Merge branch 'verilator_getenv' into wsim_verilator

This commit is contained in:
Kunlin Han 2024-04-12 15:27:09 -07:00
commit 7b5972ea82
3 changed files with 22 additions and 2 deletions

View File

@ -30,17 +30,21 @@ obj_dir_non_profiling/Vtestbench_$(WALLYCONF): $(SOURCE)
mkdir -p obj_dir_non_profiling mkdir -p obj_dir_non_profiling
time verilator \ time verilator \
--Mdir obj_dir_non_profiling -o Vtestbench_$(WALLYCONF) \ --Mdir obj_dir_non_profiling -o Vtestbench_$(WALLYCONF) \
-cc --binary \
$(OPT) $(PARAMS) $(NONPROF) \ $(OPT) $(PARAMS) $(NONPROF) \
--timescale "1ns/1ns" --timing --binary --top-module testbench --relative-includes \ --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)" \
wrapper.c \
${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
obj_dir_profiling/Vtestbench_$(WALLYCONF): $(SOURCE) obj_dir_profiling/Vtestbench_$(WALLYCONF): $(SOURCE)
mkdir -p obj_dir_profiling mkdir -p obj_dir_profiling
time verilator \ time verilator \
--Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \ --Mdir obj_dir_profiling -o Vtestbench_$(WALLYCONF) \
-cc --binary \
--prof-cfuncs $(OPT) $(PARAMS) \ --prof-cfuncs $(OPT) $(PARAMS) \
--timescale "1ns/1ns" --timing --binary --top-module testbench --relative-includes \ --timescale "1ns/1ns" --timing --top-module testbench --relative-includes \
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 "-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
questa: questa:

7
sim/verilator/wrapper.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdlib.h>
#include "Vtestbench__Dpi.h"
const char *getenvval(const char *pszName) {
return ((const char *) getenv(pszName));
}

View File

@ -34,7 +34,11 @@
`endif `endif
import cvw::*; import cvw::*;
`ifdef VERILATOR
import "DPI-C" function string getenvval(input string env_name);
`else
import "DPI-C" function string getenv(input string env_name); import "DPI-C" function string getenv(input string env_name);
`endif
module testbench; module testbench;
/* verilator lint_off WIDTHTRUNC */ /* verilator lint_off WIDTHTRUNC */
@ -60,7 +64,12 @@ module testbench;
// Variables that can be overwritten with $value$plusargs at start of simulation // Variables that can be overwritten with $value$plusargs at start of simulation
string TEST; string TEST;
integer INSTR_LIMIT; integer INSTR_LIMIT;
`ifdef VERILATOR
string RISCV_DIR = getenvval("RISCV"); // "/opt/riscv";
`else
string RISCV_DIR = getenv("RISCV"); // "/opt/riscv"; string RISCV_DIR = getenv("RISCV"); // "/opt/riscv";
`endif
// string RISCV_DIR = "/opt/riscv";
// DUT signals // DUT signals
logic [P.AHBW-1:0] HRDATAEXT; logic [P.AHBW-1:0] HRDATAEXT;