build/sim/verilator: compile sim just before running and not when building.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 21 Dec 2018 08:57:52 +0000 (09:57 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 21 Dec 2018 08:59:34 +0000 (09:59 +0100)
litex/build/sim/verilator.py

index 76f607f023ae6258b905503ec4602be598361ed3..e13cd3a9d19bc17687447f099b17f7dc4c6f2735 100644 (file)
@@ -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("../../")