From 7ca1c976c04563a19ec97ce8e21326ade596f023 Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 10:33:29 -0700 Subject: [PATCH 1/7] initial commit pmp basic coverage working --- bin/wsim | 12 +-- sim/questa/wally.do | 2 +- sim/vcs/run_vcs | 27 ++++-- testbench/coverage/test_pmp_coverage.sv | 108 ++++++++++++++++++++++++ 4 files changed, 137 insertions(+), 12 deletions(-) create mode 100644 testbench/coverage/test_pmp_coverage.sv diff --git a/bin/wsim b/bin/wsim index a10ea6158..a85b7e304 100755 --- a/bin/wsim +++ b/bin/wsim @@ -29,8 +29,8 @@ print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim # Validate arguments if (args.gui): - if (args.sim != "questa"): - print("GUI option only supported for Questa") + if args.sim not in ["questa", "vcs"]: + print("GUI option only supported for Questa and VCS") exit(1) if (args.coverage): @@ -82,9 +82,9 @@ elif (args.sim == "vcs"): if (args.coverage): print("Coverage option not available for VCS") exit(1) - if (args.gui): - print("GUI option not available for VCS") - exit(1) + if (args.gui): + cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.tb + " " + "1" + os.system(cmd) cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" print(cmd) - os.system(cmd) \ No newline at end of file + os.system(cmd) diff --git a/sim/questa/wally.do b/sim/questa/wally.do index 33832516b..062cf5fe0 100644 --- a/sim/questa/wally.do +++ b/sim/questa/wally.do @@ -97,7 +97,7 @@ if {$argc >= 3} { # "Extra checking for conflicts with always_comb done at vopt time" # because vsim will run vopt -vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} +incdir+${CONFIG}/shared ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv -suppress 2583 -suppress 7063,2596,13286 +vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} +incdir+${CONFIG}/shared ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv ${TB}/coverage/test_pmp_coverage.sv -suppress 2583 -suppress 7063,2596,13286 # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals diff --git a/sim/vcs/run_vcs b/sim/vcs/run_vcs index 27ffff8f0..ca5b10986 100755 --- a/sim/vcs/run_vcs +++ b/sim/vcs/run_vcs @@ -12,7 +12,26 @@ TB=${WALLY}/testbench CONFIG_VARIANT=${1} # Set TESTSUITE from the second script argument TESTSUITE=$2 +WKDIR=wkdir/${1}_${2} +if [ ! -d "$WKDIR" ]; then + #echo "Directory $WKDIR does not exist. Creating it now..." + mkdir -p "$WKDIR" + if [ $? -eq 0 ]; then + echo "Directory $WKDIR created successfully." + else + echo "Failed to create directory $WKDIR." + exit 1 + fi +else + echo "Directory $WKDIR already exists." +fi + +if [[ -n "$4" ]]; then + GUI="-gui" +else + GUI="" +fi INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ") SOURCE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +define+ +define+P.XLEN=64 +define+FPGA=0 +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}" @@ -21,14 +40,12 @@ SIMFILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clock OUTPUT="sim_out" clean() { - rm -rf obj_dir work transcript vsim.wlf $OUTPUT *.vcd csrc ucli.key vc_hdrs.h program.out - rm -rf simv* *.daidir dve *.vpd *.dump DVEfiles/ verdi* novas* *fsdb* *.vg *.rep *.db *.chk *.log *.out profileReport* simprofile_dir* + rm -rf ${WKDIR}/* } # Clean and run simulation with VCS clean #vcs +lint=all,noGCWM -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse -v2k_generate ${SOURCE_PATH} +define+TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV # lint ignores Unused Inputs (UI), Unnamed Assertipons (SVA-UA), Dynamic Type Sensitivty [IDTS], Null Statement [NS], Unequal Length in Comparison Operation [ULCO] -vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} -pvalue+testbench.TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV -./$OUTPUT | tee program.out - +vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -suppress -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} $SIMFILES -o ${WKDIR}/$OUTPUT -simdir ${WKDIR} -error=NOODV -work ${WKDIR} ${GUI} +./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} +fsdb+gate=off | tee ${WKDIR}/${WKDIR}.out diff --git a/testbench/coverage/test_pmp_coverage.sv b/testbench/coverage/test_pmp_coverage.sv new file mode 100644 index 000000000..2c1cbbfaa --- /dev/null +++ b/testbench/coverage/test_pmp_coverage.sv @@ -0,0 +1,108 @@ +module test_pmp_coverage import cvw::*; #(parameter cvw_t P) (input clk); + +// Ensure the covergroup is defined correctly +covergroup cg_priv_mode @(posedge clk); + coverpoint dut.core.ifu.PrivilegeModeW { + bins user = {2'b00}; + bins superv = {2'b01}; + bins hyperv = {2'b10}; + bins mach = {2'b11}; + } +endgroup + +covergroup cg_PMPConfig @(posedge clk); + coverpoint dut.core.ifu.PMPCFG_ARRAY_REGW[0][0] { + bins ones = {1}; + bins zeros = {0}; + } +endgroup + + +function bit [1:0] getPMPConfigSlice(int index); + return dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[index][4:3]; +endfunction + +//if (P.PMP_ENTRIES > 0) begin : pmp + covergroup cg_pmpcfg_mode @(posedge clk); + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[0][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[1][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[2][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[3][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[4][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[5][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[6][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[7][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + endgroup +//end + + +// Ensure that the instantiation and sampling of covergroups are within the correct procedural context +initial begin + cg_priv_mode privmodeCG = new(); // Instantiate the privilege mode covergroup + cg_PMPConfig pmpconfigCG = new(); // Instantiate the PMP config covergroup + cg_pmpcfg_mode pmpcfgmodeCG = new(); + + forever begin + @(posedge clk) begin + privmodeCG.sample(); // Sample the privilege mode covergroup + pmpconfigCG.sample(); // Sample the PMP config covergroupi + pmpcfgmodeCG.sample(); + end + end +end + + +endmodule + + + + + From db2b07b05d1cea703ad15313ccbcc5ced79eb58e Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:20:03 -0700 Subject: [PATCH 2/7] pmp functional coverage basic --- bin/wsim | 12 +-- sim/vcs/run_vcs | 27 ++++-- testbench/coverage/test_pmp_coverage.sv | 108 ++++++++++++++++++++++++ testbench/testbench.sv | 4 +- 4 files changed, 139 insertions(+), 12 deletions(-) create mode 100644 testbench/coverage/test_pmp_coverage.sv diff --git a/bin/wsim b/bin/wsim index a10ea6158..a85b7e304 100755 --- a/bin/wsim +++ b/bin/wsim @@ -29,8 +29,8 @@ print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim # Validate arguments if (args.gui): - if (args.sim != "questa"): - print("GUI option only supported for Questa") + if args.sim not in ["questa", "vcs"]: + print("GUI option only supported for Questa and VCS") exit(1) if (args.coverage): @@ -82,9 +82,9 @@ elif (args.sim == "vcs"): if (args.coverage): print("Coverage option not available for VCS") exit(1) - if (args.gui): - print("GUI option not available for VCS") - exit(1) + if (args.gui): + cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.tb + " " + "1" + os.system(cmd) cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" print(cmd) - os.system(cmd) \ No newline at end of file + os.system(cmd) diff --git a/sim/vcs/run_vcs b/sim/vcs/run_vcs index 27ffff8f0..ca5b10986 100755 --- a/sim/vcs/run_vcs +++ b/sim/vcs/run_vcs @@ -12,7 +12,26 @@ TB=${WALLY}/testbench CONFIG_VARIANT=${1} # Set TESTSUITE from the second script argument TESTSUITE=$2 +WKDIR=wkdir/${1}_${2} +if [ ! -d "$WKDIR" ]; then + #echo "Directory $WKDIR does not exist. Creating it now..." + mkdir -p "$WKDIR" + if [ $? -eq 0 ]; then + echo "Directory $WKDIR created successfully." + else + echo "Failed to create directory $WKDIR." + exit 1 + fi +else + echo "Directory $WKDIR already exists." +fi + +if [[ -n "$4" ]]; then + GUI="-gui" +else + GUI="" +fi INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ") SOURCE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +define+ +define+P.XLEN=64 +define+FPGA=0 +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}" @@ -21,14 +40,12 @@ SIMFILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clock OUTPUT="sim_out" clean() { - rm -rf obj_dir work transcript vsim.wlf $OUTPUT *.vcd csrc ucli.key vc_hdrs.h program.out - rm -rf simv* *.daidir dve *.vpd *.dump DVEfiles/ verdi* novas* *fsdb* *.vg *.rep *.db *.chk *.log *.out profileReport* simprofile_dir* + rm -rf ${WKDIR}/* } # Clean and run simulation with VCS clean #vcs +lint=all,noGCWM -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse -v2k_generate ${SOURCE_PATH} +define+TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV # lint ignores Unused Inputs (UI), Unnamed Assertipons (SVA-UA), Dynamic Type Sensitivty [IDTS], Null Statement [NS], Unequal Length in Comparison Operation [ULCO] -vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} -pvalue+testbench.TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV -./$OUTPUT | tee program.out - +vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -suppress -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} $SIMFILES -o ${WKDIR}/$OUTPUT -simdir ${WKDIR} -error=NOODV -work ${WKDIR} ${GUI} +./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} +fsdb+gate=off | tee ${WKDIR}/${WKDIR}.out diff --git a/testbench/coverage/test_pmp_coverage.sv b/testbench/coverage/test_pmp_coverage.sv new file mode 100644 index 000000000..2c1cbbfaa --- /dev/null +++ b/testbench/coverage/test_pmp_coverage.sv @@ -0,0 +1,108 @@ +module test_pmp_coverage import cvw::*; #(parameter cvw_t P) (input clk); + +// Ensure the covergroup is defined correctly +covergroup cg_priv_mode @(posedge clk); + coverpoint dut.core.ifu.PrivilegeModeW { + bins user = {2'b00}; + bins superv = {2'b01}; + bins hyperv = {2'b10}; + bins mach = {2'b11}; + } +endgroup + +covergroup cg_PMPConfig @(posedge clk); + coverpoint dut.core.ifu.PMPCFG_ARRAY_REGW[0][0] { + bins ones = {1}; + bins zeros = {0}; + } +endgroup + + +function bit [1:0] getPMPConfigSlice(int index); + return dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[index][4:3]; +endfunction + +//if (P.PMP_ENTRIES > 0) begin : pmp + covergroup cg_pmpcfg_mode @(posedge clk); + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[0][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[1][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[2][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[3][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[4][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[5][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[6][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[7][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + endgroup +//end + + +// Ensure that the instantiation and sampling of covergroups are within the correct procedural context +initial begin + cg_priv_mode privmodeCG = new(); // Instantiate the privilege mode covergroup + cg_PMPConfig pmpconfigCG = new(); // Instantiate the PMP config covergroup + cg_pmpcfg_mode pmpcfgmodeCG = new(); + + forever begin + @(posedge clk) begin + privmodeCG.sample(); // Sample the privilege mode covergroup + pmpconfigCG.sample(); // Sample the PMP config covergroupi + pmpcfgmodeCG.sample(); + end + end +end + + +endmodule + + + + + diff --git a/testbench/testbench.sv b/testbench/testbench.sv index f6a07b29c..b63d6512d 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -881,7 +881,9 @@ end if (errors) $display("%s failed with %d errors. :(", TestName, errors); else $display("%s succeeded. Brilliant!!!", TestName); endtask - + + +test_pmp_coverage #(P) pmp_inst(clk); /* verilator lint_on WIDTHTRUNC */ /* verilator lint_on WIDTHEXPAND */ From 3853f9433769894a794d1980aa367dc67b422436 Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:23:59 -0700 Subject: [PATCH 3/7] Revert "initial commit pmp basic coverage working" This reverts commit 7ca1c976c04563a19ec97ce8e21326ade596f023. --- bin/wsim | 12 +-- sim/questa/wally.do | 2 +- sim/vcs/run_vcs | 27 ++---- testbench/coverage/test_pmp_coverage.sv | 108 ------------------------ 4 files changed, 12 insertions(+), 137 deletions(-) delete mode 100644 testbench/coverage/test_pmp_coverage.sv diff --git a/bin/wsim b/bin/wsim index a85b7e304..a10ea6158 100755 --- a/bin/wsim +++ b/bin/wsim @@ -29,8 +29,8 @@ print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim # Validate arguments if (args.gui): - if args.sim not in ["questa", "vcs"]: - print("GUI option only supported for Questa and VCS") + if (args.sim != "questa"): + print("GUI option only supported for Questa") exit(1) if (args.coverage): @@ -82,9 +82,9 @@ elif (args.sim == "vcs"): if (args.coverage): print("Coverage option not available for VCS") exit(1) - if (args.gui): - cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.tb + " " + "1" - os.system(cmd) + if (args.gui): + print("GUI option not available for VCS") + exit(1) cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" print(cmd) - os.system(cmd) + os.system(cmd) \ No newline at end of file diff --git a/sim/questa/wally.do b/sim/questa/wally.do index 062cf5fe0..33832516b 100644 --- a/sim/questa/wally.do +++ b/sim/questa/wally.do @@ -97,7 +97,7 @@ if {$argc >= 3} { # "Extra checking for conflicts with always_comb done at vopt time" # because vsim will run vopt -vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} +incdir+${CONFIG}/shared ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv ${TB}/coverage/test_pmp_coverage.sv -suppress 2583 -suppress 7063,2596,13286 +vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} +incdir+${CONFIG}/shared ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv -suppress 2583 -suppress 7063,2596,13286 # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals diff --git a/sim/vcs/run_vcs b/sim/vcs/run_vcs index ca5b10986..27ffff8f0 100755 --- a/sim/vcs/run_vcs +++ b/sim/vcs/run_vcs @@ -12,26 +12,7 @@ TB=${WALLY}/testbench CONFIG_VARIANT=${1} # Set TESTSUITE from the second script argument TESTSUITE=$2 -WKDIR=wkdir/${1}_${2} -if [ ! -d "$WKDIR" ]; then - #echo "Directory $WKDIR does not exist. Creating it now..." - mkdir -p "$WKDIR" - if [ $? -eq 0 ]; then - echo "Directory $WKDIR created successfully." - else - echo "Failed to create directory $WKDIR." - exit 1 - fi -else - echo "Directory $WKDIR already exists." -fi - -if [[ -n "$4" ]]; then - GUI="-gui" -else - GUI="" -fi INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ") SOURCE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +define+ +define+P.XLEN=64 +define+FPGA=0 +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}" @@ -40,12 +21,14 @@ SIMFILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clock OUTPUT="sim_out" clean() { - rm -rf ${WKDIR}/* + rm -rf obj_dir work transcript vsim.wlf $OUTPUT *.vcd csrc ucli.key vc_hdrs.h program.out + rm -rf simv* *.daidir dve *.vpd *.dump DVEfiles/ verdi* novas* *fsdb* *.vg *.rep *.db *.chk *.log *.out profileReport* simprofile_dir* } # Clean and run simulation with VCS clean #vcs +lint=all,noGCWM -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse -v2k_generate ${SOURCE_PATH} +define+TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV # lint ignores Unused Inputs (UI), Unnamed Assertipons (SVA-UA), Dynamic Type Sensitivty [IDTS], Null Statement [NS], Unequal Length in Comparison Operation [ULCO] -vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -suppress -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} $SIMFILES -o ${WKDIR}/$OUTPUT -simdir ${WKDIR} -error=NOODV -work ${WKDIR} ${GUI} -./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} +fsdb+gate=off | tee ${WKDIR}/${WKDIR}.out +vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} -pvalue+testbench.TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV +./$OUTPUT | tee program.out + diff --git a/testbench/coverage/test_pmp_coverage.sv b/testbench/coverage/test_pmp_coverage.sv deleted file mode 100644 index 2c1cbbfaa..000000000 --- a/testbench/coverage/test_pmp_coverage.sv +++ /dev/null @@ -1,108 +0,0 @@ -module test_pmp_coverage import cvw::*; #(parameter cvw_t P) (input clk); - -// Ensure the covergroup is defined correctly -covergroup cg_priv_mode @(posedge clk); - coverpoint dut.core.ifu.PrivilegeModeW { - bins user = {2'b00}; - bins superv = {2'b01}; - bins hyperv = {2'b10}; - bins mach = {2'b11}; - } -endgroup - -covergroup cg_PMPConfig @(posedge clk); - coverpoint dut.core.ifu.PMPCFG_ARRAY_REGW[0][0] { - bins ones = {1}; - bins zeros = {0}; - } -endgroup - - -function bit [1:0] getPMPConfigSlice(int index); - return dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[index][4:3]; -endfunction - -//if (P.PMP_ENTRIES > 0) begin : pmp - covergroup cg_pmpcfg_mode @(posedge clk); - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[0][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[1][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[2][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[3][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[4][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[5][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[6][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - - coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[7][4:3] { - bins off = {2'b00}; - bins tor = {2'b01}; - bins na4 = {2'b10}; - bins napot = {2'b11}; - } - endgroup -//end - - -// Ensure that the instantiation and sampling of covergroups are within the correct procedural context -initial begin - cg_priv_mode privmodeCG = new(); // Instantiate the privilege mode covergroup - cg_PMPConfig pmpconfigCG = new(); // Instantiate the PMP config covergroup - cg_pmpcfg_mode pmpcfgmodeCG = new(); - - forever begin - @(posedge clk) begin - privmodeCG.sample(); // Sample the privilege mode covergroup - pmpconfigCG.sample(); // Sample the PMP config covergroupi - pmpcfgmodeCG.sample(); - end - end -end - - -endmodule - - - - - From 7a5eac963ed727b9d8bcbf9617291af3f11e11b7 Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:43:33 -0700 Subject: [PATCH 4/7] Revert "pmp functional coverage basic" This reverts commit db2b07b05d1cea703ad15313ccbcc5ced79eb58e. --- testbench/testbench.sv | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testbench/testbench.sv b/testbench/testbench.sv index d17f389f2..0c732c0be 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -882,9 +882,7 @@ end if (errors) $display("%s failed with %d errors. :(", TestName, errors); else $display("%s succeeded. Brilliant!!!", TestName); endtask - - -test_pmp_coverage #(P) pmp_inst(clk); + /* verilator lint_on WIDTHTRUNC */ /* verilator lint_on WIDTHEXPAND */ From 48ad4d6001650f6e285608724e63fa883d530924 Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:52:54 -0700 Subject: [PATCH 5/7] pmp coverage --- bin/wsim | 14 +++++++------- sim/vcs/run_vcs | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/bin/wsim b/bin/wsim index a10ea6158..b29eee4bd 100755 --- a/bin/wsim +++ b/bin/wsim @@ -29,8 +29,8 @@ print("Config=" + args.config + " tests=" + args.testsuite + " sim=" + args.sim # Validate arguments if (args.gui): - if (args.sim != "questa"): - print("GUI option only supported for Questa") + if args.sim not in ["questa", "vcs"]: + print("GUI option only supported for Questa and VCS") exit(1) if (args.coverage): @@ -82,9 +82,9 @@ elif (args.sim == "vcs"): if (args.coverage): print("Coverage option not available for VCS") exit(1) - if (args.gui): - print("GUI option not available for VCS") - exit(1) - cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" + if (args.gui): + cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.tb + " " + "1" + else: + cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" print(cmd) - os.system(cmd) \ No newline at end of file + os.system(cmd) diff --git a/sim/vcs/run_vcs b/sim/vcs/run_vcs index 27ffff8f0..ca5b10986 100755 --- a/sim/vcs/run_vcs +++ b/sim/vcs/run_vcs @@ -12,7 +12,26 @@ TB=${WALLY}/testbench CONFIG_VARIANT=${1} # Set TESTSUITE from the second script argument TESTSUITE=$2 +WKDIR=wkdir/${1}_${2} +if [ ! -d "$WKDIR" ]; then + #echo "Directory $WKDIR does not exist. Creating it now..." + mkdir -p "$WKDIR" + if [ $? -eq 0 ]; then + echo "Directory $WKDIR created successfully." + else + echo "Failed to create directory $WKDIR." + exit 1 + fi +else + echo "Directory $WKDIR already exists." +fi + +if [[ -n "$4" ]]; then + GUI="-gui" +else + GUI="" +fi INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ") SOURCE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +define+ +define+P.XLEN=64 +define+FPGA=0 +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}" @@ -21,14 +40,12 @@ SIMFILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clock OUTPUT="sim_out" clean() { - rm -rf obj_dir work transcript vsim.wlf $OUTPUT *.vcd csrc ucli.key vc_hdrs.h program.out - rm -rf simv* *.daidir dve *.vpd *.dump DVEfiles/ verdi* novas* *fsdb* *.vg *.rep *.db *.chk *.log *.out profileReport* simprofile_dir* + rm -rf ${WKDIR}/* } # Clean and run simulation with VCS clean #vcs +lint=all,noGCWM -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse -v2k_generate ${SOURCE_PATH} +define+TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV # lint ignores Unused Inputs (UI), Unnamed Assertipons (SVA-UA), Dynamic Type Sensitivty [IDTS], Null Statement [NS], Unequal Length in Comparison Operation [ULCO] -vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} -pvalue+testbench.TEST=$TESTSUITE $SIMFILES -o $OUTPUT -error=NOODV -./$OUTPUT | tee program.out - +vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU -simprofile -suppress -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse ${SOURCE_PATH} $SIMFILES -o ${WKDIR}/$OUTPUT -simdir ${WKDIR} -error=NOODV -work ${WKDIR} ${GUI} +./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} +fsdb+gate=off | tee ${WKDIR}/${WKDIR}.out From ee566aa856a17243aa3346489663430fd15f28fd Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:53:04 -0700 Subject: [PATCH 6/7] pmp coverage --- testbench/testbench.sv | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testbench/testbench.sv b/testbench/testbench.sv index 0c732c0be..093522fc3 100644 --- a/testbench/testbench.sv +++ b/testbench/testbench.sv @@ -168,7 +168,6 @@ module testbench; "arch64zknd": if (P.ZKND_SUPPORTED) tests = arch64zknd; "arch64zkne": if (P.ZKNE_SUPPORTED) tests = arch64zkne; "arch64zknh": if (P.ZKNH_SUPPORTED) tests = arch64zknh; - "wallycov64i": tests = wallycov64i; endcase end else begin // RV32 case (TEST) @@ -882,7 +881,10 @@ end if (errors) $display("%s failed with %d errors. :(", TestName, errors); else $display("%s succeeded. Brilliant!!!", TestName); endtask - + +`ifdef PMP_COVERAGE +test_pmp_coverage #(P) pmp_inst(clk); +`endif /* verilator lint_on WIDTHTRUNC */ /* verilator lint_on WIDTHEXPAND */ From 12a9c0ebd6296c386bdcc8312106b2a9d0a5f96d Mon Sep 17 00:00:00 2001 From: Divya2030 Date: Thu, 2 May 2024 11:53:32 -0700 Subject: [PATCH 7/7] pmp coverage --- testbench/coverage/test_pmp_coverage.sv | 108 ++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 testbench/coverage/test_pmp_coverage.sv diff --git a/testbench/coverage/test_pmp_coverage.sv b/testbench/coverage/test_pmp_coverage.sv new file mode 100644 index 000000000..2c1cbbfaa --- /dev/null +++ b/testbench/coverage/test_pmp_coverage.sv @@ -0,0 +1,108 @@ +module test_pmp_coverage import cvw::*; #(parameter cvw_t P) (input clk); + +// Ensure the covergroup is defined correctly +covergroup cg_priv_mode @(posedge clk); + coverpoint dut.core.ifu.PrivilegeModeW { + bins user = {2'b00}; + bins superv = {2'b01}; + bins hyperv = {2'b10}; + bins mach = {2'b11}; + } +endgroup + +covergroup cg_PMPConfig @(posedge clk); + coverpoint dut.core.ifu.PMPCFG_ARRAY_REGW[0][0] { + bins ones = {1}; + bins zeros = {0}; + } +endgroup + + +function bit [1:0] getPMPConfigSlice(int index); + return dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[index][4:3]; +endfunction + +//if (P.PMP_ENTRIES > 0) begin : pmp + covergroup cg_pmpcfg_mode @(posedge clk); + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[0][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[1][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[2][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[3][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[4][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[5][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[6][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + + coverpoint dut.core.ifu.immu.immu.PMPCFG_ARRAY_REGW[7][4:3] { + bins off = {2'b00}; + bins tor = {2'b01}; + bins na4 = {2'b10}; + bins napot = {2'b11}; + } + endgroup +//end + + +// Ensure that the instantiation and sampling of covergroups are within the correct procedural context +initial begin + cg_priv_mode privmodeCG = new(); // Instantiate the privilege mode covergroup + cg_PMPConfig pmpconfigCG = new(); // Instantiate the PMP config covergroup + cg_pmpcfg_mode pmpcfgmodeCG = new(); + + forever begin + @(posedge clk) begin + privmodeCG.sample(); // Sample the privilege mode covergroup + pmpconfigCG.sample(); // Sample the PMP config covergroupi + pmpcfgmodeCG.sample(); + end + end +end + + +endmodule + + + + +