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
quits or scroll waveform horizontally or scroll waveform vertically decrease increase waveform scale will find the next prev transition on the highlighted signal save or load the current waveform configuration move the cursor increase decrease the signals pane size increase decrease the values pane size increase decrease the waves pane size Left clicking on the waveform will position a cursor and show the value of signals at that cycle in the values window All windows also have scroll bars that can be clicked on q escape left right ctrl mouse wheel up down mouse wheel e b s S h j k l 9 0 _
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