Skip to content

Commit

Permalink
Merge pull request openhwgroup#1765 from zchamski/cvvdev/dev/verilato…
Browse files Browse the repository at this point in the history
…r-v5

Switch Verilator testing to use v5.008 instead of v4.110
  • Loading branch information
JeanRochCoulon authored Apr 6, 2023
2 parents 8d6a427 + 046a50d commit a2b8835
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 36 deletions.
18 changes: 13 additions & 5 deletions .gitlab-ci/cva6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
45 changes: 33 additions & 12 deletions cva6/regress/install-cva6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions cva6/regress/install-spike.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

78 changes: 63 additions & 15 deletions cva6/regress/install-verilator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

26 changes: 26 additions & 0 deletions cva6/regress/verilator-v5.patch
Original file line number Diff line number Diff line change
@@ -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]; }
2 changes: 1 addition & 1 deletion cva6/sim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a2b8835

Please sign in to comment.