From d3775eedd742992011712f6cce7d4246ebc81e16 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 6 Feb 2020 17:07:48 +0000 Subject: [PATCH] back.pysim: make `write_vcd(traces=)` actually use those traces. Reported in #280. --- nmigen/back/pysim.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 6bf4b7c..63455fc 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -1,6 +1,7 @@ import inspect import warnings from contextlib import contextmanager +import itertools from vcd import VCDWriter from vcd.gtkw import GTKWSave @@ -85,7 +86,15 @@ class _VCDWaveformWriter(_WaveformWriter): self.gtkw_file = gtkw_file self.gtkw_save = gtkw_file and GTKWSave(self.gtkw_file) - for signal, names in signal_names.items(): + self.traces = [] + + trace_names = SignalDict() + for trace in traces: + if trace not in signal_names: + trace_names[trace] = trace.name + self.traces.append(trace) + + for signal, names in itertools.chain(signal_names.items(), trace_names.items()): if signal.decoder: var_type = "string" var_size = 1 @@ -137,12 +146,12 @@ class _VCDWaveformWriter(_WaveformWriter): self.gtkw_save.dumpfile_size(self.vcd_file.tell()) self.gtkw_save.treeopen("top") - for signal, hierarchy in self.gtkw_names.items(): + for signal in self.traces: if len(signal) > 1 and not signal.decoder: suffix = "[{}:0]".format(len(signal) - 1) else: suffix = "" - self.gtkw_save.trace(".".join(hierarchy) + suffix) + self.gtkw_save.trace(".".join(self.gtkw_names[signal]) + suffix) self.vcd_file.close() if self.gtkw_file is not None: -- 2.30.2