From 6f6b1fd1fd21dc74f80acac8fadd8705de8647d1 Mon Sep 17 00:00:00 2001 From: Kunlin Han Date: Tue, 16 Apr 2024 18:45:21 -0700 Subject: [PATCH 1/4] Add extra path to search for deriv/buildroot. --- sim/verilator/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sim/verilator/Makefile b/sim/verilator/Makefile index 4042326a8..f4a9ff8a8 100644 --- a/sim/verilator/Makefile +++ b/sim/verilator/Makefile @@ -5,7 +5,7 @@ PARAMS?=-DVERILATOR=1 --no-trace-top NONPROF?=--stats WORKING_DIR=${WALLY}/sim/verilator TARGET=$(WORKING_DIR)/target -SOURCE=${WALLY}/config/shared/*.vh ${WALLY}/config/${WALLYCONF} ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv +SOURCE=${WALLY}/config/shared/*.vh ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv WALLYCONF?=rv64gc TEST?=arch64i @@ -33,7 +33,7 @@ obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(SOURCE) -cc --binary \ $(OPT) $(PARAMS) $(NONPROF) \ --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ - "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" \ + "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" \ wrapper.c \ ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv @@ -44,8 +44,9 @@ obj_dir_profiling/Vtestbench_$(WALLYCONF): $(SOURCE) -cc --binary \ --prof-cfuncs $(OPT) $(PARAMS) \ --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ + "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" \ wrapper.c \ - "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv + ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv questa: time vsim -c -do "do ${WALLY}/sim/wally-batch.do $(WALLYCONF) $(TEST)" From 392eedb342d247f95fa39dce70e6657ca1db34f9 Mon Sep 17 00:00:00 2001 From: Kunlin Han Date: Tue, 16 Apr 2024 18:54:11 -0700 Subject: [PATCH 2/4] Update sim/verilator/Makefile with constants for simplicity. --- sim/verilator/Makefile | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/sim/verilator/Makefile b/sim/verilator/Makefile index f4a9ff8a8..28ec9b673 100644 --- a/sim/verilator/Makefile +++ b/sim/verilator/Makefile @@ -1,15 +1,20 @@ +SHELL := /bin/bash .PHONY: profile run questa clean +# verilator configurations OPT= PARAMS?=-DVERILATOR=1 --no-trace-top NONPROF?=--stats -WORKING_DIR=${WALLY}/sim/verilator -TARGET=$(WORKING_DIR)/target -SOURCE=${WALLY}/config/shared/*.vh ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv - WALLYCONF?=rv64gc TEST?=arch64i +# constants +WORKING_DIR=${WALLY}/sim/verilator +TARGET=$(WORKING_DIR)/target +DEPENDENCIES=${WALLY}/config/shared/*.vh ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv +INCLUDE_PATH="-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" +SOURCE_PATH=${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv + default: run profile: obj_dir_profiling/Vtestbench_$(WALLYCONF) @@ -26,27 +31,27 @@ run: obj_dir_non_profiling/Vtestbench_$(WALLYCONF) time $(WORKING_DIR)/obj_dir_non_profiling/Vtestbench_$(WALLYCONF) +TEST=$(TEST) 2>&1 > $(WORKING_DIR)/logs/$(WALLYCONF)_$(TEST).log echo "Please check $(WORKING_DIR)/logs/$(WALLYCONF)_$(TEST).log for logs and output files." -obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(SOURCE) +obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES) mkdir -p obj_dir_non_profiling time verilator \ --Mdir obj_dir_non_profiling -o Vtestbench_$(WALLYCONF) \ -cc --binary \ $(OPT) $(PARAMS) $(NONPROF) \ --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ - "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" \ + $(INCLUDE_PATH) \ wrapper.c \ - ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv + $(SOURCE_PATH) -obj_dir_profiling/Vtestbench_$(WALLYCONF): $(SOURCE) +obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES) mkdir -p obj_dir_profiling time verilator \ --Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \ -cc --binary \ --prof-cfuncs $(OPT) $(PARAMS) \ --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ - "-I${WALLY}/config/shared" "-I${WALLY}/config/$(WALLYCONF)" "-I${WALLY}/config/deriv/$(WALLYCONF)" \ + $(INCLUDE_PATH) \ wrapper.c \ - ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv + $(SOURCE_PATH) questa: time vsim -c -do "do ${WALLY}/sim/wally-batch.do $(WALLYCONF) $(TEST)" From 91a88fa46c09f946da574e6362d1977dd1f200d7 Mon Sep 17 00:00:00 2001 From: Kunlin Han Date: Wed, 17 Apr 2024 09:52:54 -0700 Subject: [PATCH 3/4] Update sim/verilator/Makefile with more comments and merging variables. --- sim/verilator/Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sim/verilator/Makefile b/sim/verilator/Makefile index 28ec9b673..e212d1d13 100644 --- a/sim/verilator/Makefile +++ b/sim/verilator/Makefile @@ -9,11 +9,15 @@ WALLYCONF?=rv64gc TEST?=arch64i # constants +# assume WALLY variable is correctly configured in the shell environment WORKING_DIR=${WALLY}/sim/verilator TARGET=$(WORKING_DIR)/target -DEPENDENCIES=${WALLY}/config/shared/*.vh ${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv +# 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)" -SOURCE_PATH=${WALLY}/src/cvw.sv ${WALLY}/testbench/testbench.sv ${WALLY}/testbench/common/*.sv ${WALLY}/src/*/*.sv ${WALLY}/src/*/*/*.sv +# SOURCES are source files +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) default: run @@ -40,7 +44,7 @@ obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES) --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ $(INCLUDE_PATH) \ wrapper.c \ - $(SOURCE_PATH) + $(SOURCES) obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES) mkdir -p obj_dir_profiling @@ -51,7 +55,7 @@ obj_dir_profiling/Vtestbench_$(WALLYCONF): $(DEPENDENCIES) --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \ $(INCLUDE_PATH) \ wrapper.c \ - $(SOURCE_PATH) + $(SOURCES) questa: time vsim -c -do "do ${WALLY}/sim/wally-batch.do $(WALLYCONF) $(TEST)" From 08dd2eac7475572d63cf048f87e0f4e3eb347718 Mon Sep 17 00:00:00 2001 From: Kunlin Han Date: Wed, 17 Apr 2024 23:26:09 -0700 Subject: [PATCH 4/4] Add getenvval for rom. Related to issue #723. --- src/generic/mem/rom1p1r.sv | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/generic/mem/rom1p1r.sv b/src/generic/mem/rom1p1r.sv index 7350eac9c..7a53c529e 100644 --- a/src/generic/mem/rom1p1r.sv +++ b/src/generic/mem/rom1p1r.sv @@ -48,7 +48,11 @@ module rom1p1r #(parameter ADDR_WIDTH = 8, DATA_WIDTH = 32, PRELOAD_ENABLED = 0) initial begin if (PRELOAD_ENABLED) begin +`ifdef VERILATOR + $readmemh({getenvval("WALLY"), "/fpga/src/boot.mem"}, ROM, 0); +`else $readmemh("$WALLY/fpga/src/boot.mem", ROM, 0); +`endif end end