Skip to content

Commit 0a6e236

Browse files
Merge pull request #2607 from MikeOpenHWGroup/cv32e40p/dev_restore_verilator
Restore verilator to CV32E40P core testbench
2 parents 33917ee + ee41469 commit 0a6e236

File tree

7 files changed

+45
-74
lines changed

7 files changed

+45
-74
lines changed

cv32e40p/sim/core/Makefile

+18-9
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ SIMV = ./simv
134134
# dsim is the Metrics Technologies SystemVerilog simulator (https://metrics.ca/)
135135
DSIM = dsim
136136
DSIM_HOME = /tools/Metrics/dsim
137-
DSIM_CMP_FLAGS = +define+CORE_TB -timescale 1ns/1ps $(SV_CMP_FLAGS) -suppress MultiBlockWrite +define+CV32E40P_APU_TRACE
137+
DSIM_CMP_FLAGS = +define+CORE_TB +define+CV32E40P_APU_TRACE +acc+b -timescale 1ns/1ps $(SV_CMP_FLAGS)
138+
DSIM_SUPPRESS = -suppress MultiBlockWrite -suppress IneffectiveDynamicCast
138139
DSIM_RUN_FLAGS =
139140
DSIM_UVM_ARGS = +incdir+$(UVM_HOME)/src $(UVM_HOME)/src/uvm_pkg.sv
140141
DSIM_RESULTS ?= $(PWD)/dsim_results
141142
DSIM_WORK ?= $(DSIM_RESULTS)/dsim_work
142143
DSIM_IMAGE = dsim.out
143144

144145
ifneq (${WAVES}, 0)
145-
DSIM_CMP_FLAGS += +acc
146146
DSIM_DMP_FILE ?= dsim.fst
147147
DSIM_RUN_FLAGS += -waves $(DSIM_DMP_FILE)
148148
endif
@@ -155,7 +155,8 @@ XRUN_DIR = xcelium.d
155155
# verilator configuration
156156
VERILATOR = verilator
157157
VERI_FLAGS +=
158-
VERI_COMPILE_FLAGS += -Wno-BLKANDNBLK $(SV_CMP_FLAGS) # hope this doesn't hurt us in the long run
158+
VERI_COMPILE_FLAGS += $(SV_CMP_FLAGS)
159+
VERI_WARN_WAIVERS ?= --Wno-lint --Wno-UNOPTFLAT --Wno-MODDUP --Wno-MULTIDRIVEN --Wno-COMBDLY --Wno-BLKANDNBLK
159160
VERI_TRACE ?=
160161
VERI_OBJ_DIR ?= cobj_dir
161162
#VERI_LOG_DIR ?= cobj_dir/logs
@@ -185,7 +186,7 @@ TBSRC_TOP := $(TBSRC_HOME)/core/tb_top.sv
185186
TBSRC_CORE := $(TBSRC_HOME)/core
186187
TBSRC_PKG := $(TBSRC_CORE)/tb_riscv/include/perturbation_defines.sv
187188
TBSRC := $(TBSRC_CORE)/tb_top.sv \
188-
$(TBSRC_CORE)/cv32e40p_tb_wrapper.sv \
189+
$(TBSRC_CORE)/cv32e40p_core_tb_wrapper.sv \
189190
$(TBSRC_CORE)/mm_ram.sv \
190191
$(TBSRC_CORE)/dp_ram.sv \
191192
$(TBSRC_CORE)/tb_riscv/riscv_random_stall.sv \
@@ -199,7 +200,7 @@ RTLSRC_VLOG_TB_TOP := $(basename $(notdir $(TBSRC_TOP)))
199200
RTLSRC_VOPT_TB_TOP := $(addsuffix _vopt, $(RTLSRC_VLOG_TB_TOP))
200201

201202
TBSRC_VERI := $(TBSRC_CORE)/tb_top_verilator.sv \
202-
$(TBSRC_CORE)/cv32e40p_tb_wrapper.sv \
203+
$(TBSRC_CORE)/cv32e40p_core_tb_wrapper.sv \
203204
$(TBSRC_CORE)/tb_riscv/riscv_rvalid_stall.sv \
204205
$(TBSRC_CORE)/tb_riscv/riscv_gnt_stall.sv \
205206
$(TBSRC_CORE)/mm_ram.sv \
@@ -276,9 +277,13 @@ mk_results:
276277

277278
# Metrics dsim compile targets
278279
dsim-comp: mk_results CV_CORE_pkg tbsrc_pkg tbsrc
280+
@echo "$(BANNER)"
281+
@echo "* Compiling with Metrics DSIM"
282+
@echo "$(BANNER)"
279283
cd $(DSIM_RESULTS) && \
280284
$(DSIM) \
281285
$(DSIM_CMP_FLAGS) \
286+
$(DSIM_SUPPRESS) \
282287
$(DSIM_UVM_ARGS) \
283288
-f $(CV_CORE_MANIFEST) \
284289
$(TBSRC_PKG) \
@@ -287,8 +292,12 @@ dsim-comp: mk_results CV_CORE_pkg tbsrc_pkg tbsrc
287292
-genimage $(DSIM_IMAGE)
288293

289294
dsim-comp-rtl-only: mk_results $(CV_CORE_PKG)
295+
@echo "$(BANNER)"
296+
@echo "* Compiling (only) with Metrics DSIM"
297+
@echo "$(BANNER)"
290298
$(DSIM) \
291299
$(DSIM_CMP_FLAGS) \
300+
$(DSIM_SUPPRESS) \
292301
-f $(CV_CORE_MANIFEST) \
293302
-work $(DSIM_WORK) \
294303
-genimage $(DSIM_IMAGE)
@@ -313,7 +322,7 @@ dsim-test: dsim-comp $(TEST_PROGRAM_PATH)/$(TEST)/$(TEST).hex
313322
-work $(DSIM_WORK) \
314323
$(DSIM_RUN_FLAGS) \
315324
-sv_lib $(UVM_HOME)/src/dpi/libuvm_dpi.so \
316-
+firmware=$(VERI_CUSTOM)/$(TEST)/$(TEST).hex
325+
+firmware=../../$(TEST_PROGRAM_RELPATH)/$(TEST)/$(TEST).hex
317326

318327
# Metrics dsim cleanup
319328
.PHONY: dsim-clean
@@ -490,13 +499,13 @@ testbench_verilator: CV_CORE_pkg $(TBSRC_VERI) $(TBSRC_PKG)
490499
@echo "$(BANNER)"
491500
$(VERILATOR) --cc --sv --exe \
492501
$(VERI_TRACE) \
493-
--Wno-lint --Wno-UNOPTFLAT \
494-
--Wno-MODDUP --top-module \
502+
$(VERI_WARN_WAIVERS) \
503+
--top-module \
495504
tb_top_verilator $(TBSRC_VERI) \
496505
-f $(CV_CORE_MANIFEST) \
497506
$(CV_CORE_PKG)/bhv/$(CV_CORE_LC)_core_log.sv \
498507
$(TBSRC_CORE)/tb_top_verilator.cpp --Mdir $(VERI_OBJ_DIR) \
499-
-CFLAGS "-std=gnu++11 $(VERI_CFLAGS)" \
508+
-CFLAGS "$(VERI_CFLAGS)" \
500509
$(VERI_COMPILE_FLAGS)
501510
$(MAKE) -C $(VERI_OBJ_DIR) -f Vtb_top_verilator.mk
502511
mkdir -p $(SIM_RESULTS)

cv32e40p/sim/core/README.md

+10-31
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,27 @@ To run the core testbench you will need a SystemVerilog simulator and RISC-V GCC
88

99
Supported SystemVerilog Simulators
1010
----------------------------------
11-
The core testbench and associated test-programs can be run using **_Verilator_**, the Metrics
12-
**_dsim_**, Mentor's **_Questa_**, Cadence **_Xcelium_**, Synopsys **_vcs_** and Aldec **_Riviera-PRO_**
13-
simulators. Note that **_Icarus_** verilog cannot compile the RTL and there are no plans
14-
to support Icarus in the future.
11+
The core testbench and associated test-programs can be run using **_Verilator_**, Metrics
12+
**_DSim_**, Siemens **_Questasim_**, Cadence **_Xcelium_**, Synopsys **_vcs_** and Aldec **_Riviera-PRO_** simulators.
13+
Note:
14+
- The following has been recently tested with both Verilator and DSim, but it has been some time since other simulators have been used. Bit-rot may have set in.
15+
- **_Icarus_** verilog cannot compile the RTL and there are no plans to support Icarus in the future.
1516

1617
RISC-V GCC Compiler "Toolchain"
1718
-------------------------------
1819
Pointers to the recommended toolchain for CV32E40P are in `../TOOLCHAIN`.
1920

20-
Running your own C programs
21-
---------------------
22-
A hello world program is available and you can run it in the CV32E40P Core testbench.
23-
Invoke the `dsim-hello_world` or `hello-world-veri-run` makefile rules to run it with
24-
`dsim` or `verilator` respectively.
25-
26-
The hello world program is located in the `custom` folder. The relevant sections
27-
in the Makefile on how to compile and link this program can be found under `Running
28-
custom programs`. Make sure you have a working C compiler (see above) and keep in
29-
mind that you are running on a very basic machine.
30-
3121
Running the testbench with [verilator](https://www.veripool.org/wiki/verilator)
3222
----------------------
33-
Point your environment variable `RISCV` to your RISC-V toolchain. Call `make`
34-
to run the default test (hello_world).
23+
Point your environment variable `RISCV` to your RISC-V toolchain.
24+
Call `make` to run the default test with Verilator.
3525

36-
Running your own Assembler programs
26+
Running your own C and/or RISC-V Assembler programs
3727
-----------------------------
3828
If you have a C or assembly program in `../../tests/programs/custom`
3929
then the following will work with Verilator:<br>
4030
```
31+
make veri-test TEST=hello-world
4132
make veri-test TEST=dhrystone
4233
make veri-test TEST=misalign
4334
make veri-test TEST=fibonacci
@@ -51,6 +42,7 @@ Point your environment variable `RISCV` to your RISC-V toolchain. Call
5142
`make dsim-sanity` to build and run the testbench with the hello_world
5243
test in the custom directory. Other test targets of interest:<br>
5344
```
45+
make dsim-test TEST=hello-world
5446
make dsim-test TEST=dhrystone
5547
make dsim-test TEST=misalign
5648
make dsim-test TEST=fibonacci
@@ -124,16 +116,3 @@ riviera-hello-world` to build the testbench and the firmware, and run it. Use
124116
`ASIM_FLAGS` to configure the simulator e.g. `make custom-asim-run
125117
ASIM_FLAGS="-gui"`.
126118

127-
Options
128-
-------
129-
A few plusarg options are supported:
130-
* `+verbose` to show all memory read and writes and other miscellaneous information.
131-
132-
* `+vcd` to produce a vcd file called `riscy_tb.vcd`. Verilator always produces
133-
a vcd file called `verilator_tb.vcd`.
134-
135-
Examples
136-
--------
137-
Run all riscv_tests to completion with **dsim**:
138-
`make dsim-cv32_riscv_tests`
139-

cv32e40p/tb/README.md

+7-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
## CV32/TB: testbenches for the CV32E40P CORE-V family of RISC-V cores.
2-
Derived from the
3-
[tb](https://github.com/pulp-platform/riscv/tree/master/tb)
4-
directory of the PULP-Platform RI5CY project. There are two distinct
5-
testbenches:
1+
## Testbenches for the CV32E40P CORE-V family of RISC-V cores.
2+
There are two distinct testbenches here.
63

74
### core
8-
Modified to remove a few RTL files (placed these in the rtl directory). This
9-
testbench supports Verilator and we will do what we can to maintain Verilator
10-
support here. Note that `tb_riscv` is now a sub-directory of `core`.
5+
A very simple testbench that can be run with Verilator and any commercial SystemVerilog simulator.
6+
This is not a production testbench - it is here to provide a simple example.
117

128
### uvmt
13-
The testbench and testharness for the CV32E40P UVM verification
14-
environments. This tb/th maintains support for all features of the `core`
15-
testbench. This testbench must be run with a SystemVerilog 1800-compliant simulator,
16-
i.e. it cannot be run with Verilator.
17-
18-
## Retired Testbenches
19-
A set of directories inherited from the RI5CY project have fallen into disuse
20-
and were deleted. Since nothing is ever gone in GitHub, if you _must_ have
21-
this content, it is available in any hash of this repo older than
22-
11ffa1577abfff2f7dce8afed6047b0c86ad335c. The deleted directories are:
23-
24-
* dm
25-
* scripts
26-
* serDiv
27-
* tb_MPU
28-
* verilator-model
9+
The testbench for the CV32E40P UVM verification environment.
10+
This is the production environment used to verify the CV32E40P.
11+
This testbench must be run with a SystemVerilog 1800-compliant simulator.

cv32e40p/tb/core/cv32e40p_tb_wrapper.sv cv32e40p/tb/core/cv32e40p_core_tb_wrapper.sv

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//
1616
// SPDX-License-Identifier: Apache-2.0 WITH SHL-0.51
1717

18-
module cv32e40p_tb_wrapper
18+
module cv32e40p_core_tb_wrapper
1919
#(parameter // Parameters used by TB
2020
INSTR_RDATA_WIDTH = 32,
2121
RAM_ADDR_WIDTH = 20,
@@ -179,4 +179,4 @@ module cv32e40p_tb_wrapper
179179
.exit_valid_o ( exit_valid_o ),
180180
.exit_value_o ( exit_value_o ));
181181

182-
endmodule // cv32e40p_tb_wrapper
182+
endmodule // cv32e40p_core_tb_wrapper

cv32e40p/tb/core/tb_top.sv

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module tb_top
7070
if($test$plusargs("verbose"))
7171
$display("[TESTBENCH] @ t=%0t: loading firmware %0s",
7272
$time, firmware);
73-
$readmemh(firmware, cv32e40p_tb_wrapper_i.ram_i.dp_ram_i.mem);
73+
$readmemh(firmware, cv32e40p_core_tb_wrapper_i.ram_i.dp_ram_i.mem);
7474
end else begin
7575
$display("No firmware specified");
7676
$finish;
@@ -145,13 +145,13 @@ module tb_top
145145
end
146146

147147
// wrapper for CV32E40P, the memory system and stdout peripheral
148-
cv32e40p_tb_wrapper
148+
cv32e40p_core_tb_wrapper
149149
#(
150150
.INSTR_RDATA_WIDTH (INSTR_RDATA_WIDTH),
151151
.RAM_ADDR_WIDTH (RAM_ADDR_WIDTH),
152152
.BOOT_ADDR (BOOT_ADDR)
153153
)
154-
cv32e40p_tb_wrapper_i
154+
cv32e40p_core_tb_wrapper_i
155155
(
156156
.clk_i ( core_clk ),
157157
.rst_ni ( core_rst_n ),

cv32e40p/tb/core/tb_top_verilator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int main(int argc, char **argv, char **env)
3939
top = new Vtb_top_verilator();
4040

4141
svSetScope(svGetScopeFromName(
42-
"TOP.tb_top_verilator.cv32e40p_tb_wrapper_i.ram_i.dp_ram_i"));
42+
"TOP.tb_top_verilator.cv32e40p_core_tb_wrapper_i.ram_i.dp_ram_i"));
4343
Verilated::scopesDump();
4444

4545
#ifdef VCD_TRACE
@@ -56,7 +56,7 @@ int main(int argc, char **argv, char **env)
5656

5757
#ifdef MCY
5858
svSetScope(svGetScopeFromName(
59-
"TOP.tb_top_verilator.cv32e40p_tb_wrapper_i.riscv_core_i.ex_stage_i.alu_i.int_div.div_i"));
59+
"TOP.tb_top_verilator.cv32e40p_core_tb_wrapper_i.riscv_core_i.ex_stage_i.alu_i.int_div.div_i"));
6060
svLogicVecVal idx = {0};
6161
idx.aval = mutidx;
6262
set_mutidx(&idx);

cv32e40p/tb/core/tb_top_verilator.sv

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module tb_top_verilator
3939
if($test$plusargs("verbose"))
4040
$display("[TESTBENCH] %t: loading firmware %0s ...",
4141
$time, firmware);
42-
$readmemh(firmware, cv32e40p_tb_wrapper_i.ram_i.dp_ram_i.mem);
42+
$readmemh(firmware, cv32e40p_core_tb_wrapper_i.ram_i.dp_ram_i.mem);
4343

4444
end else begin
4545
$display("No firmware specified");
@@ -85,7 +85,7 @@ module tb_top_verilator
8585
end
8686

8787
// wrapper for cv32e40p, the memory system and stdout peripheral
88-
cv32e40p_tb_wrapper
88+
cv32e40p_core_tb_wrapper
8989
#(.INSTR_RDATA_WIDTH (INSTR_RDATA_WIDTH),
9090
.RAM_ADDR_WIDTH (RAM_ADDR_WIDTH),
9191
.BOOT_ADDR (BOOT_ADDR),
@@ -94,7 +94,7 @@ module tb_top_verilator
9494
.ZFINX (0),
9595
.DM_HALTADDRESS (32'h1A110800)
9696
)
97-
cv32e40p_tb_wrapper_i
97+
cv32e40p_core_tb_wrapper_i
9898
(.clk_i ( clk_i ),
9999
.rst_ni ( rst_ni ),
100100
.fetch_enable_i ( fetch_enable_i ),

0 commit comments

Comments
 (0)