sim.pysim: Only close VCD/GTKW files if we opened them ourselves.
Fixes #1107.
This commit is contained in:
parent
fc81ff17f7
commit
a725282751
|
@ -41,10 +41,14 @@ class _VCDWriter:
|
||||||
# the simulator is still usable if it's not installed for some reason.
|
# the simulator is still usable if it's not installed for some reason.
|
||||||
import vcd, vcd.gtkw
|
import vcd, vcd.gtkw
|
||||||
|
|
||||||
|
self.close_vcd = False
|
||||||
|
self.close_gtkw = False
|
||||||
if isinstance(vcd_file, str):
|
if isinstance(vcd_file, str):
|
||||||
vcd_file = open(vcd_file, "w")
|
vcd_file = open(vcd_file, "w")
|
||||||
|
self.close_vcd = True
|
||||||
if isinstance(gtkw_file, str):
|
if isinstance(gtkw_file, str):
|
||||||
gtkw_file = open(gtkw_file, "w")
|
gtkw_file = open(gtkw_file, "w")
|
||||||
|
self.close_gtkw = True
|
||||||
|
|
||||||
self.vcd_signal_vars = SignalDict()
|
self.vcd_signal_vars = SignalDict()
|
||||||
self.vcd_memory_vars = {}
|
self.vcd_memory_vars = {}
|
||||||
|
@ -189,9 +193,9 @@ class _VCDWriter:
|
||||||
else:
|
else:
|
||||||
assert False # :nocov:
|
assert False # :nocov:
|
||||||
|
|
||||||
if self.vcd_file is not None:
|
if self.close_vcd:
|
||||||
self.vcd_file.close()
|
self.vcd_file.close()
|
||||||
if self.gtkw_file is not None:
|
if self.close_gtkw:
|
||||||
self.gtkw_file.close()
|
self.gtkw_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue