Add color style
authorCesar Strauss <cestrauss@gmail.com>
Sun, 23 Aug 2020 17:44:54 +0000 (14:44 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Sun, 23 Aug 2020 17:44:54 +0000 (14:44 -0300)
src/soc/experiment/alu_fsm.py

index 6f5de4fd00cbc7780e0c7f9f1b871e7d014df859..0079bbd5360a4005aec0bc2edfd1f6802b12b392 100644 (file)
@@ -294,6 +294,18 @@ def write_gtkw(gtkw_name, vcd_name, gtkw_style, gtkw_dom,
     In place of a class name, an inline class description can be used.
     ``(signal, {attribute: value, ...}, ...)``
     """
+    colors = {
+        'blue': GTKWColor.blue,
+        'cycle': GTKWColor.cycle,
+        'green': GTKWColor.green,
+        'indigo': GTKWColor.indigo,
+        'normal': GTKWColor.normal,
+        'orange': GTKWColor.orange,
+        'red': GTKWColor.red,
+        'violet': GTKWColor.violet,
+        'yellow': GTKWColor.yellow,
+    }
+
     with open(gtkw_name, "wt") as gtkw_file:
         gtkw = GTKWSave(gtkw_file)
         if loc is not None:
@@ -348,7 +360,10 @@ def write_gtkw(gtkw_name, vcd_name, gtkw_style, gtkw_dom,
                     # prepend module name to signal
                     if 'module' in node_style:
                         signal_name = node_style['module'] + '.' + signal_name
-                    gtkw.trace(signal_name)
+                    color = None
+                    if 'color' in node_style:
+                        color = colors[node_style['color']]
+                    gtkw.trace(signal_name, color=color)
 
         walk(gtkw_dom, root_style)