diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index c563adcb03..9cce6fffd2 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -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 $(dirname "${BASH_SOURCE[0]}")/../../) 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. @@ -28,13 +40,13 @@ 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. @@ -42,8 +54,6 @@ if [ "$VERILATOR_INSTALL_DIR" != "NO" ]; then 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 @@ -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" @@ -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 diff --git a/cva6/regress/install-riscv-dv.sh b/cva6/regress/install-riscv-dv.sh index 9a643c9820..e4d468e576 100755 --- a/cva6/regress/install-riscv-dv.sh +++ b/cva6/regress/install-riscv-dv.sh @@ -9,10 +9,10 @@ # 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 @@ -20,7 +20,7 @@ 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 diff --git a/cva6/regress/install-spike.sh b/cva6/regress/install-spike.sh index c389e32a8b..0e21d61213 100755 --- a/cva6/regress/install-spike.sh +++ b/cva6/regress/install-spike.sh @@ -10,7 +10,7 @@ set -e VERSION="e93b9cbbbcd3ad0a02ae298e9f1a2d98d3ac0153" -if [ -z ${NUM_JOBS} ]; then +if [ -z "$NUM_JOBS" ]; then NUM_JOBS=1 fi @@ -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 @@ -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 - diff --git a/cva6/regress/install-verilator.sh b/cva6/regress/install-verilator.sh index c676f1118d..becedcfa90 100755 --- a/cva6/regress/install-verilator.sh +++ b/cva6/regress/install-verilator.sh @@ -9,7 +9,7 @@ set -e -if [ -z ${NUM_JOBS} ]; then +if [ -z "$NUM_JOBS" ]; then NUM_JOBS=1 fi @@ -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 diff --git a/cva6/regress/smoke-tests.sh b/cva6/regress/smoke-tests.sh index 064b5d8711..1fa832e906 100644 --- a/cva6/regress/smoke-tests.sh +++ b/cva6/regress/smoke-tests.sh @@ -10,7 +10,7 @@ # where are the tools if ! [ -n "$RISCV" ]; then echo "Error: RISCV variable undefined" - return + exit fi # install the required tools diff --git a/cva6/sim/Makefile b/cva6/sim/Makefile index 23fcf205ef..2ee006ec68 100644 --- a/cva6/sim/Makefile +++ b/cva6/sim/Makefile @@ -110,7 +110,7 @@ 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 @@ -118,7 +118,7 @@ vcs-testharness: 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