tools/litex_sim: Avoid double build iteration with pre_run_callback function.
This commit is contained in:
parent
c98c777bed
commit
de738e153d
|
@ -190,7 +190,8 @@ class SimVerilatorToolchain:
|
|||
trace_start = 0,
|
||||
trace_end = -1,
|
||||
regular_comb = False,
|
||||
interactive = True):
|
||||
interactive = True,
|
||||
pre_run_callback = None):
|
||||
|
||||
# Create build directory
|
||||
os.makedirs(build_dir, exist_ok=True)
|
||||
|
@ -228,6 +229,8 @@ class SimVerilatorToolchain:
|
|||
|
||||
# Run
|
||||
if run:
|
||||
if pre_run_callback is not None:
|
||||
pre_run_callback(v_output.ns)
|
||||
if which("verilator") is None:
|
||||
msg = "Unable to find Verilator toolchain, please either:\n"
|
||||
msg += "- Install Verilator.\n"
|
||||
|
|
|
@ -454,14 +454,13 @@ def main():
|
|||
soc.add_constant("REMOTEIP{}".format(i+1), int(args.remote_ip.split(".")[i]))
|
||||
|
||||
# Build/Run ------------------------------------------------------------------------------------
|
||||
def pre_run_callback(vns):
|
||||
generate_gtkw_savefile(builder, vns, args.trace_fst)
|
||||
|
||||
builder_kwargs["csr_csv"] = "csr.csv"
|
||||
builder = Builder(soc, **builder_kwargs)
|
||||
for i in range(2):
|
||||
build = (i == 0)
|
||||
run = (i == 1)
|
||||
vns = builder.build(
|
||||
build = build,
|
||||
run = run,
|
||||
soc.platform.toolchain.pre_run_callback = pre_run_callback
|
||||
builder.build(
|
||||
threads = args.threads,
|
||||
sim_config = sim_config,
|
||||
opt_level = args.opt_level,
|
||||
|
@ -469,12 +468,9 @@ def main():
|
|||
trace_fst = args.trace_fst,
|
||||
trace_start = trace_start,
|
||||
trace_end = trace_end,
|
||||
interactive = not args.non_interactive
|
||||
interactive = not args.non_interactive,
|
||||
pre_run_callback = pre_run_callback
|
||||
)
|
||||
if args.with_analyzer:
|
||||
soc.analyzer.export_csv(vns, "analyzer.csv")
|
||||
if args.gtkwave_savefile:
|
||||
generate_gtkw_savefile(builder, vns, args.trace_fst)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue