From c19916a1d0f0bef22969a0990e2a350bed53e55e Mon Sep 17 00:00:00 2001 From: Jordan Carlin Date: Sat, 10 Aug 2024 12:18:54 -0700 Subject: [PATCH] Allow Verilator to pass extra args at compile time (like -G...) --- bin/wsim | 4 ++-- sim/verilator/Makefile | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/wsim b/bin/wsim index e35ec6841..ea7086bdf 100755 --- a/bin/wsim +++ b/bin/wsim @@ -127,7 +127,7 @@ if (args.sim == "questa"): elif (args.sim == "verilator"): # PWD=${WALLY}/sim CONFIG=rv64gc TESTSUITE=arch64i print(f"Running Verilator on {args.config} {args.testsuite}") - os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} TESTBENCH={args.tb} EXTRA_ARGS='{args.args}'") + os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} TESTBENCH={args.tb} EXTRA_ARGS=\"{args.args}\"") elif (args.sim == "vcs"): print(f"Running VCS on " + args.config + " " + args.testsuite) if (args.gui): @@ -135,7 +135,7 @@ elif (args.sim == "vcs"): if (args.args == ""): vcsargs = "" else: - vcsargs = " --args " + args.args + vcsargs = " --args \"" + args.args + "\"" if (ElfFile != ""): ElfFile = " --elffile " + ElfFile cmd = cd + "; " + prefix + " ./run_vcs " + args.config + " " + args.testsuite + vcsargs + ElfFile + " " + flags diff --git a/sim/verilator/Makefile b/sim/verilator/Makefile index a7a57244e..04544a914 100644 --- a/sim/verilator/Makefile +++ b/sim/verilator/Makefile @@ -12,6 +12,8 @@ NONPROF?=--stats VERILATOR_DIR=${WALLY}/sim/verilator SOURCE=${WALLY}/config/shared/*.vh ${WALLY}/config/${WALLYCONF} ${WALLY}/config/deriv/${WALLYCONF} ${WALLY}/src/cvw.sv ${WALLY}/testbench/*.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv EXTRA_ARGS= +PLUS_ARGS:=$(filter pattern +%, $(EXTRA_ARGS)) +PARAM_ARGS:=$(filter-out pattern +%, $(EXTRA_ARGS)) WALLYCONF?=rv64gc @@ -44,7 +46,7 @@ default: run run: wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH} mkdir -p $(VERILATOR_DIR)/logs - wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH} ${ARGTEST} $(EXTRA_ARGS) + wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH} ${ARGTEST} $(PLUS_ARGS) profile: obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF) $(VERILATOR_DIR)/obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF) ${ARGTEST} @@ -65,6 +67,7 @@ wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH}: $(DEPENDENCIES) $(INCLUDE_PATH) \ ${WRAPPER} \ ${GTEST} \ + ${PARAM_ARGS} \ $(SOURCES) obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF): $(DEPENDENCIES) @@ -77,6 +80,7 @@ obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF): $(DEPENDENCIES) $(INCLUDE_PATH) \ ${WRAPPER} \ ${GTEST} \ + ${PARAM_ARGS} \ $(SOURCES) clean: