VCS Simulation Passed

This commit is contained in:
Divya2030 2024-05-07 10:41:02 -07:00
parent 8c3cbede40
commit a3f1a274d2
3 changed files with 99 additions and 36 deletions

View File

@ -34,8 +34,8 @@ if (args.gui):
exit(1)
if (args.coverage):
if (args.sim != "questa"):
print("Coverage option only available for Questa")
if args.sim not in ["questa", "vcs"]:
print("Coverage option only available for Questa and VCS")
exit(1)
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}'")
elif (args.sim == "vcs"):
print(f"Running VCS on " + args.config + " " + args.testsuite)
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"
else:
cmd = cd + "; ./run_vcs " + args.config + " " + "\""+args.testsuite+"\""
args.args += "gui"
elif (args.coverage):
args.args += "coverage"
cmd = cd + "; ./run_vcs " + args.config + " " + args.testsuite + " " + args.args
print(cmd)
os.system(cmd)

View File

@ -4,48 +4,108 @@
# Note: VCS produces warning about unsupported Linux Version, but runs successfully
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
CFG=${WALLY}/config
SRC=${WALLY}/src
TB=${WALLY}/testbench
# Color Definitions
RED='\033[0;31m'
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
#CONFIG_VARIANT=${1:-rv64i}
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."
WKDIR="wkdir/${1}_${2}"
COV="cov/${1}_${2}"
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
echo "Directory $dir created successfully."
else
echo "Failed to create directory $dir."
exit 1
fi
else
echo "Failed to create directory $WKDIR."
exit 1
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 "Directory $WKDIR already exists."
echo -e "${GREEN}Directory $WKDIR already exists.${NC}"
fi
if [[ -n "$4" ]]; then
# GUI option handling
GUI=""
if [ "$3" = "gui" ]; then
GUI="-gui"
else
GUI=""
fi
# Collect include directories
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"
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
#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
#clean
if [ "$3" = "coverage" ]; then
echo -e "${YELLOW}#### Running VCS Simulation with Coverage ####${NC}"
# 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,9 +318,13 @@ module testbench;
// Find the test vector files and populate the PC to function label converter
////////////////////////////////////////////////////////////////////////////////
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"];
end_signature_addr = ProgramAddrLabelArray["sig_end_canary"];
end_signature_addr = ProgramAddrLabelArray["sig_end_canary"];
signature_size = end_signature_addr - begin_signature_addr;
end
logic EcallFaultM;
@ -409,8 +413,7 @@ module testbench;
if (!begin_signature_addr)
$display("begin_signature addr not found in %s", ProgramLabelMapFile);
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, ProgramAddrLabelArray["begin_signature"], errors);
CheckSignature(pathname, tests[test], riscofTest, begin_signature_addr, errors);
if(errors > 0) totalerrors = totalerrors + 1;
end
end
@ -420,6 +423,8 @@ module testbench;
else $display("FAIL: %d test programs had errors", totalerrors);
`ifdef VERILATOR // this macro is defined when verilator is used
$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
$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