+# 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
+ 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("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)
+
+