mibuild/sim/verilator: remove verilator_root, use -Wno-fatal and add verbose option...
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 2 Mar 2015 22:23:23 +0000 (23:23 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 2 Mar 2015 22:23:23 +0000 (23:23 +0100)
mibuild/sim/verilator.py

index c3a23f5945dcd62fe25b1a69609ea345f88d11ac..20afa8deb47f09001b3e5c5c00278ff8b0ef4002 100644 (file)
@@ -49,7 +49,7 @@ def _build_tb(platform, template):
        f.close()
        tools.write_to_file("dut_tb.cpp", content)
 
-def _build_sim(platform, build_name, include_paths, verilator_root_path, template_file, trace):
+def _build_sim(platform, build_name, include_paths, template_file, trace, verbose):
        include = ""
        for path in include_paths:
                include += "-I"+path+" "
@@ -57,17 +57,20 @@ def _build_sim(platform, build_name, include_paths, verilator_root_path, templat
        build_script_contents = """# Autogenerated by mibuild
        rm -rf obj_dir/
 verilator {disable_warnings} -O3 --cc dut.v --exe dut_tb.cpp {trace} {include}
-make -j -C obj_dir/ -f Vdut.mk Vdut VERILATOR_ROOT={verilator_root}
+make -j -C obj_dir/ -f Vdut.mk Vdut
 
-""".format(verilator_root= os.path.join("../../", verilator_root_path), # XXX
-       disable_warnings="-Wno-lint -Wno-INITIALDLY",
+""".format(
+       disable_warnings="-Wno-fatal",
        trace="-trace" if trace else "",
        include=include)
        build_script_file = "build_" + build_name + ".sh"
        tools.write_to_file(build_script_file, build_script_contents, force_unix=True)
 
        _build_tb(platform, os.path.join("../", template_file)) # XXX
-       r = subprocess.call(["bash", build_script_file])
+       if verbose:
+               r = subprocess.call(["bash", build_script_file])
+       else:
+               r = subprocess.call(["bash", build_script_file], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
        if r != 0:
                raise OSError("Subprocess failed")
 
@@ -81,10 +84,10 @@ def _run_sim(build_name):
                raise OSError("Subprocess failed")
 
 class VerilatorPlatform(GenericPlatform):
-       # XXX fix template / verilator_path
+       # XXX fix template_file
        def build(self, soc, build_dir="build", build_name="top", run=True, trace=True,
                        template_file="../migen/mibuild/sim/dut_tb.cpp",
-                       verilator_root_path="../verilator"):
+                       verbose=False):
                tools.mkdir_noerror(build_dir)
                os.chdir(build_dir)
 
@@ -103,7 +106,7 @@ class VerilatorPlatform(GenericPlatform):
                        if path not in include_paths:
                                include_paths.append(path)
                include_paths += self.verilog_include_paths
-               _build_sim(self, build_name, include_paths, verilator_root_path, template_file, trace)
+               _build_sim(self, build_name, include_paths, template_file, trace, verbose)
 
                if run:
                        _run_sim(build_name)