+import warnings
+
from migen.fhdl.std import *
from migen.fhdl.structure import _Fragment
from migen.fhdl import verilog
self.multiwrite(getattr(obj, k), v)
def __del__(self):
+ if hasattr(self, "ipc"):
+ warnings.warn("call Simulator.close() to clean up "
+ "or use it as a contextmanager", DeprecationWarning)
+ self.close()
+
+ def close(self):
+ self.ipc.close()
+ self.sim_runner.close()
del self.ipc
del self.sim_runner
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
# Contrary to multiread/multiwrite, Proxy fetches the necessary signals only and
# immediately forwards writes into the simulation.
class Proxy:
import subprocess
import os
+import time
def _str2file(filename, contents):
f = open(filename, "w")
subprocess.check_call(["iverilog", "-o", self.vvp_file] + self.options + [self.top_file, self.dut_file] + self.extra_files)
self.process = subprocess.Popen(["vvp", "-mmigensim", self.vvp_file])
- def __del__(self):
+ def close(self):
if hasattr(self, "process"):
+ self.process.terminate()
+ if self.process.poll() is None:
+ time.sleep(.1)
+ self.process.kill()
self.process.wait()
if not self.keep_files:
for f in [self.top_file, self.dut_file, self.vvp_file]: