Testing Hardware With ASCII Waveforms

Testing software is — sometimes — easier than testing hardware. After all, you can always create test files and even fake user input before monitoring outputs using common tools. Hardware though, is a bit different. Sometimes it is hard to visualize exactly what’s happening. [Andrew Ray’s] answer? Produce simulated waveforms using ASCII text.

The process uses some custom tools written in OCaml, but the code is available for you on GitHub. The tool, called Hardcaml, allows you to write test benches for hardware — not a new idea for FPGA developers. The output, however, is an ASCII text waveform and common software development tools can check that waveform against the expected output.

You could do the same thing with a Verilog VCD file, of course, but it wouldn’t be as much fun to read. You’d want to use a waveform viewer to really see what’s going on. In fact, we wondered if it would be worth going the other way, to convert the Hardcaml output to VCD so tools you use to diff waveforms would possibly work.

We like ASCII art. In fact, we took our own crack at ASCII CAD back in 2002. You can even go 3D with your ASCII art if you like.

13 thoughts on “Testing Hardware With ASCII Waveforms

  1. “The process uses some custom tools written in OCaml, but the code is available for you on GitHub. The tool, called Hardcaml, allows you to write test benches for hardware — not a new idea for FPGA developers”

    Hardcaml is actually more than a testbench tool. It’s a complete framework for FPGA development, a bit like nMigen or Chisel, but in OCaml.

  2. It’ll be a mess with proportional space fonts. That’s something won’t work too well as is when you want to copy/paste to on the web.
    Some of the FPGA tools has a waveform editor for stimulus. Real life signals do not align exactly on clock edges.

    1. Would be cool if you could define tolerances and perfect alignment means in tolerance.

      You’d need to hit it with something more accurate of course but zoom could also be used to get a closer look.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.