From 2deffd8c8a9f2a80a1ec7e153aeffa725638a03a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 21 Dec 2018 09:57:52 +0100 Subject: [PATCH] build/sim/verilator: compile sim just before running and not when building. --- litex/build/sim/verilator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/litex/build/sim/verilator.py b/litex/build/sim/verilator.py index 76f607f02..e13cd3a9d 100644 --- a/litex/build/sim/verilator.py +++ b/litex/build/sim/verilator.py @@ -117,7 +117,7 @@ def _generate_sim_config(config): tools.write_to_file("sim_config.js", content) -def _build_sim(platform, build_name, sources, threads, coverage, verbose): +def _build_sim(build_name, sources, threads, coverage): makefile = os.path.join(core_directory, 'Makefile') cc_srcs = [] for filename, language, library in sources: @@ -134,6 +134,8 @@ mkdir -p modules && cp obj_dir/*.so modules build_script_file = "build_" + build_name + ".sh" tools.write_to_file(build_script_file, build_script_contents, force_unix=True) +def _compile_sim(build_name, verbose): + build_script_file = "build_" + build_name + ".sh" p = subprocess.Popen(["bash", build_script_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output, _ = p.communicate() output = output.decode('utf-8') @@ -146,7 +148,6 @@ mkdir -p modules && cp obj_dir/*.so modules if verbose: print(output) - def _run_sim(build_name, as_root=False): run_script_contents = "sudo " if as_root else "" run_script_contents += "obj_dir/Vdut" @@ -198,10 +199,11 @@ class SimVerilatorToolchain: _generate_sim_config(sim_config) # build - _build_sim(platform, build_name, platform.sources, threads, coverage, verbose) + _build_sim(build_name, platform.sources, threads, coverage) # run if run: + _compile_sim(build_name, verbose) _run_sim(build_name, as_root=sim_config.has_module("ethernet")) os.chdir("../../")