Skip to content

Commit 2fe3686

Browse files
committed
More functional coverage refactoring
1 parent 98ef851 commit 2fe3686

File tree

7 files changed

+32
-16
lines changed

7 files changed

+32
-16
lines changed

bin/regression-wally

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def addTestsByDir(testDir, config, sim, coverStr, configs, lockstepMode=0, breke
320320
# fcov/ccov only runs on WALLY-COV-ALL.elf files; other lockstep runs on all files
321321
fileEnd = "ALL.elf" if "cvw-arch-verif/tests" in testDir and "priv" not in testDir and (coverStr == "--fcov" or coverStr == "--ccov") else ".elf"
322322
if lockstepMode or coverStr == "--fcov":
323-
gs = "Mismatches : 0"
323+
gs = "** Note: $finish"
324324
elif brekerMode:
325325
gs="# trek: info: summary: Test PASSED"
326326
else:

bin/wsim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,11 @@ def prepSim(args, ElfFile):
101101
flagsList.append("--ccov")
102102
if args.fcov:
103103
flagsList.append("--fcov")
104-
defineList.extend(["+define+ENABLE_RVVI_TRACE", "+define+INCLUDE_TRACE2COV", "+define+IDV_INCLUDE_TRACE2COV", "+define+COVER_BASE_RV32I"]) # COVER_BASE_RV32I is just needed to keep riscvISACOV happy, but does not affect tests
105-
argsList.extend(["+TRACE2COV_ENABLE=1", "+IDV_TRACE2COV=1"])
104+
defineList.extend(["+define+ENABLE_RVVI_TRACE", "+define+FCOV"])
106105
if args.gui:
107106
flagsList.append("--gui")
108107
if args.lockstep or args.lockstepverbose:
109108
flagsList.append("--lockstep")
110-
if args.lockstep or args.lockstepverbose:
111109
prefix = lockstepSetup(args)
112110
defineList.extend(["+define+USE_IMPERAS_DV", "+define+ENABLE_RVVI_TRACE"])
113111
if args.config == "breker": # Requires a license for the breker tool. See tests/breker/README.md for details

sim/imperas-verbose.ic

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Add Imperas simulator application instruction tracing
2-
--verbose --trace --tracechange --traceshowicount --tracemode -tracemem ASX --monitornetschange # --traceafter 300000000
2+
--verbose --trace --tracechange --traceshowicount --tracemode --tracemem XSL --monitornetschange # --traceafter 300000000
33
--override cpu/debugflags=6 --override cpu/verbose=1
4-
--override cpu/show_c_prefix=T

sim/questa/wally.do

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,11 @@ if {[lcheck lst "--ccov"]} {
113113
if {[lcheck lst "--fcov"]} {
114114
set IMPERAS_HOME $::env(IMPERAS_HOME)
115115
set FunctCoverage 1
116-
# ImpProprietary is needed for trace2cov for now
117116
set FCvlog "+incdir+${FCRVVI}/unpriv \
118117
+incdir+${FCRVVI}/priv +incdir+${FCRVVI}/rv64_priv +incdir+${FCRVVI}/rv32_priv \
119118
+incdir+${FCRVVI}/common +incdir+${FCRVVI} \
120119
+incdir+$env(WALLY)/addins/cvw-arch-verif/riscvISACOV/source \
121-
+incdir+${IMPERAS_HOME}/ImpPublic/include/host \
122-
+incdir+${IMPERAS_HOME}/ImpProprietary/include/host \
123-
${IMPERAS_HOME}/ImpPublic/source/host/rvvi/*.sv \
124-
${IMPERAS_HOME}/ImpProprietary/source/host/idv/*.sv"
125-
set SVLib " -sv_lib ${IMPERAS_HOME}/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model "
120+
${FCRVVI}/*.sv"
126121
}
127122

128123
# if --lockstep found set flag and remove from list
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// trace2riscvISACOV.sv
2+
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
3+
4+
`include "RISCV_coverage.svh"
5+
6+
module trace2riscvISACOV(rvviTrace rvvi);
7+
// Connect coverage class to RVVI trace interface
8+
coverage #(rvvi.ILEN, rvvi.XLEN, rvvi.FLEN, rvvi.VLEN, rvvi.NHART, rvvi.RETIRE) riscvISACOV;
9+
initial begin
10+
riscvISACOV = new(rvvi);
11+
$display("trace2riscvISACOV: coverage initialized");
12+
end
13+
14+
// Dissassemble instruction from RVVI trace for processing by coverage model
15+
string disass;
16+
dissassembler #(rvvi.XLEN) dissassembler(rvvi.insn[0][0], disass);
17+
18+
// Invoke the riscvISACOV sample function on each clock edge for the current Instruction
19+
// If RVVI accepts more than one instruction or hart, iterate over all of them in the
20+
// correct order of retirement (TODO: multiple instructions/harts not implemented)
21+
always_ff @(posedge rvvi.clk) begin
22+
riscvISACOV.sample(rvvi.trap[0][0], 0, 0, {$sformatf("%h ", rvvi.insn[0][0]), disass});
23+
$display("trace2riscvISACOV: sample taken for instruction %h: %s", rvvi.insn[0][0], disass);
24+
end
25+
endmodule

testbench/common/wallyTracer.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,7 @@ module wallyTracer import cvw::*; #(parameter cvw_t P) (rvviTrace rvvi);
742742
end
743743

744744
always_ff @(posedge clk) begin
745+
$display("wallyTracer: %b", rvvi.insn[0][0]);
745746
if(valid) begin
746747
if(`STD_LOG) begin
747748
$fwrite(file, "%016x, %08x, %s\t\t", rvvi.pc_rdata[0][0], rvvi.insn[0][0], instrWName);

testbench/testbench.sv

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ end
738738
`endif
739739

740740
// Functional coverage
741-
`ifdef INCLUDE_TRACE2COV
742-
trace2cov idv_trace2cov(rvvi); // needed for fcov as of now
741+
`ifdef FCOV
742+
trace2riscvISACOV trace2riscvISACOV(rvvi);
743743
`endif
744744

745745
////////////////////////////////////////////////////////////////////////////////
@@ -756,8 +756,6 @@ end
756756
.CMP_CSR (1)
757757
) idv_trace2api(rvvi);
758758

759-
// trace2log idv_trace2log(rvvi); // currently not used
760-
761759
string filename;
762760
initial begin
763761
// imperasDV requires the elffile be defined at the begining of the simulation.

0 commit comments

Comments
 (0)