cvw/sim/vcs/run_vcs

118 lines
4.5 KiB
Plaintext
Raw Normal View History

2024-04-03 17:39:02 +00:00
#!/bin/bash
2024-04-20 21:12:55 +00:00
# VCS Compilation for WALLY
# Divya Kohli, Rose Thompson, David Harris 2024
2024-04-21 05:52:08 +00:00
# Note: VCS produces warning about unsupported Linux Version, but runs successfully
2024-04-20 21:12:55 +00:00
# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
2024-04-03 17:39:02 +00:00
2024-05-07 17:41:02 +00:00
# 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"
2024-04-03 17:39:02 +00:00
# Set CONFIG_VARIANT from the first script argument
CONFIG_VARIANT=${1}
# Set TESTSUITE from the second script argument
TESTSUITE=$2
2024-05-07 17:41:02 +00:00
WKDIR="wkdir/${1}_${2}"
COV="cov/${1}_${2}"
LOGS="logs"
2024-05-08 11:39:42 +00:00
if [ ${TESTSUITE} = "buildroot" ]; then
shift 2
PLUSARGS="$*"
fi
2024-05-07 17:41:02 +00:00
clean_logs() {
echo -e "${YELLOW}Cleaning up workspace...${NC}"
rm -rf wkdir logs cov
}
clean_simprofile() {
echo -e "${YELLOW}Cleaning up simprofile_dir...${NC}"
2024-05-08 11:25:03 +00:00
rm -rf simprofile_dir* profileReport*
2024-05-07 17:41:02 +00:00
}
2024-05-08 11:25:03 +00:00
#clean_simprofile
2024-05-07 17:41:02 +00:00
#clean_logs
# 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
2024-05-02 18:52:54 +00:00
else
2024-05-07 17:41:02 +00:00
echo "Directory $dir already exists."
2024-05-02 18:52:54 +00:00
fi
2024-05-07 17:41:02 +00:00
}
# 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
}
2024-05-02 18:52:54 +00:00
else
2024-05-07 17:41:02 +00:00
echo -e "${GREEN}Directory $WKDIR already exists.${NC}"
2024-05-02 18:52:54 +00:00
fi
2024-05-07 17:41:02 +00:00
# GUI option handling
GUI=""
if [ "$3" = "gui" ]; then
2024-05-02 18:52:54 +00:00
GUI="-gui"
else
GUI=""
fi
2024-04-20 21:12:55 +00:00
2024-05-07 17:41:02 +00:00
# Collect include directories
2024-04-20 21:12:55 +00:00
INCLUDE_DIRS=$(find ${SRC} -type d | xargs -I {} echo -n "{} ")
2024-05-07 17:41:02 +00:00
INCLUDE_PATH="+incdir+${CFG}/${CONFIG_VARIANT} +incdir+${CFG}/deriv/${CONFIG_VARIANT} +incdir+${CFG}/shared +incdir+../../tests +define+ +incdir+${TB} ${SRC}/cvw.sv +incdir+${SRC}"
2024-04-20 21:12:55 +00:00
2024-05-07 17:41:02 +00:00
# Prepare RTL files avoiding certain paths
2024-06-19 16:40:35 +00:00
RTL_FILES="$INCLUDE_DIRS $(find ${SRC} -name "*.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_2048x64.sv") ${TB}/testbench.sv $(find ${TB}/common -name "*.sv" ! -path "${TB}/common/wallyTracer.sv")"
2024-05-07 17:41:02 +00:00
# Simulation and Coverage Commands
2024-04-03 17:39:02 +00:00
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 -suppress +warn -sverilog +vc -Mupdate -line -full64 -lca -ntb_opts sensitive_dyn ${INCLUDE_PATH} " # Disabled Debug flags; add them back for a GUI mode -debug_access+all+reverse -kdb +vcs+vcdpluson
SIMV_CMD="./${WKDIR}/$OUTPUT +TEST=${TESTSUITE} ${PLUSARGS} -no_save"
2024-04-03 17:39:02 +00:00
# Clean and run simulation with VCS
2024-05-07 17:41:02 +00:00
2024-06-27 18:16:17 +00:00
if [ "$3" = "--coverage" ]; then
2024-05-07 17:41:02 +00:00
echo -e "${YELLOW}#### Running VCS Simulation with Coverage ####${NC}"
2024-06-27 18:16:17 +00:00
COV_OPTIONS="-cm line+cond+branch+fsm+tgl -cm_log ${WKDIR}/coverage.log -cm_dir ${WKDIR}/COVERAGE"
COV_RUN="urg -dir ./${WKDIR}/COVERAGE.vdb -format text -report IndividualCovReport/${CONFIG_VARIANT}_${TESTSUITE}"
2024-06-28 14:19:03 +00:00
$VCS_CMD -Mdir=${WKDIR} $COV_OPTIONS $RTL_FILES -o ${WKDIR}/$OUTPUT -Mlib ${WKDIR} -work ${WKDIR} -l "$LOGS/${CONFIG_VARIANT}_${TESTSUITE}.log"
2024-06-27 18:16:17 +00:00
$SIMV_CMD $COV_OPTIONS # dh 6/27/24 *** are COV_OPTIONS really needed?
2024-05-07 17:41:02 +00:00
$COV_RUN
#cp -rf urgReport $COV
2024-06-27 18:16:17 +00:00
elif [ "$3" = "--lockstep" ]; then
echo -e "${YELLOW}#### Running VCS Simulation with Lockstep ####${NC}"
2024-06-28 14:19:03 +00:00
LOCKSTEP_OPTIONS=" +define+USE_IMPERAS_DV +incdir+${IMPERAS_HOME}/ImpPublic/include/host +incdir+${IMPERAS_HOME}/ImpProprietary/include/host ${IMPERAS_HOME}/ImpPublic/source/host/rvvi/*.sv ${IMPERAS_HOME}/ImpProprietary/source/host/idv/*.sv ${TB}/common/wallyTracer.sv"
LOCKSTEP_SIMV="-sv_lib ${IMPERAS_HOME}/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model"
$VCS_CMD -Mdir=${WKDIR} $LOCKSTEP_OPTIONS $RTL_FILES -o ${WKDIR}/$OUTPUT -Mlib ${WKDIR} -work ${WKDIR} -l "$LOGS/${CONFIG_VARIANT}_${TESTSUITE}.log"
$SIMV_CMD $LOCKSTEP_SIMV
2024-05-07 17:41:02 +00:00
else
echo -e "${YELLOW}#### Running VCS Simulation ####${NC}"
2024-06-28 14:19:03 +00:00
$VCS_CMD -Mdir=${WKDIR} $RTL_FILES -o ${WKDIR}/$OUTPUT -work ${WKDIR} -Mlib ${WKDIR} -l "$LOGS/${CONFIG_VARIANT}_${TESTSUITE}.log"
2024-05-08 11:25:03 +00:00
$SIMV_CMD
2024-05-07 17:41:02 +00:00
fi