Skip to content

Commit 96bac4b

Browse files
authored
Throw an exception if the user tries to render a trace without stepping the simulation (#472)
1 parent 97f29c0 commit 96bac4b

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

pyrtl/simulation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,9 @@ def render_trace(
17551755
is not found in the map, the argument ``repr_func`` will be used instead.
17561756
:param segment_size: Traces are broken in the segments of this number of cycles.
17571757
"""
1758+
if len(self) == 0:
1759+
msg = "You need to step the simulation at least once to render a trace."
1760+
raise PyrtlError(msg)
17581761
if repr_per_name is None:
17591762
repr_per_name = {}
17601763
if _currently_in_jupyter_notebook():

tests/test_compilesim.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,14 +1206,8 @@ def test_empty_trace_after_untraceable_removed(self):
12061206
r.next <<= r + 1
12071207
sim = self.sim()
12081208
sim.step_multiple(provided_inputs={}, nsteps=10)
1209-
with self.assertRaises(pyrtl.PyrtlError) as ex:
1209+
with self.assertRaises(pyrtl.PyrtlError):
12101210
sim.tracer.render_trace()
1211-
self.assertEqual(
1212-
str(ex.exception),
1213-
"Empty trace list. This may have occurred because "
1214-
"untraceable wires were removed prior to simulation, "
1215-
"if a CompiledSimulation was used.",
1216-
)
12171211

12181212
def test_invalid_base(self):
12191213
self.in1 = pyrtl.Input(8, "in1")

0 commit comments

Comments
 (0)