blob: 6d6eee87f8206281a4237ba615e053119595cb19 [file] [log] [blame]
#!/usr/bin/env bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Script to run the assembly tests generated by the riscv-dv instruction generator.
# Test directory
RUN_DIR="./"
# Assembly test file name
TEST=""
# Seed
RAND_SEED=1
SEED=""
# Wavform dump options
WAVES=0
WAVES_OPTS=""
# Coveragedump options
COV=0
COV_OPTS=""
# Process command line options
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-dir)
RUN_DIR="$2"
shift
;;
-test)
TEST="$2"
shift
;;
-waves)
WAVES="$2"
shift
;;
-cov)
COV="$2"
shift
;;
-seed)
SEED="$2"
RAND_SEED=0
shift
;;
*)
echo "unknown option $1"
exit 1
;;
esac
shift
done
# If the test is specified through "-test" option, run a single test rather
# than all tests under RUN_DIR.
if [[ $TEST == "" ]]; then
find "$RUN_DIR" -name "*.S" > "$RUN_DIR/asm_test_list"
else
echo "$TEST" > "$RUN_DIR/asm_test_list"
fi
OUT="$RUN_DIR/rtl_sim"
CWD=`pwd`
# Run each test
while read asm_test; do
OPTS=""
SRC=$(echo "$asm_test" | sed 's/^.*\///g' | sed 's/\.S>*$//g')
BINFILE="$asm_test.bin"
mkdir -p $OUT/$SRC
cd $OUT/$SRC
if [[ $RAND_SEED == 1 ]]; then
SEED=$RANDOM
fi
if [[ $WAVES == 1 ]]; then
WAVES_OPTS="-ucli -do $CWD/vcs.tcl"
fi
if [[ $COV == 1 ]]; then
COV_OPTS="-cm line+tgl+assert+fsm+branch \
-cm_dir ${RUN_DIR}/rtl_sim/test.vdb \
-cm_log /dev/null \
-assert nopostproc \
-cm_name test_${SEED}"
fi
if [[ "$BINFILE" =~ "ebreak" ]]; then
OPTS="+enable_debug_seq=1"
fi
if [[ "$BINFILE" =~ "wfi" ]]; then
OPTS="+enable_irq_seq=1"
fi
CMD="$OUT/vcs_simv +UVM_TESTNAME=core_ibex_base_test \
${WAVES_OPTS} +ntb_random_seed=${SEED} +vcs+lic+wait ${COV_OPTS}\
+UVM_MAX_QUIT_COUNT=5 +bin=$BINFILE -l sim.log ${OPTS}"
echo "Running simulation for : $CMD"
$CMD
done <"$RUN_DIR/asm_test_list"