Skip to content

Commit

Permalink
sim.pysim: use "bench" as a top level root for testbench signals.
Browse files Browse the repository at this point in the history
Fixes #561.
  • Loading branch information
Lunaphied committed Dec 16, 2021
1 parent b1f5664 commit 7dcd3d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions amaranth/sim/pysim.py
Expand Up @@ -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:
Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, fragment, *, vcd_file, gtkw_file=None, traces=()):
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:
Expand Down
1 change: 1 addition & 0 deletions docs/changes.rst
Expand Up @@ -70,6 +70,7 @@ Toolchain changes
* Added: :meth:`build.BuildPlan.execute_remote_ssh`.
* Deprecated: :class:`test.utils.FHDLTestCase`, with no replacement.
* Deprecated: :func:`back.rtlil.convert()` and :func:`back.verilog.convert()` without an explicit `ports=` argument.
* Changed: VCD output now uses a top-level "bench" module that contains testbench only signals.


Platform integration changes
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sim.py
Expand Up @@ -849,7 +849,7 @@ def test_bug_595(self):
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()
Expand Down

0 comments on commit 7dcd3d3

Please sign in to comment.