from soc.fu.base_input_record import CompOpSubsetBase
from soc.decoder.power_enums import (MicrOp, Function)
-from vcd.gtkw import GTKWSave, GTKWColor
+from nmutil.gtkw import write_gtkw
class CompFSMOpSubset(CompOpSubsetBase):
return list(self)
-# Write a formatted GTKWave "save" file
-def write_gtkw(base_name, top_dut_name, loc):
- # hierarchy path, to prepend to signal names
- dut = top_dut_name + "."
- # color styles
- style_input = GTKWColor.orange
- style_output = GTKWColor.yellow
- style_debug = GTKWColor.red
- with open(base_name + ".gtkw", "wt") as gtkw_file:
- gtkw = GTKWSave(gtkw_file)
- gtkw.comment("Auto-generated by " + loc)
- gtkw.dumpfile(base_name + ".vcd")
- # set a reasonable zoom level
- # also, move the marker to an interesting place
- gtkw.zoom_markers(-22.9, 10500000)
- gtkw.trace(dut + "clk")
- # place a comment in the signal names panel
- gtkw.blank("Shifter Demonstration")
- with gtkw.group("prev port"):
- gtkw.trace(dut + "op__sdir", color=style_input)
- # demonstrates using decimal base (default is hex)
- gtkw.trace(dut + "p_data_i[7:0]", color=style_input,
- datafmt='dec')
- gtkw.trace(dut + "p_shift_i[7:0]", color=style_input,
- datafmt='dec')
- gtkw.trace(dut + "p_valid_i", color=style_input)
- gtkw.trace(dut + "p_ready_o", color=style_output)
- with gtkw.group("debug"):
- gtkw.blank("Some debug statements")
- # change the displayed name in the panel
- gtkw.trace("top.zero", alias='zero delay shift',
- color=style_debug)
- gtkw.trace("top.interesting", color=style_debug)
- gtkw.trace("top.test_case", alias="test case", color=style_debug)
- gtkw.trace("top.msg", color=style_debug)
- with gtkw.group("internal"):
- gtkw.trace(dut + "fsm_state")
- gtkw.trace(dut + "count[3:0]")
- gtkw.trace(dut + "shift_reg[7:0]", datafmt='dec')
- with gtkw.group("next port"):
- gtkw.trace(dut + "n_data_o[7:0]", color=style_output,
- datafmt='dec')
- gtkw.trace(dut + "n_valid_o", color=style_output)
- gtkw.trace(dut + "n_ready_i", color=style_input)
-
-
def test_shifter():
m = Module()
m.submodules.shf = dut = Shifter(8)
with open("test_shifter.il", "w") as f:
f.write(il)
- # Write the GTKWave project file
- write_gtkw("test_shifter", "top.shf", __file__)
-
# Describe a GTKWave document
- # Uses a split CSS + DOM approach, where style is separated from
- # content.
# Style for signals, classes and groups
- # Syntax: {selector: {attribute: value, ...}, ...}
- # "selector" can be a signal, class or group
- # signal groups propagate most attributes to their children
- # attribute choices:
- # - module: instance path, for prepending to the signal name
- # - color: trace color
- # - base: numerical base for value display
- # - display: alternate text to display in the signal pane
- # - comment: comment to display in the signal pane
-
gtkwave_style = {
# Root selector. Gives default attributes for every signal.
- '': {'module': 'top.shf', 'base': 'dec'},
+ '': {'base': 'dec'},
# color the traces, according to class
# class names are not hardcoded, they are just strings
'in': {'color': 'orange'},
}
# DOM style description for the trace pane
- # Syntax: [signal, (signal, class), (group, [children]), comment, ...]
- # The DOM is a list of nodes.
- # Nodes are signals, signal groups or comments.
- # - signals are strings, or tuples: (signal name, class, class, ...)
- # - signal groups are tuples: (group name, class, class, ..., [nodes])
- # - comments are: {'comment': 'comment string'}
- # In place of a class name, an inline class description can be used.
- # (signal, {attribute: value, ...}, ...)
-
gtkwave_desc = [
# simple signal, without a class
# even so, it inherits the top-level root attributes
]),
]
- # TODO: Read and interpret the mini-language above, writing
- # TODO: the corresponding GTKWave document.
+ write_gtkw("test_shifter.gtkw", "test_shifter.vcd",
+ gtkwave_desc, gtkwave_style,
+ module="top.shf", loc=__file__, marker=10500000)
sim = Simulator(m)
sim.add_clock(1e-6)