sim: fix to support ConvOutput
authorSebastien Bourdeauducq <sb@m-labs.hk>
Sun, 12 Apr 2015 06:06:57 +0000 (14:06 +0800)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Sun, 12 Apr 2015 06:06:57 +0000 (14:06 +0800)
migen/sim/generic.py
migen/sim/icarus.py

index 2977cf9d8293b03967a4b0876c6cefba27072316..8377e00d74fabc8964dbf6caf13e2bbb39cae197 100644 (file)
@@ -87,11 +87,11 @@ class Simulator:
                c_top = self.top_level.get(sockaddr)
 
                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,
                        name=self.top_level.dut_type,
-                       return_ns=True,
                        **vopts)
+               self.namespace = c_fragment.ns
 
                self.cycle_counter = -1
 
index 866a3fdce1c0e46b91cd4ea1eda541ef5239b6c7..7f8c30c72c1564ff138323b019c119715df13f84 100644 (file)
@@ -5,10 +5,6 @@ import subprocess
 import os
 import time
 
-def _str2file(filename, contents):
-       f = open(filename, "w")
-       f.write(contents)
-       f.close()
 
 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):
@@ -20,11 +16,14 @@ class Runner:
                self.top_file = top_file
                self.dut_file = dut_file
                self.vvp_file = vvp_file
+               self.data_files = []
                self.keep_files = keep_files
 
        def start(self, c_top, c_dut):
-               _str2file(self.top_file, c_top)
-               _str2file(self.dut_file, c_dut)
+               with open(self.top_file, "w") as f:
+                       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)
                self.process = subprocess.Popen(["vvp", "-mmigensim", "-Mvpi", self.vvp_file])
 
@@ -36,8 +35,9 @@ class Runner:
                                self.process.kill()
                        self.process.wait()
                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:
                                        os.remove(f)
                                except OSError:
                                        pass
+               self.data_files.clear()