sim.pysim: use "bench" as a top level root for testbench signals.
authorIrides <irides@irides.network>
Thu, 16 Dec 2021 01:47:48 +0000 (19:47 -0600)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 31 Dec 2021 20:38:17 +0000 (20:38 +0000)
Fixes #561.

nmigen/sim/pysim.py
tests/test_sim.py

index cc3d9483854ed0722201156335a43e16f2757df3..c3c40efacea4aa132577cc80a0539f68ff35ee1c 100644 (file)
@@ -19,7 +19,7 @@ class _NameExtractor:
     def __init__(self):
         self.names = SignalDict()
 
-    def __call__(self, fragment, *, hierarchy=("top",)):
+    def __call__(self, fragment, *, hierarchy=("bench", "top",)):
         def add_signal_name(signal):
             hierarchical_signal_name = (*hierarchy, signal.name)
             if signal not in self.names:
@@ -74,7 +74,7 @@ class _VCDWriter:
         trace_names = SignalDict()
         for trace in traces:
             if trace not in signal_names:
-                trace_names[trace] = {("top", trace.name)}
+                trace_names[trace] = {('bench', trace.name)}
             self.traces.append(trace)
 
         if self.vcd_writer is None:
index 94b1141a2951a2253e520c2ac3aa0000ba4fddc6..7a72cca2f7bd98b99353f831ad7abb8e570bfaad 100644 (file)
@@ -849,7 +849,7 @@ class SimulatorRegressionTestCase(FHDLTestCase):
                 pass
         sim = Simulator(dut)
         with self.assertRaisesRegex(NameError,
-                r"^Signal 'top\.name with space_state' contains a whitespace character$"):
+                r"^Signal 'bench\.top\.name with space_state' contains a whitespace character$"):
             with open(os.path.devnull, "w") as f:
                 with sim.write_vcd(f):
                     sim.run()