Merge branch 'main' of https://github.com/openhwgroup/cvw into dev

This commit is contained in:
David Harris 2024-05-07 12:58:40 -07:00
commit 927f166e1f
3 changed files with 99 additions and 36 deletions

View File

@ -34,8 +34,8 @@ if (args.gui):
exit(1) exit(1)
if (args.coverage): if (args.coverage):
if (args.sim != "questa"): if args.sim not in ["questa", "vcs"]:
print("Coverage option only available for Questa") print("Coverage option only available for Questa and VCS")
exit(1) exit(1)
if (args.vcd): if (args.vcd):
@ -79,12 +79,10 @@ elif (args.sim == "verilator"):
os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} EXTRA_ARGS='{args.args}'") os.system(f"/usr/bin/make -C {regressionDir}/verilator WALLYCONF={args.config} TEST={args.testsuite} EXTRA_ARGS='{args.args}'")
elif (args.sim == "vcs"): elif (args.sim == "vcs"):
print(f"Running VCS on " + args.config + " " + args.testsuite) print(f"Running VCS on " + args.config + " " + args.testsuite)
if (args.coverage):
print("Coverage option not available for VCS")
exit(1)
if (args.gui): if (args.gui):
cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.tb + " " + "1" args.args += "gui"
else: elif (args.coverage):
cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\"" args.args += "coverage"
cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.args
print(cmd) print(cmd)
os.system(cmd) os.system(cmd)

View File

@ -4,48 +4,108 @@
# Note: VCS produces warning about unsupported Linux Version, but runs successfully # Note: VCS produces warning about unsupported Linux Version, but runs successfully
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 # SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
CFG=${WALLY}/config # Color Definitions
SRC=${WALLY}/src RED='\033[0;31m'
TB=${WALLY}/testbench GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Directories
CFG="${WALLY}/config"
SRC="${WALLY}/src"
TB="${WALLY}/testbench"
# Set CONFIG_VARIANT from the first script argument # Set CONFIG_VARIANT from the first script argument
#CONFIG_VARIANT=${1:-rv64i}
CONFIG_VARIANT=${1} CONFIG_VARIANT=${1}
# Set TESTSUITE from the second script argument # Set TESTSUITE from the second script argument
TESTSUITE=$2 TESTSUITE=$2
WKDIR=wkdir/${1}_${2}
if [ ! -d "$WKDIR" ]; then WKDIR="wkdir/${1}_${2}"
#echo "Directory $WKDIR does not exist. Creating it now..." COV="cov/${1}_${2}"
mkdir -p "$WKDIR" LOGS="logs"
clean_logs() {
echo -e "${YELLOW}Cleaning up workspace...${NC}"
rm -rf wkdir logs cov
}
clean_simprofile() {
echo -e "${YELLOW}Cleaning up simprofile_dir...${NC}"
rm -rf simprofile_dir* profileReport*
}
#clean_logs
clean_simprofile
# Function to create a directory if it does not exist
create_directory() {
local dir=$1 # Local variable for directory name
if [ ! -d "$dir" ]; then
mkdir -p "$dir"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Directory $WKDIR created successfully." echo "Directory $dir created successfully."
else else
echo "Failed to create directory $WKDIR." echo "Failed to create directory $dir."
exit 1 exit 1
fi fi
else else
echo "Directory $WKDIR already exists." echo "Directory $dir already exists."
fi
}
# Create or verify WKDIR, COV, and LOGS directories
create_directory "$WKDIR"
create_directory "$COV"
create_directory "$LOGS"
# Ensure the working directory exists
if [ ! -d "$WKDIR" ]; then
echo -e "${YELLOW}Directory $WKDIR does not exist. Creating it now...${NC}"
mkdir -p "$WKDIR" && echo -e "${GREEN}Directory $WKDIR created successfully.${NC}" || {
echo -e "${RED}Failed to create directory $WKDIR.${NC}"
exit 1
}
else
echo -e "${GREEN}Directory $WKDIR already exists.${NC}"
fi fi
if [[ -n "$4" ]]; then # GUI option handling
GUI=""
if [ "$3" = "gui" ]; then
GUI="-gui" GUI="-gui"
else else
GUI="" GUI=""
fi fi
# Collect include directories
INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ") 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}" INCLUDE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +incdir+../../tests +define+ +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}"
SIMFILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clockgater.sv" ! -path "${SRC}/generic/mem/rom1p1r_128x64.sv" ! -path "${SRC}/generic/mem/ram2p1r1wbe_128x64.sv" ! -path "${SRC}/generic/mem/rom1p1r_128x32.sv" ! -path "${SRC}/generic/mem/ram2p1r1wbe_512x64.sv") ${TB}/testbench.sv $(find ${TB}/common -name "*.sv" ! -path "${TB}/common/wallyTracer.sv")" # Prepare RTL files avoiding certain paths
RTL_FILES="$INCLUDE_DIRS $(find ${SRC} -name "*.sv" ! -path "${SRC}/generic/clockgater.sv" ! -path "${SRC}/generic/mem/rom1p1r_128x64.sv" ! -path "${SRC}/generic/mem/ram2p1r1wbe_128x64.sv" ! -path "${SRC}/generic/mem/rom1p1r_128x32.sv" ! -path "${SRC}/generic/mem/ram2p1r1wbe_512x64.sv") ${TB}/testbench.sv $(find ${TB}/common -name "*.sv" ! -path "${TB}/common/wallyTracer.sv")"
# Simulation and Coverage Commands
OUTPUT="sim_out" OUTPUT="sim_out"
VCS_CMD="vcs +lint=all,noGCWM,noUI,noSVA-UA,noIDTS,noNS,noULCO,noCAWM-L,noWMIA-L,noSV-PIU,noSTASKW_CO,noSTASKW_CO1,noSTASKW_RMCOF +vcs+vcdpluson -simprofile -suppress +warn -sverilog +vc -Mupdate -line -full64 -kdb -lca -debug_access+all+reverse -ntb_opts sensitive_dyn +define+SIM_VCS ${INCLUDE_PATH} $RTL_FILES"
SIMV_CMD="./${WKDIR}/$OUTPUT +TEST=${TESTSUITE}"
COV_FILES="${TB}/coverage/test_pmp_coverage.sv"
COV_OPTIONS="-cm line+cond+branch+fsm+tgl -cm_log ${WKDIR}/coverage.log -cm_dir ${WKDIR}/COVERAGE"
COV_RUN="urg -dir ${WKDIR}/sim_out.vdb/"
clean() {
rm -rf ${WKDIR}/*
}
# Clean and run simulation with VCS # Clean and run simulation with VCS
clean #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] if [ "$3" = "coverage" ]; then
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} echo -e "${YELLOW}#### Running VCS Simulation with Coverage ####${NC}"
./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} +fsdb+gate=off | tee ${WKDIR}/${WKDIR}.out # Code Coverage.
$VCS_CMD $COV_OPTIONS -o ${WKDIR}/$OUTPUT -Mlib ${WKDIR} -work ${WKDIR} -l "$LOGS/${CONFIG_VARIANT}_${TESTSUITE}.log"
$SIMV_CMD
$COV_RUN
cp -rf urgReport $COV
else
echo -e "${YELLOW}#### Running VCS Simulation ####${NC}"
$VCS_CMD -o ${WKDIR}/$OUTPUT -work ${WKDIR} -Mlib ${WKDIR} -l "$LOGS/{CONFIG_VARIANT}_{TESTSUITE}.log"
$SIMV_CMD ${GUI}
fi

View File

@ -318,7 +318,11 @@ module testbench;
// Find the test vector files and populate the PC to function label converter // Find the test vector files and populate the PC to function label converter
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
logic [P.XLEN-1:0] testadr; logic [P.XLEN-1:0] testadr;
always_comb begin
//VCS ignores the dynamic types while processing the implicit sensitivity lists of always @*, always_comb, and always_latch
//procedural blocks. VCS supports the dynamic types in the implicit sensitivity list of always @* block as specified in the Section 9.2 of the IEEE Standard SystemVerilog Specification 1800-2012.
//To support memory load and dump task verbosity: flag : -diag sys_task_mem
always @(*) begin
begin_signature_addr = ProgramAddrLabelArray["begin_signature"]; begin_signature_addr = ProgramAddrLabelArray["begin_signature"];
end_signature_addr = ProgramAddrLabelArray["sig_end_canary"]; end_signature_addr = ProgramAddrLabelArray["sig_end_canary"];
signature_size = end_signature_addr - begin_signature_addr; signature_size = end_signature_addr - begin_signature_addr;
@ -409,8 +413,7 @@ module testbench;
if (!begin_signature_addr) if (!begin_signature_addr)
$display("begin_signature addr not found in %s", ProgramLabelMapFile); $display("begin_signature addr not found in %s", ProgramLabelMapFile);
else if (TEST != "embench") begin // *** quick hack for embench. need a better long term solution else if (TEST != "embench") begin // *** quick hack for embench. need a better long term solution
// CheckSignature(pathname, tests[test], riscofTest, begin_signature_addr, errors); CheckSignature(pathname, tests[test], riscofTest, begin_signature_addr, errors);
CheckSignature(pathname, tests[test], riscofTest, ProgramAddrLabelArray["begin_signature"], errors);
if(errors > 0) totalerrors = totalerrors + 1; if(errors > 0) totalerrors = totalerrors + 1;
end end
end end
@ -420,6 +423,8 @@ module testbench;
else $display("FAIL: %d test programs had errors", totalerrors); else $display("FAIL: %d test programs had errors", totalerrors);
`ifdef VERILATOR // this macro is defined when verilator is used `ifdef VERILATOR // this macro is defined when verilator is used
$finish; // Simulator Verilator needs $finish to terminate simulation. $finish; // Simulator Verilator needs $finish to terminate simulation.
`elsif SIM_VCS // this macro is defined when vcs is used
$finish; // Simulator VCS needs $finish to terminate simulation.
`else `else
$stop; // if this is changed to $finish for Questa, wally-batch.do does not go to the next step to run coverage, and wally.do terminates without allowing GUI debug $stop; // if this is changed to $finish for Questa, wally-batch.do does not go to the next step to run coverage, and wally.do terminates without allowing GUI debug
`endif `endif