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:
parent
dbbdc287af
commit
d65204febd
@ -75,6 +75,16 @@ class Simulation(object):
|
|||||||
warn("Cosimulation not registered as Simulation argument")
|
warn("Cosimulation not registered as Simulation argument")
|
||||||
del _futureEvents[:]
|
del _futureEvents[:]
|
||||||
del _siglist[:]
|
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):
|
def run(self, duration=None, quiet=0):
|
||||||
|
|
||||||
@ -165,19 +175,11 @@ class Simulation(object):
|
|||||||
except StopSimulation:
|
except StopSimulation:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
printExcInfo()
|
printExcInfo()
|
||||||
if cosim:
|
self.finalize()
|
||||||
_simulator._cosim = 0
|
|
||||||
os.close(cosim._rt)
|
|
||||||
os.close(cosim._wf)
|
|
||||||
os.waitpid(cosim._child_pid, 0)
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
except:
|
except:
|
||||||
if cosim:
|
self.finalize()
|
||||||
_simulator._cosim = 0
|
|
||||||
os.close(cosim._rt)
|
|
||||||
os.close(cosim._wf)
|
|
||||||
os.waitpid(cosim._child_pid, 0)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user