Fixed wsim to be able to invoke TestFloat with Verilator. However, TestFloat produces incorrect results with Verilator

This commit is contained in:
David Harris 2024-05-09 18:56:59 -07:00
parent a89e064d1d
commit 61e559606e
2 changed files with 30 additions and 19 deletions

View File

@ -54,10 +54,7 @@ for d in ["logs", "wkdir", "cov"]:
cd = "cd $WALLY/sim/" +args.sim
if (args.sim == "questa"):
if (args.tb == "testbench_fp"):
args.args = " -GTEST=" + args.testsuite + " " + args.args
# cmd = "do wally.do " + args.config + " " + args.testsuite + " " + args.tb + " " + " -GTEST=" + args.testsuite + " " + args.args
# else:
# cmd = "do wally.do " + args.config + " " + args.testsuite + " " + args.tb + " " + args.args
args.args = " -GTEST=\"" + args.testsuite + "\" " + args.args
cmd = "do wally.do " + args.config + " " + args.testsuite + " " + args.tb + " " + args.args
if (args.coverage):
cmd += " -coverage"
@ -76,7 +73,7 @@ elif (args.sim == "verilator"):
if (args.gui):
print("GUI option not available for Verilator")
exit(1)
os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} 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):

View File

@ -16,6 +16,7 @@ EXTRA_ARGS=
WALLYCONF?=rv64gc
TEST?=arch64i
TESTBENCH?=testbench
# constants
# assume WALLY variable is correctly configured in the shell environment
@ -24,47 +25,60 @@ TARGET=$(WORKING_DIR)/target
# INCLUDE_PATH are pathes that Verilator should search for files it needs
INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)"
# SOURCES are source files
SOURCES=${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv
SOURCES=${WALLY}/src/cvw.sv ${WALLY}/testbench/${TESTBENCH}.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv
# DEPENDENCIES are configuration files and source files, which leads to recompilation of executables
DEPENDENCIES=${WALLY}/config/shared/*.vh $(SOURCES)
# regular testbench requires a wrapper defining getenvval
ifeq ($(TESTBENCH), testbench)
WRAPPER=${WALLY}/sim/verilator/wrapper.c
GTEST=
ARGTEST=+TEST=$(TEST)
else
WRAPPER=
GTEST=-GTEST="\"${TEST}\""
ARGTEST=
endif
default: run
run: wkdir/$(WALLYCONF)_$(TEST)/Vtestbench
run: wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH}
mkdir -p $(VERILATOR_DIR)/logs
wkdir/$(WALLYCONF)_$(TEST)/Vtestbench +TEST=$(TEST)
wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH} ${ARGTEST}
profile: obj_dir_profiling/Vtestbench_$(WALLYCONF)
$(VERILATOR_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) +TEST=$(TEST)
profile: obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF)
$(VERILATOR_DIR)/obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF) ${ARGTEST}
mv gmon.out gmon_$(WALLYCONF).out
gprof $(VERILATOR_DIR)/obj_dir_profiling/Vtestbench_$(WALLYCONF) gmon_$(WALLYCONF).out > gmon_$(WALLYCONF).log
gprof $(VERILATOR_DIR)/obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF) gmon_$(WALLYCONF).out > gmon_$(WALLYCONF).log
verilator_profcfunc gmon_$(WALLYCONF).log > gmon_$(WALLYCONF).log2
mkdir -p $(VERILATOR_DIR)/logs_profiling
mv gmon_$(WALLYCONF)* $(VERILATOR_DIR)/logs_profiling
echo "Please check $(VERILATOR_DIR)/logs_profiling/gmon_$(WALLYCONF)* for logs and output files."
wkdir/$(WALLYCONF)_$(TEST)/Vtestbench: $(DEPENDENCIES)
wkdir/$(WALLYCONF)_$(TEST)/V${TESTBENCH}: $(DEPENDENCIES)
mkdir -p wkdir/$(WALLYCONF)_$(TEST)
verilator \
--Mdir wkdir/$(WALLYCONF)_$(TEST) -o Vtestbench \
--Mdir wkdir/$(WALLYCONF)_$(TEST) -o V${TESTBENCH} \
--binary --trace \
$(OPT) $(PARAMS) $(NONPROF) \
$(EXTRA_ARGS) \
--top-module testbench --relative-includes \
--top-module ${TESTBENCH} --relative-includes \
$(INCLUDE_PATH) \
${WALLY}/sim/verilator/wrapper.c \
${WRAPPER} \
${GTEST} \
$(SOURCES)
obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES)
obj_dir_profiling/V${TESTBENCH}_$(WALLYCONF): $(DEPENDENCIES)
mkdir -p obj_dir_profiling
verilator \
--Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \
--Mdir obj_dir_profiling -o V${TESTBENCH}_$(WALLYCONF) \
--binary \
--prof-cfuncs $(OPT) $(PARAMS) \
$(EXTRA_ARGS) \
--top-module testbench --relative-includes \
--top-module ${TESTBENCH} --relative-includes \
$(INCLUDE_PATH) \
${WALLY}/sim/verilator/wrapper.c \
${WRAPPER} \
${GTEST} \
$(SOURCES)
clean: