Writing waveforms in expect tests can be very useful but does come with it s limitations In particular it is not really possible to print very long traces and designs with lots and lots of signals can become unwieldy As an alternative we can use the terminal based interactive waveform viewer

Building a Simulation Application

The interactive waveform viewer should be built as a top level application It should be linked with the library Waveforms are created in the normal way by wrapping a simulator with and then running a testbench The following function is used to run the viewer hardcaml_waveterm_interactive Hardcaml_waveterm Wavform create # Hardcaml_waveterm_interactive run waves

Using the Waveform Viewer

Left clicking on the waveform will position the active cursor and show the value of signals at that cycle in the values window Cycle deltas between different cursors is shown in the wave view title All windows also have scroll bars that can be clicked on A can be present in the current directory your home directory or found via the environment variable to configure key bindings # Hardcaml_waveterm_interactive print_key_help Escape quit Up scroll up Down scroll down Ctrl Up scroll up fast Ctrl Down scroll down fast show help cursor centered zoom in cursor centered zoom out Alt cursor centered zoom in fast Alt cursor centered zoom out fast 9 expand signals window shrink signals window 0 expand values window shrink values window Home scroll wave to beginning End scroll wave to end Ctrl Home scroll to first signal Ctrl End scroll to last signal Left scroll left Right scroll right Ctrl Left scroll left fast Ctrl Right scroll right fast k move cursor up j move cursor down h move cursor left l move cursor right K move cursor up fast J move cursor down fast H move cursor left fast L move cursor right fast g center on cursor G set cursor to first wave on screen 1 select cursor 1 2 select cursor 2 3 select cursor 3 4 select cursor 4 5 select cursor 5 Alt 1 select cursor 1 and center Alt 2 select cursor 2 and center Alt 3 select cursor 3 and center Alt 4 select cursor 4 and center Alt 5 select cursor 5 and center r remove selected cursor Enter maybe toggle module s save ui state S load ui state e search for transition forward b search for transition backward f cycle wave format F reset wave format c cycle colour C toggle bold unit hardcamlwavetermrc HARDCAMLWAVETERMRC

Interactive Waveforms from Expect Tests

Waveform based expect tests are very information limited We often either run very small simulations show a small portion of a larger simulation or zoom far out to capture general behavior Often we can see the behavior of control signals but not the detailed values on data buses To help with this the library can optionally serialize a waveform to disk It provides an function which is very similar to This provides an optional argument called which specifies the filename to which the waveform will be saved The suffix will be added By default waveforms are not saved To do so execute the tests with the following environment variable set Which will output a file in the same directory called To view the waveform a tool called is provided with in the directory Hardcaml_waveterm expect Hardcaml_waveterm Waveform print Hardcaml_waveterm Waveform expect serialize_to filename waves serialize_to hardcamlwaveform EXPECT_TEST_WAVEFORM 1 filename hardcamlwaveform waveform_viewer hardcaml_waveterm bin waveform_viewer exe show filename hardcamlwaveform