This commit is contained in:
Florent Kermarrec 2015-04-13 09:37:03 +02:00
commit a2c17cdcef
2 changed files with 9 additions and 9 deletions

View File

@ -87,11 +87,11 @@ class Simulator:
c_top = self.top_level.get(sockaddr) c_top = self.top_level.get(sockaddr)
fragment = fragment + _Fragment(clock_domains=top_level.clock_domains) fragment = fragment + _Fragment(clock_domains=top_level.clock_domains)
c_fragment, self.namespace = verilog.convert(fragment, c_fragment = verilog.convert(fragment,
ios=self.top_level.ios, ios=self.top_level.ios,
name=self.top_level.dut_type, name=self.top_level.dut_type,
return_ns=True,
**vopts) **vopts)
self.namespace = c_fragment.ns
self.cycle_counter = -1 self.cycle_counter = -1

View File

@ -5,10 +5,6 @@ import subprocess
import os import os
import time import time
def _str2file(filename, contents):
f = open(filename, "w")
f.write(contents)
f.close()
class Runner: class Runner:
def __init__(self, options=None, extra_files=None, top_file="migensim_top.v", dut_file="migensim_dut.v", vvp_file=None, keep_files=False): def __init__(self, options=None, extra_files=None, top_file="migensim_top.v", dut_file="migensim_dut.v", vvp_file=None, keep_files=False):
@ -20,11 +16,14 @@ class Runner:
self.top_file = top_file self.top_file = top_file
self.dut_file = dut_file self.dut_file = dut_file
self.vvp_file = vvp_file self.vvp_file = vvp_file
self.data_files = []
self.keep_files = keep_files self.keep_files = keep_files
def start(self, c_top, c_dut): def start(self, c_top, c_dut):
_str2file(self.top_file, c_top) with open(self.top_file, "w") as f:
_str2file(self.dut_file, c_dut) f.write(c_top)
c_dut.write(self.dut_file)
self.data_files += c_dut.data_files.keys()
subprocess.check_call(["iverilog", "-o", self.vvp_file] + self.options + [self.top_file, self.dut_file] + self.extra_files) 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", "-Mvpi", self.vvp_file]) self.process = subprocess.Popen(["vvp", "-mmigensim", "-Mvpi", self.vvp_file])
@ -36,8 +35,9 @@ class Runner:
self.process.kill() self.process.kill()
self.process.wait() self.process.wait()
if not self.keep_files: if not self.keep_files:
for f in [self.top_file, self.dut_file, self.vvp_file]: for f in [self.top_file, self.dut_file, self.vvp_file] + self.data_files:
try: try:
os.remove(f) os.remove(f)
except OSError: except OSError:
pass pass
self.data_files.clear()