1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

refactor + clean-up cosimulation upon exception

This commit is contained in:
jand 2003-05-12 23:36:08 +00:00
parent dbbdc287af
commit d65204febd

View File

@ -76,6 +76,16 @@ class Simulation(object):
del _futureEvents[:]
del _siglist[:]
def finalize(self):
cosim = self._cosim
if cosim:
_simulator._cosim = 0
os.close(cosim._rt)
os.close(cosim._wf)
os.waitpid(cosim._child_pid, 0)
def run(self, duration=None, quiet=0):
""" Run the simulation for some duration.
@ -165,19 +175,11 @@ class Simulation(object):
except StopSimulation:
if not quiet:
printExcInfo()
if cosim:
_simulator._cosim = 0
os.close(cosim._rt)
os.close(cosim._wf)
os.waitpid(cosim._child_pid, 0)
self.finalize()
return 0
except:
if cosim:
_simulator._cosim = 0
os.close(cosim._rt)
os.close(cosim._wf)
os.waitpid(cosim._child_pid, 0)
self.finalize()
raise