diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index cca0456de5..ea02e05dfb 100644 --- a/.gitlab-ci/cva6.yml +++ b/.gitlab-ci/cva6.yml @@ -102,6 +102,7 @@ pub_check_env: - echo $RISCV - echo $RISCV_PREFIX - echo $VERILATOR_ROOT + - echo $VERILATOR_INSTALL_DIR - echo $SPIKE_ROOT - echo $BBL_ROOT - echo $SYN_VCS_BASHRC @@ -148,15 +149,21 @@ pub_smoke: DASHBOARD_SORT_INDEX: 0 DASHBOARD_JOB_CATEGORY: "Basic" script: - - mkdir -p artifacts/reports + - mkdir -p artifacts/reports artifacts/logs - python3 .gitlab-ci/scripts/report_fail.py - echo $SYN_VCS_BASHRC; source $SYN_VCS_BASHRC - - source cva6/regress/smoke-tests.sh + # In order to capture logs in case of test failure, the test script cannot fail. + - source cva6/regress/smoke-tests.sh || true + # The list of files must NOT fail on various DV_SIMULATORS values, so use 'v*_sim' to match + # 'veri-testharness_sim', 'vcs-testharness_sim' and 'vcs-uvm_sim' (one of them always applies, + # at least until new RTL simulator configurations are added.) + - for i in cva6/sim/*/v*_sim/*.log.iss ; do head -10000 $i > artifacts/logs/$(basename $i).head ; done - python3 .gitlab-ci/scripts/report_simu.py cva6/sim/logfile.log artifacts: when: always paths: - artifacts/reports/*.yml + - artifacts/logs/*.log.iss.head pub_riscv_arch_test: stage: two @@ -426,7 +433,8 @@ pub_wb_dcache: - source ci/make-tmp.sh - source ci/build-riscv-tests.sh - cd ../../../ - - make run-asm-tests-verilator defines=WB_DCACHE + # Use 'verilator --no-timing' until the timing issues in corev_apu RTL are fixed. + - make verilator="verilator --no-timing" run-asm-tests-verilator defines=WB_DCACHE - cd ../.. - python3 .gitlab-ci/scripts/report_pass.py artifacts: @@ -515,8 +523,8 @@ pub_fpga-boot: - job: pub_fpga-build artifacts: true variables: - VERILATOR_ROOT: "/shares/tools/dummy/verilator" # to avoid install of verilator - SPIKE_ROOT: "/shares/tools/dummy/spike" # to avoid install of spike + VERILATOR_INSTALL_DIR: "NO" # Skip install and checks of verilator + SPIKE_ROOT: "NO" # Skip install and checks of spike DASHBOARD_JOB_TITLE: "FPGA Linux64 Boot " DASHBOARD_JOB_DESCRIPTION: "Test of Linux 64 bits boot on FPGA Genesys2" DASHBOARD_SORT_INDEX: 10 diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 01808cdd64..c563adcb03 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -9,25 +9,46 @@ # Customise this to a fast local disk export ROOT_PROJECT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd) -export TOP=$ROOT_PROJECT/tools +export TOP="$ROOT_PROJECT/tools" # where to install the tools if ! [ -n "$RISCV" ]; then - echo "Error: RISCV variable undefined" + echo "Error: RISCV variable undefined." return fi -# install Verilator -if ! [ -n "$VERILATOR_ROOT" ]; then - export VERILATOR_ROOT=$TOP/verilator-4.110/ -fi -cva6/regress/install-verilator.sh +# Set up tool-related variables. +export PATH="$RISCV/bin:$PATH" +export LIBRARY_PATH="$RISCV/lib" +export LD_LIBRARY_PATH="$RISCV/lib:$LD_LIBRARY_PATH" +export C_INCLUDE_PATH="$RISCV/include" +export CPLUS_INCLUDE_PATH="$RISCV/include" + +# Install Verilator v5. +# Set VERILATOR_INSTALL_DIR to 'NO' to skip installation and checks +# of Verilator (useful for CI jobs not depending on Verilator in any way). +if [ "$VERILATOR_INSTALL_DIR" != "NO" ]; then + cva6/regress/install-verilator.sh + + # Complain if the installation directory of Verilator still is not set + # after running the installer. + if [ -z "$VERILATOR_INSTALL_DIR" ]; then + echo "Error: VERILATOR_INSTALL_DIR variable still undefined after running Verilator installer." + return + fi + + # Verilator was set up: add Verilator paths to appropriate variables. + export PATH="$VERILATOR_INSTALL_DIR/bin:$PATH" + export C_INCLUDE_PATH="$VERILATOR_INSTALL_DIR/share/verilator/include:$C_INCLUDE_PATH" + export CPLUS_INCLUDE_PATH="$VERILATOR_INSTALL_DIR/share/verilator/include:$CPLUS_INCLUDE_PATH" -export PATH=$RISCV/bin:$VERILATOR_ROOT/bin:$PATH -export LIBRARY_PATH=$RISCV/lib -export LD_LIBRARY_PATH=$RISCV/lib -export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include -export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_ROOT/include + # Check proper Verilator installation given current $PATH. + echo PATH=\"$PATH\" + echo "Verilator version:" + verilator --version || { echo "Error: Verilator not in \$PATH." ; return ; } +else + echo "Skipping Verilator setup on user's request (\$VERILATOR_INSTALL_DIR = \"NO\")." +fi # number of parallel jobs to use for make commands and simulation export NUM_JOBS=24 diff --git a/cva6/regress/install-spike.sh b/cva6/regress/install-spike.sh index af81255c4d..c389e32a8b 100755 --- a/cva6/regress/install-spike.sh +++ b/cva6/regress/install-spike.sh @@ -14,7 +14,12 @@ if [ -z ${NUM_JOBS} ]; then NUM_JOBS=1 fi -if [ ! -f "$SPIKE_ROOT/bin/spike" ]; then +# Set SPIKE_ROOT to 'NO' to skip the installation/checks of Spike altogether. +# This is useful for CI jobs not depending on Spike in any way. +if [ "$SPIKE_ROOT" = "NO" ]; then + echo "Skipping Spike setup on user's request (\$SPIKE_ROOT = \"NO\")." +else + if [ ! -f "$SPIKE_ROOT/bin/spike" ]; then echo "Installing Spike" PATCH_DIR=`pwd`/cva6/regress mkdir -p $SPIKE_ROOT @@ -35,7 +40,8 @@ if [ ! -f "$SPIKE_ROOT/bin/spike" ]; then ../configure --enable-commitlog --prefix="$SPIKE_ROOT" make -j${NUM_JOBS} make install -else - echo "Using Spike from cached directory." + else + echo "Using Spike from cached directory $SPIKE_ROOT." + fi fi diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index 337a9d1d25..c676f1118d 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -13,20 +13,68 @@ if [ -z ${NUM_JOBS} ]; then NUM_JOBS=1 fi -if [ ! -f "$VERILATOR_ROOT/bin/verilator" ]; then - echo "Installing Verilator" - mkdir -p $VERILATOR_ROOT - cd $VERILATOR_ROOT - rm -f verilator*.tgz v4.*.tar.gz - wget https://github.com/verilator/verilator/archive/refs/tags/v4.110.tar.gz - tar xzf v4.*.tar.gz - rm -f v4.*.tar.gz - cd verilator-4.110 - mkdir -p $VERILATOR_ROOT - # copy scripts - autoconf && ./configure --prefix="$VERILATOR_ROOT" && make -j${NUM_JOBS} - cp -r * $VERILATOR_ROOT/ - make test +# Ensure the location of tools is known (usually, .../core-v-verif/tools). +if [ -z "$TOP" ]; then + echo "Error: location of core-v-verif 'tools' tree (\$TOP) is not defined." + return +fi + +VERILATOR_REPO="https://github.com/verilator/verilator.git" +VERILATOR_BRANCH="master" +# Use the release tag instead of a full SHA1 hash. +VERILATOR_HASH="v5.008" +VERILATOR_PATCH="$TOP/../cva6/regress/verilator-v5.patch" + +# Unset historical variable VERILATOR_ROOT as it collides with the build process. +if [ -n "$VERILATOR_ROOT" ]; then + unset VERILATOR_ROOT +fi + +# Define the default src+build location of Verilator. +# No need to force this location in Continuous Integration scripts. +if [ -z "$VERILATOR_BUILD_DIR" ]; then + export VERILATOR_BUILD_DIR=${TOP}/verilator-$VERILATOR_HASH/verilator +fi + +# Define the default installation location of Verilator: one level up +# from the source tree in the core-v-verif tree. +# Continuous Integration may need to override this particular variable +# to use a preinstalled build of Verilator. +if [ -z "$VERILATOR_INSTALL_DIR" ]; then + export VERILATOR_INSTALL_DIR=$(dirname ${VERILATOR_BUILD_DIR}) +fi + +# Build and install Verilator only if not already installed at the expected +# location $VERILATOR_INSTALL_DIR. +if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then + echo "Building Verilator in $VERILATOR_BUILD_DIR..." + echo "Verilator will be installed in $VERILATOR_INSTALL_DIR" + echo "VERILATOR_REPO=$VERILATOR_REPO" + echo "VERILATOR_BRANCH=$VERILATOR_BRANCH" + echo "VERILATOR_HASH=$VERILATOR_HASH" + echo "VERILATOR_PATCH=$VERILATOR_PATCH" + mkdir -p $VERILATOR_BUILD_DIR + cd $VERILATOR_BUILD_DIR + # Clone only if the ".git" directory does not exist. + # Do not remove the content arbitrarily if ".git" does not exist in order + # to preserve user content - let git fail instead. + [ -d .git ] || git clone $VERILATOR_REPO -b $VERILATOR_BRANCH . + git checkout $VERILATOR_HASH + if [ ! -z "$VERILATOR_PATCH" ] ; then + git apply $VERILATOR_PATCH || true + fi + # Generate the config script and configure Verilator. + autoconf && ./configure --prefix="$VERILATOR_INSTALL_DIR" && make -j${NUM_JOBS} + # FORNOW: Accept failure in 'make test' (segfault issue on Debian10) + make test || true + echo "Installing Verilator in $VERILATOR_INSTALL_DIR..." + make install + #make test || echo "### 'make test' in $VERILATOR_ROOT: some tests failed." + cd - else - echo "Using Verilator from cached directory." + echo "Using Verilator from cached directory $VERILATOR_INSTALL_DIR." fi + +# Update PATH to match the verilator installation. +export PATH="$VERILATOR_INSTALL_DIR/bin:$PATH" + diff --git a/cva6/regress/verilator-v5.patch b/cva6/regress/verilator-v5.patch new file mode 100644 index 0000000000..ed8df2b9f8 --- /dev/null +++ b/cva6/regress/verilator-v5.patch @@ -0,0 +1,26 @@ +diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS +index 215fb6bd8..829752e6b 100644 +--- a/docs/CONTRIBUTORS ++++ b/docs/CONTRIBUTORS +@@ -154,5 +154,6 @@ Yuri Victorovich + Yutetsu TAKATSUKASA + Yu-Sheng Lin + Yves Mathieu ++Zbigniew Chamski + Zhanglei Wang + Zixi Li +diff --git a/include/verilated_types.h b/include/verilated_types.h +index cb7265e32..f1d482d8e 100644 +--- a/include/verilated_types.h ++++ b/include/verilated_types.h +@@ -1012,8 +1012,8 @@ struct VlUnpacked final { + + // METHODS + // Raw access +- WData* data() { return &m_storage[0]; } +- const WData* data() const { return &m_storage[0]; } ++ WData* data() { return (WData*)&m_storage[0]; } ++ const WData* data() const { return (const WData*)&m_storage[0]; } + + T_Value& operator[](size_t index) { return m_storage[index]; } + const T_Value& operator[](size_t index) const { return m_storage[index]; } diff --git a/cva6/sim/Makefile b/cva6/sim/Makefile index 28e3624da2..23fcf205ef 100644 --- a/cva6/sim/Makefile +++ b/cva6/sim/Makefile @@ -116,7 +116,7 @@ vcs-testharness: grep $(isspostrun_opts) ./trace_rvfi_hart_00.dasm veri-testharness: - make -C $(path_var) verilate target=$(target) defines=$(subst +define+,,$(isscomp_opts)) + make -C $(path_var) verilate verilator="verilator --no-timing" target=$(target) defines=$(subst +define+,,$(isscomp_opts)) $(path_var)/work-ver/Variane_testharness $(if $(TRACE_COMPACT), -f verilator.fst) $(if $(TRACE_FAST), -v verilator.vcd) $(elf) $(issrun_opts) +PRELOAD=$(elf) \ +tohost_addr=$(shell $$RISCV/bin/riscv-none-elf-nm -B $(elf) | grep -w tohost | cut -d' ' -f1) $(tool_path)/spike-dasm --isa=$(variant) < ./trace_rvfi_hart_00.dasm > $(log)