Signals to display traces for.
"""
if self._state.timeline.now != 0.0:
+ for file in (vcd_file, gtkw_file):
+ if hasattr(file, "close"):
+ file.close()
raise ValueError("Cannot start writing waveforms after advancing simulation time")
+
waveform_writer = _VCDWaveformWriter(self._fragment,
vcd_file=vcd_file, gtkw_file=gtkw_file, traces=traces)
- self._waveform_writers.append(waveform_writer)
- yield
- waveform_writer.close(self._state.timeline.now)
- self._waveform_writers.remove(waveform_writer)
+ try:
+ self._waveform_writers.append(waveform_writer)
+ yield
+ finally:
+ waveform_writer.close(self._state.timeline.now)
+ self._waveform_writers.remove(waveform_writer)