+"""
+ This work is funded through NLnet under Grant 2019-02-012
+
+ License: LGPLv3+
+
+
+"""
from vcd.gtkw import GTKWSave, GTKWColor
from math import log2
:param color: default trace color
:param base: default numerical base
:param loc: source code location to include as a comment
- :param zoom: initial zoom level, in GTKWave format
+ :param zoom: initial zoom level, in GTKWave format. Can also be "formal"
+ when the file comes from a formal engine
:param marker: initial location of a marker
:param clk_period: clock period in seconds, helping
to set a reasonable initial zoom level.
Attribute choices:
- * module: instance path, for prepending to the signal name
+ * module: absolute path of the current module
+ * submodule: same as above, but relative
* 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
* bit: select a bit from a wide signal. MSB is zero, unfortunately
+ * closed (for groups): this group starts closed
**gtkw_dom format**
In place of a class name, an inline class description can be used.
``(signal, {attribute: value, ...}, ...)``
+
+ An anonymous group can be used to apply a style to a group of signals.
+ ``({attribute: value}, [signal, signal, ...])``
"""
colors = {
'blue': GTKWColor.blue,
gtkw.dumpfile(vcd_name)
# set a reasonable zoom level
# also, move the marker to an interesting place
+ if zoom == "formal":
+ # output from formal engines looks good at this zoom level
+ zoom = -6.3
if zoom is None:
zoom = -42.8 - log2(clk_period)
# base zoom level is affected by time resolution units
elif isinstance(node, dict):
if 'comment' in node:
gtkw.blank(node['comment'])
+ # merge the submodule into the module path
+ if 'submodule' in node_style:
+ node_module = node_style['submodule']
+ if 'module' in node_style:
+ node_top_module = node_style['module']
+ node_module = node_top_module + '.' + node_module
+ # update the module path
+ node_style['module'] = node_module
+ # don't propagate this attribute to children
+ del node_style['submodule']
# emit the group delimiters and walk over the child list
if children is not None:
- gtkw.begin_group(node_name)
+ # see whether this group starts closed
+ closed = False
+ if 'closed' in node_style:
+ closed = node_style['closed']
+ del node_style['closed'] # do not inherit
+ # only emit a group if it has a name
+ if isinstance(node_name, str):
+ gtkw.begin_group(node_name, closed)
# pass on the group style to its children
walk(children, node_style)
- gtkw.end_group(node_name)
+ if isinstance(node_name, str):
+ gtkw.end_group(node_name)
# emit a trace, if the node is a signal
elif node_name is not None:
signal_name = node_name