In addition to waveforms, myhdlpeek
also lets you display the captured traces as tables.
To demonstrate, I'll use our old friend the multiplexer:
from myhdl import *
from myhdlpeek import Peeker # Import the myhdlpeeker module.
def mux(z, a, b, sel):
"""A simple multiplexer."""
@always_comb
def mux_logic():
if sel == 1:
z.next = a # Signal a sent to mux output when sel is high.
else:
z.next = b # Signal b sent to mux output when sel is low.
return mux_logic
# Create some signals to attach to the multiplexer.
a, b, z = [Signal(0) for _ in range(3)] # Integer signals for the inputs & output.
sel = Signal(intbv(0)[1:]) # Binary signal for the selector.
# Create some Peekers to monitor the multiplexer I/Os.
Peeker.clear() # Clear any existing Peekers. (Start with a clean slate.)
Peeker(a, 'a') # Add a Peeker to the a input.
Peeker(b, 'b') # Add a Peeker to the b input.
Peeker(z, 'z') # Add a peeker to the z output.
Peeker(sel, 'select') # Add a Peeker to the select input. The Peeker label doesn't have to match the signal name.
# Instantiate mux.
mux_1 = mux(z, a, b, sel)
# Apply random patterns to the multiplexer.
from random import randrange
def test():
for _ in range(8):
a.next, b.next, sel.next = randrange(8), randrange(8), randrange(2)
yield delay(1)
# Simulate the multiplexer, testbed and the peekers.
sim = Simulation(mux_1, test(), *Peeker.instances()).run()
Once the simulation has run, I can display the results using a table instead of waveforms:
Peeker.to_html_table()
I can use the same options for tabular output that are available for showing waveforms:
Peeker.to_html_table('select a b z', start_time=3) # Select and change order of signals, and set start time.
There's even a version for use in console mode (outside of the Jupyter environment):
Peeker.to_text_table('select a b z')