From 5efcea5be560caf98ca0aa928765ae24cdb895b2 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Fri, 3 Mar 2023 20:13:27 +0100 Subject: [PATCH 01/17] Verilator-based simulations: Install and use v5.006 of Verilator. * cva6/regress/install-cva6.sh (VERILATOR_ROOT): Use a separate Verilator build containing v5.006. * cva6/regress/install-verilator.sh: Modify to install and build Verilator v5.006 with modifications that make it buildable on Debian 10. Add comments explaining the current limitations. --- cva6/regress/install-cva6.sh | 2 +- cva6/regress/install-verilator.sh | 41 ++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 01808cdd64..98161c3c78 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -19,7 +19,7 @@ fi # install Verilator if ! [ -n "$VERILATOR_ROOT" ]; then - export VERILATOR_ROOT=$TOP/verilator-4.110/ + export VERILATOR_ROOT=$TOP/verilator-5.006/ fi cva6/regress/install-verilator.sh diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index 337a9d1d25..9e4cfcbb7a 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -13,20 +13,39 @@ if [ -z ${NUM_JOBS} ]; then NUM_JOBS=1 fi -if [ ! -f "$VERILATOR_ROOT/bin/verilator" ]; then - echo "Installing Verilator" +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="../../../cva6/regress/verilator-v5.patch" + +# VERILATOR_ROOT must point to the root of the Verilator source tree. +# This is not necessarily the installation prefix. +# The two should be kept separate ==> use VERILATOR_INSTALL_DIR to specify +# the installation location of Verilator. +if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then + echo "Building Verilator in $VERILATOR_ROOT..." + echo "VERILATOR_REPO=$VERILATOR_REPO" + echo "VERILATOR_BRANCH=$VERILATOR_BRANCH" + echo "VERILATOR_HASH=$VERILATOR_HASH" + echo "VERILATOR_PATCH=$VERILATOR_PATCH" 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/ + # 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 + fi + # Generate the config script and configure Verilator. + autoconf && ./configure --prefix="$VERILATOR_INSTALL_DIR" && make -j${NUM_JOBS} make test + 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." fi From ecc4efeb77579ffe56bae135f8abd69a736e3c1e Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 29 Mar 2023 14:55:23 +0200 Subject: [PATCH 02/17] FORNOW: Assume '--no-timing' for Verilator v5 until RTL is cleaned up. --- cva6/sim/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 9ac92f39fb81496356eeea7a1ba4a9e3c78d612c Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 29 Mar 2023 14:58:14 +0200 Subject: [PATCH 03/17] Default to Verilator v5.008. Change VL flow to use separate install dir. --- cva6/regress/install-cva6.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 98161c3c78..6faed55696 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -18,16 +18,21 @@ if ! [ -n "$RISCV" ]; then fi # install Verilator +# Use historical variable VERILATOR_ROOT to check/specify VL configuration. if ! [ -n "$VERILATOR_ROOT" ]; then - export VERILATOR_ROOT=$TOP/verilator-5.006/ + # Verilator installation dir should be separate from the VL source root. + # Source code will be unpacked, built and tested in the 'verilator' + # subdir of the install dir. + export VERILATOR_ROOT=$TOP/verilator-5.008/verilator + export VERILATOR_INSTALL_DIR=$(dirname $VERILATOR_ROOT) fi cva6/regress/install-verilator.sh -export PATH=$RISCV/bin:$VERILATOR_ROOT/bin:$PATH +export PATH=$RISCV/bin:$VERILATOR_INSTALL_DIR/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 +export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include +export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include # number of parallel jobs to use for make commands and simulation export NUM_JOBS=24 From 96fa52e43ac652d507e125117011c97dc89c36f1 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 29 Mar 2023 16:29:21 +0200 Subject: [PATCH 04/17] Add patch needed for direct access to memory data in Verilator 5. --- cva6/regress/verilator-v5.patch | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cva6/regress/verilator-v5.patch 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]; } From 967c6c09eef14454d2288817061f63941be0ca8a Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 29 Mar 2023 18:20:11 +0200 Subject: [PATCH 05/17] Improve support of Verilator 5 (install dir choice, Debian10 test failure). --- cva6/regress/install-cva6.sh | 7 ++++++- cva6/regress/install-verilator.sh | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 6faed55696..0470dfb2c9 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -19,11 +19,16 @@ fi # install Verilator # Use historical variable VERILATOR_ROOT to check/specify VL configuration. -if ! [ -n "$VERILATOR_ROOT" ]; then +if [ -z "$VERILATOR_ROOT" ]; then # Verilator installation dir should be separate from the VL source root. # Source code will be unpacked, built and tested in the 'verilator' # subdir of the install dir. export VERILATOR_ROOT=$TOP/verilator-5.008/verilator +fi + +# If the installation directory of Verilator is not set, +# default to the parent directory of the Verilator source. +if [ -z "$VERILATOR_INSTALL_DIR" ]; then export VERILATOR_INSTALL_DIR=$(dirname $VERILATOR_ROOT) fi cva6/regress/install-verilator.sh diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index 9e4cfcbb7a..b2ab5f799d 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -41,7 +41,8 @@ if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then fi # Generate the config script and configure Verilator. autoconf && ./configure --prefix="$VERILATOR_INSTALL_DIR" && make -j${NUM_JOBS} - make test + # 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." From b7a89bf0bad5dbf123c6fffa203679494af94155 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Sun, 2 Apr 2023 20:15:03 +0200 Subject: [PATCH 06/17] Verilator v5: Print install dir at start of install. Allow patch to fail. --- cva6/regress/install-verilator.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index b2ab5f799d..0c7233c62c 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -25,6 +25,7 @@ VERILATOR_PATCH="../../../cva6/regress/verilator-v5.patch" # the installation location of Verilator. if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then echo "Building Verilator in $VERILATOR_ROOT..." + echo "Verilator will be installed in $VERILATOR_INSTALL_DIR" echo "VERILATOR_REPO=$VERILATOR_REPO" echo "VERILATOR_BRANCH=$VERILATOR_BRANCH" echo "VERILATOR_HASH=$VERILATOR_HASH" @@ -37,7 +38,7 @@ if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then [ -d .git ] || git clone $VERILATOR_REPO -b $VERILATOR_BRANCH . git checkout $VERILATOR_HASH if [ ! -z "$VERILATOR_PATCH" ] ; then - git apply $VERILATOR_PATCH + git apply $VERILATOR_PATCH || true fi # Generate the config script and configure Verilator. autoconf && ./configure --prefix="$VERILATOR_INSTALL_DIR" && make -j${NUM_JOBS} From ff0cf769ba476a8e6054254f7d8783c7cbd4a499 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Sun, 2 Apr 2023 20:18:05 +0200 Subject: [PATCH 07/17] Print Verilator install dir in pub_check_env CI job. --- .gitlab-ci/cva6.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index cca0456de5..122234e8bb 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 From dfc252a549f81069305af13f237878dd49d1d334 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Mon, 3 Apr 2023 11:45:26 +0200 Subject: [PATCH 08/17] CI: Capture RTL simulator logs of smoke tests. Report PASS/FAIL via Python script. --- .gitlab-ci/cva6.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index 122234e8bb..98a94050b3 100644 --- a/.gitlab-ci/cva6.yml +++ b/.gitlab-ci/cva6.yml @@ -149,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 -5000 $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 From 597c7e6efa7ef7abc3adbe2937c71f912dec305c Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Mon, 3 Apr 2023 21:23:25 +0200 Subject: [PATCH 09/17] Verilator installer: Track PATH settings. Perform install sanity check. --- cva6/regress/install-cva6.sh | 5 +++++ cva6/regress/install-verilator.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 0470dfb2c9..cab311436c 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -39,6 +39,11 @@ export LD_LIBRARY_PATH=$RISCV/lib export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include +# Check proper Verilator installation given current $PATH. +echo PATH=\"$PATH\" +echo "Verilator version:" +verilator --version + # number of parallel jobs to use for make commands and simulation export NUM_JOBS=24 diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index 0c7233c62c..1d15911ebb 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -49,5 +49,5 @@ if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then #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 From 91d440fd740f83184a91b85983837456d602216e Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Mon, 3 Apr 2023 21:43:53 +0200 Subject: [PATCH 10/17] CI (pub_smoke): Extend log snapshots to 10k lines. --- .gitlab-ci/cva6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index 98a94050b3..4dd07533fe 100644 --- a/.gitlab-ci/cva6.yml +++ b/.gitlab-ci/cva6.yml @@ -157,7 +157,7 @@ pub_smoke: # 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 -5000 $i > artifacts/logs/$(basename $i).head ; done + - 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 From 64ab7d5fc99cbdda41827638bac80f4c2e08544d Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Mon, 3 Apr 2023 21:45:55 +0200 Subject: [PATCH 11/17] Verilator: Unset VERILATOR_ROOT to forcibly search verilator_bin in $PATH. --- cva6/regress/install-cva6.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index cab311436c..6c0dac09cc 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -33,6 +33,12 @@ if [ -z "$VERILATOR_INSTALL_DIR" ]; then fi cva6/regress/install-verilator.sh +# With Verilator v5, it is (FORNOW) necessary to either maintain a copy +# of the source+build directory at $VERILATOR_ROOT, or to unset VERILATOR_ROOT +# so that 'verilator_bin' is searched in the PATH. The former is not +# applicable to Continuous Integration environments, so... +unset VERILATOR_ROOT + export PATH=$RISCV/bin:$VERILATOR_INSTALL_DIR/bin:$PATH export LIBRARY_PATH=$RISCV/lib export LD_LIBRARY_PATH=$RISCV/lib From 00abb1ff62a6f9335c92dce4272cfff448a5358f Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Tue, 4 Apr 2023 18:05:29 +0200 Subject: [PATCH 12/17] Installers: Get rid of VERILATOR_ROOT, improve operation and error checks. --- cva6/regress/install-cva6.sh | 28 ++++++-------------- cva6/regress/install-verilator.sh | 43 +++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 6c0dac09cc..289b0defed 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -13,33 +13,21 @@ 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 -# Use historical variable VERILATOR_ROOT to check/specify VL configuration. -if [ -z "$VERILATOR_ROOT" ]; then - # Verilator installation dir should be separate from the VL source root. - # Source code will be unpacked, built and tested in the 'verilator' - # subdir of the install dir. - export VERILATOR_ROOT=$TOP/verilator-5.008/verilator -fi +# Install Verilator v5. +cva6/regress/install-verilator.sh -# If the installation directory of Verilator is not set, -# default to the parent directory of the Verilator source. +# Complain if the installation directory of Verilator still is not set +# after running the installer. if [ -z "$VERILATOR_INSTALL_DIR" ]; then - export VERILATOR_INSTALL_DIR=$(dirname $VERILATOR_ROOT) + echo "Error: VERILATOR_INSTALL_DIR variable still undefined after running Verilator installer." + return fi -cva6/regress/install-verilator.sh - -# With Verilator v5, it is (FORNOW) necessary to either maintain a copy -# of the source+build directory at $VERILATOR_ROOT, or to unset VERILATOR_ROOT -# so that 'verilator_bin' is searched in the PATH. The former is not -# applicable to Continuous Integration environments, so... -unset VERILATOR_ROOT -export PATH=$RISCV/bin:$VERILATOR_INSTALL_DIR/bin:$PATH +export PATH=$RISCV/bin:$PATH export LIBRARY_PATH=$RISCV/lib export LD_LIBRARY_PATH=$RISCV/lib export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index 1d15911ebb..c676f1118d 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -13,25 +13,48 @@ if [ -z ${NUM_JOBS} ]; then NUM_JOBS=1 fi +# 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="../../../cva6/regress/verilator-v5.patch" +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 -# VERILATOR_ROOT must point to the root of the Verilator source tree. -# This is not necessarily the installation prefix. -# The two should be kept separate ==> use VERILATOR_INSTALL_DIR to specify -# the installation location of Verilator. +# 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_ROOT..." + 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_ROOT - cd $VERILATOR_ROOT + 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. @@ -51,3 +74,7 @@ if [ ! -f "$VERILATOR_INSTALL_DIR/bin/verilator" ]; then else echo "Using Verilator from cached directory $VERILATOR_INSTALL_DIR." fi + +# Update PATH to match the verilator installation. +export PATH="$VERILATOR_INSTALL_DIR/bin:$PATH" + From c469e750a3732ad0724b5c689baa08040343aa98 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Tue, 4 Apr 2023 18:55:08 +0200 Subject: [PATCH 13/17] Verilator installation: Force addition of Verilator 'bin' dir to PATH. --- cva6/regress/install-cva6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 289b0defed..73663f1658 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -27,7 +27,7 @@ if [ -z "$VERILATOR_INSTALL_DIR" ]; then return fi -export PATH=$RISCV/bin:$PATH +export PATH=$RISCV/bin:$VERILATOR_INSTALL_DIR/bin:$PATH export LIBRARY_PATH=$RISCV/lib export LD_LIBRARY_PATH=$RISCV/lib export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include From 707a7ff9910d8b9f4a7a331af09994acccdbdc70 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Tue, 4 Apr 2023 18:57:31 +0200 Subject: [PATCH 14/17] Stop the core-v-verif CVA6 installer if Verilator is not in $PATH. --- cva6/regress/install-cva6.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index 73663f1658..f16be1f267 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -36,7 +36,7 @@ export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/ # Check proper Verilator installation given current $PATH. echo PATH=\"$PATH\" echo "Verilator version:" -verilator --version +verilator --version || { echo "Error: Verilator not in \$PATH." ; return ; } # number of parallel jobs to use for make commands and simulation export NUM_JOBS=24 From 2afb29916b841a42ad5627798d40b1f836ff8248 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 5 Apr 2023 17:15:52 +0200 Subject: [PATCH 15/17] Provide way of disabling Verilator and/or Spike setup for specific CI jobs. * cva6/regress/install-cva6.sh: Disable Verilator setup if the install dir variable has value 'NO'. Refactor the flow of variable definitions in presence of Verilator. Add informative messages. * cva6/regress/install-spike.sh: Disable Spike setup if variable SPIKE_ROOT has value 'NO'. Update message printed upon reusing an existing Spike installation. --- cva6/regress/install-cva6.sh | 46 ++++++++++++++++++++++------------- cva6/regress/install-spike.sh | 12 ++++++--- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index f16be1f267..c563adcb03 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -9,7 +9,7 @@ # 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 @@ -17,26 +17,38 @@ if ! [ -n "$RISCV" ]; then return fi +# 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. -cva6/regress/install-verilator.sh +# 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 + # 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 -export PATH=$RISCV/bin:$VERILATOR_INSTALL_DIR/bin:$PATH -export LIBRARY_PATH=$RISCV/lib -export LD_LIBRARY_PATH=$RISCV/lib -export C_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include -export CPLUS_INCLUDE_PATH=$RISCV/include:$VERILATOR_INSTALL_DIR/share/verilator/include + # 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" -# Check proper Verilator installation given current $PATH. -echo PATH=\"$PATH\" -echo "Verilator version:" -verilator --version || { echo "Error: Verilator not in \$PATH." ; return ; } + # 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 From f2f6e23883d73dc12f16f2956171850eece4d7e9 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 5 Apr 2023 17:19:56 +0200 Subject: [PATCH 16/17] CI: Disable installation/checks of Verilator and Spike for FPGA boot job. * .gitlab-ci/cva6.yml (pub_fpga-boot): Use new mechanism of disabling the setup and checks of Verilator and Spike. Replace VERILATOR_ROOT with VERILATOR_INSTALL_DIR. --- .gitlab-ci/cva6.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index 4dd07533fe..410634f50c 100644 --- a/.gitlab-ci/cva6.yml +++ b/.gitlab-ci/cva6.yml @@ -522,8 +522,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 From 046a50d58648bafdb2263dee53e1043e83057284 Mon Sep 17 00:00:00 2001 From: Zbigniew Chamski Date: Wed, 5 Apr 2023 17:33:15 +0200 Subject: [PATCH 17/17] CI: Force the use of '--no-timing' option for Verilator tests of WB cache. * .gitlab-ci/cva6.yml (pub_wb_cache): Pass the '--no-timing' option as part of user definition of the 'verilator' variable. --- .gitlab-ci/cva6.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/cva6.yml b/.gitlab-ci/cva6.yml index 410634f50c..ea02e05dfb 100644 --- a/.gitlab-ci/cva6.yml +++ b/.gitlab-ci/cva6.yml @@ -433,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: