Skip to content

Commit e1976d7

Browse files
committed
Private names
1 parent d0ce64d commit e1976d7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

amaranth/sim/core.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,23 @@ def write_vcd(self, vcd_file, gtkw_file=None, *, traces=(), fs_per_delta=0):
239239
file.close()
240240
raise ValueError("Cannot start writing waveforms after advancing simulation time")
241241

242-
for trace in traces:
243-
if isinstance(trace, ValueLike):
244-
trace_cast = Value.cast(trace)
242+
def traverse_traces(traces):
243+
if isinstance(traces, ValueLike):
244+
trace_cast = Value.cast(traces)
245245
for trace_signal in trace_cast._rhs_signals():
246246
if trace_signal.name == "":
247-
if trace_signal is trace:
247+
if trace_signal is traces:
248248
raise TypeError("Cannot trace signal with private name")
249249
else:
250-
raise TypeError(f"Cannot trace signal with private name (within {trace!r})")
250+
raise TypeError(f"Cannot trace signal with private name (within {traces!r})")
251+
elif isinstance(traces, list) or isinstance(traces, tuple):
252+
for trace in traces:
253+
traverse_traces(trace)
254+
elif isinstance(traces, dict):
255+
for trace in traces.values():
256+
traverse_traces(trace)
257+
258+
traverse_traces(traces)
251259

252260
return self._engine.write_vcd(vcd_file=vcd_file, gtkw_file=gtkw_file,
253261
traces=traces, fs_per_delta=fs_per_delta)

0 commit comments

Comments
 (0)