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+" "
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")
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)
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)