back.pysim: emit toplevel inputs in VCD files as well.
authorwhitequark <whitequark@whitequark.org>
Thu, 6 Feb 2020 17:19:47 +0000 (17:19 +0000)
committerwhitequark <whitequark@whitequark.org>
Thu, 6 Feb 2020 17:19:47 +0000 (17:19 +0000)
Before this commit, only signals driven from fragments (in practice,
everything except toplevel inputs) would get written to a VCD file.
Not having toplevel inputs in the dump made debugging ~impossible.

After this commit, all signals the fragment refers to get written to
a VCD file. (More specifically, all signals the compiler assigns
an index to, i.e. signals the generated code reads or writes.)

Fixes #280.

nmigen/back/pysim.py

index 63455fcf684cb900e953816e3c8657c7b5f9677c..0187a07efd794c9d0736b2242e4ff4fb36cafe51 100644 (file)
@@ -704,9 +704,6 @@ class _FragmentCompiler:
                 self.signal_names[signal].add(hierarchical_signal_name)
 
         for domain_name, domain_signals in fragment.drivers.items():
-            for domain_signal in domain_signals:
-                add_signal_name(domain_signal)
-
             domain_stmts = LHSGroupFilter(domain_signals)(fragment.statements)
             domain_process = _CompiledProcess(self.state, comb=domain_name is None,
                 name=".".join((*hierarchy, "<{}>".format(domain_name or "comb"))))
@@ -762,6 +759,9 @@ class _FragmentCompiler:
 
             processes.add(domain_process)
 
+            for used_signal in domain_process.context.indexes:
+                add_signal_name(used_signal)
+
         for subfragment_index, (subfragment, subfragment_name) in enumerate(fragment.subfragments):
             if subfragment_name is None:
                 subfragment_name = "U${}".format(subfragment_index)