Skip to content

Commit

Permalink
CVA6: Infrastructure improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioOpenHWGroup committed May 3, 2023
1 parent 320e46f commit 1657b98
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
37 changes: 23 additions & 14 deletions cva6/regress/install-cva6.sh
Expand Up @@ -8,13 +8,25 @@
# Original Author: Jean-Roch COULON - Thales

# Customise this to a fast local disk
export ROOT_PROJECT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../../" && pwd)
export ROOT_PROJECT=$(readlink -f .)
export TOP="$ROOT_PROJECT/tools"

# where to install the tools
if ! [ -n "$RISCV" ]; then
if [ -z "$RISCV" ]; then
echo "Error: RISCV variable undefined."
return
exit
fi

if [ -z "$CV_SW_PREFIX" ]; then
export CV_SW_PREFIX="$(ls -1 -r $RISCV/bin/riscv*-gcc | head -n 1| grep gcc | rev | cut -d '/' -f 1 | cut -d '-' -f 2- | rev)-"
fi

if [ -z "$RISCV_GCC" ]; then
export RISCV_GCC=$RISCV/bin/${CV_SW_PREFIX}gcc
fi

if [ -z "$RISCV_OBJCOPY" ]; then
export RISCV_OBJCOPY=$RISCV/bin/${CV_SW_PREFIX}objcopy
fi

# Set up tool-related variables.
Expand All @@ -28,22 +40,20 @@ export CPLUS_INCLUDE_PATH="$RISCV/include"
# 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
source 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
exit
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"

# Check proper Verilator installation given current $PATH.
echo PATH=\"$PATH\"
echo "Verilator version:"
verilator --version || { echo "Error: Verilator not in \$PATH." ; return ; }
else
Expand All @@ -54,7 +64,7 @@ fi
export NUM_JOBS=24

# install the required tools for cva6
if ! [ -n "$CVA6_REPO" ]; then
if [ -z "$CVA6_REPO" ]; then
CVA6_REPO="https://github.com/openhwgroup/cva6.git"
CVA6_BRANCH="master"
CVA6_HASH="75807530f26ba9a0ca501e9d3a6575ec375ed7ab"
Expand All @@ -67,16 +77,15 @@ echo $CVA6_PATCH

if ! [ -d core-v-cores/cva6 ]; then
git clone --recursive $CVA6_REPO -b $CVA6_BRANCH core-v-cores/cva6
cd core-v-cores/cva6; git checkout $CVA6_HASH;
git -C core-v-cores/cva6 checkout $CVA6_HASH
echo -n "Using CVA6 commit "; git describe --always HEAD
if [ -f ../$CVA6_PATCH ]; then
git apply ../$CVA6_PATCH
if [ -f $CVA6_PATCH ]; then
git -C core-v-cores/cva6 apply $CVA6_PATCH
fi
cd -
fi

# install Spike
if ! [ -n "$SPIKE_ROOT" ]; then
if [ -z "$SPIKE_ROOT" ]; then
export SPIKE_ROOT=$TOP/spike/
fi
cva6/regress/install-spike.sh
source cva6/regress/install-spike.sh
6 changes: 3 additions & 3 deletions cva6/regress/install-riscv-dv.sh
Expand Up @@ -9,18 +9,18 @@

# riscv-dv env variables
export RISCV_TOOLCHAIN=$RISCV
if ! [ -n "$RISCV_GCC" ]; then
if [ -z "$RISCV_GCC" ]; then
export RISCV_GCC="$RISCV_TOOLCHAIN/bin/riscv-none-elf-gcc"
fi
if ! [ -n "$RISCV_OBJCOPY" ]; then
if [ -z "$RISCV_OBJCOPY" ]; then
export RISCV_OBJCOPY="$RISCV_TOOLCHAIN/bin/riscv-none-elf-objcopy"
fi
export SPIKE_PATH=$SPIKE_ROOT/bin
export RTL_PATH=$ROOT_PROJECT/core-v-cores/cva6
export TB_PATH=$ROOT_PROJECT/cva6/tb/core
export TESTS_PATH=$ROOT_PROJECT/cva6/tests

if ! [ -n "$DV_REPO" ]; then
if [ -z "$DV_REPO" ]; then
export DV_REPO="https://github.com/google/riscv-dv.git"
export DV_BRANCH=master
export DV_HASH=96c1ee6f371f2754c45b4831fcab95f6671689d9
Expand Down
10 changes: 4 additions & 6 deletions cva6/regress/install-spike.sh
Expand Up @@ -10,7 +10,7 @@
set -e
VERSION="e93b9cbbbcd3ad0a02ae298e9f1a2d98d3ac0153"

if [ -z ${NUM_JOBS} ]; then
if [ -z "$NUM_JOBS" ]; then
NUM_JOBS=1
fi

Expand All @@ -21,13 +21,13 @@ if [ "$SPIKE_ROOT" = "NO" ]; then
else
if [ ! -f "$SPIKE_ROOT/bin/spike" ]; then
echo "Installing Spike"
PATCH_DIR=`pwd`/cva6/regress
PATCH_DIR=$(pwd)/cva6/regress
mkdir -p $SPIKE_ROOT
cd $SPIKE_ROOT
git clone https://github.com/riscv/riscv-isa-sim.git
cd riscv-isa-sim
git checkout $VERSION
# Apply Spike patches.
# Apply Spike patches (GCC > 4.8)
git apply $PATCH_DIR/spike/patches/spike-shared-fesvr-lib.patch
git apply $PATCH_DIR/spike/patches/spike-cvxif-extension.patch
git apply $PATCH_DIR/spike/patches/spike-dlopen-diagnostics.patch
Expand All @@ -38,10 +38,8 @@ else
mkdir -p build
cd build
../configure --enable-commitlog --prefix="$SPIKE_ROOT"
make -j${NUM_JOBS}
make install
make -j${NUM_JOBS} install
else
echo "Using Spike from cached directory $SPIKE_ROOT."
fi
fi

4 changes: 2 additions & 2 deletions cva6/regress/install-verilator.sh
Expand Up @@ -9,7 +9,7 @@

set -e

if [ -z ${NUM_JOBS} ]; then
if [ -z "$NUM_JOBS" ]; then
NUM_JOBS=1
fi

Expand Down Expand Up @@ -41,7 +41,7 @@ fi
# 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})
export VERILATOR_INSTALL_DIR="$(dirname $VERILATOR_BUILD_DIR)"
fi

# Build and install Verilator only if not already installed at the expected
Expand Down
2 changes: 1 addition & 1 deletion cva6/regress/smoke-tests.sh
Expand Up @@ -10,7 +10,7 @@
# where are the tools
if ! [ -n "$RISCV" ]; then
echo "Error: RISCV variable undefined"
return
exit
fi

# install the required tools
Expand Down
4 changes: 2 additions & 2 deletions cva6/sim/Makefile
Expand Up @@ -110,15 +110,15 @@ spike:
vcs-testharness:
make -C $(path_var) vcs_build target=$(target) defines=$(subst +define+,,$(isscomp_opts))
$(path_var)/work-vcs/simv $(if $(VERDI), -verdi -do $(path_var)/init_testharness.do,) +permissive -sv_lib $(path_var)/work-dpi/ariane_dpi \
+tohost_addr=$(shell $$RISCV/bin/riscv-none-elf-nm -B $(elf) | grep -w tohost | cut -d' ' -f1) \
+tohost_addr=$(shell $$RISCV/bin/${CV_SW_PREFIX}nm -B $(elf) | grep -w tohost | cut -d' ' -f1) \
+PRELOAD=$(elf) +permissive-off ++$(elf) $(issrun_opts)
$(tool_path)/spike-dasm --isa=$(variant) < ./trace_rvfi_hart_00.dasm > $(log)
grep $(isspostrun_opts) ./trace_rvfi_hart_00.dasm

veri-testharness:
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)
+tohost_addr=$(shell $$RISCV/bin/${CV_SW_PREFIX}nm -B $(elf) | grep -w tohost | cut -d' ' -f1)
$(tool_path)/spike-dasm --isa=$(variant) < ./trace_rvfi_hart_00.dasm > $(log)
# If present, move default trace files to per-test directory.
[ ! -f verilator.fst ] || mv verilator.fst `dirname $(log)`/`basename $(log) .log`.$(target).fst
Expand Down

0 comments on commit 1657b98

Please sign in to comment.