forked from chipsalliance/riscv-dv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·146 lines (126 loc) · 3.56 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/bin/bash
# This is simple run script to run a dedicated test or a regression
#
# Usage:
# Run a single test with irun
# ./run -tool irun -test riscv_instr_base_test
#
# Run regression with vcs
# ./run -test all
#
# Change output directory
# ./run -out my_output_dir
DATE=`date +%Y-%m-%d`
# RTL simulator, support vcs and irun
SIMULATOR="vcs"
# random seed
SEED=`date +%s`
# Test name, "all" means run all tests in the testlist
TEST="riscv_instr_base_test"
# Number of assembly programs to be generated for this test
# This option only apply to single test mode. For the regression mode, the number is specified in
# the testlist
NUM_TESTS=1
# Simulation output directory
OUT="./out_${DATE}"
# Process command line options
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-tool)
SIMULATOR="$2"
shift
;;
-test)
TEST="$2"
shift
;;
-n)
NUM_TESTS="$2"
shift
;;
-seed)
SEED="$2"
shift
;;
-o)
OUT="$2"
shift
;;
*)
echo "unknown option $1"
return
;;
esac
shift
done
# Generate compile and simulation commands
if [[ "$SIMULATOR" == "vcs" ]]; then
COMPILE_CMD="vcs -file ./vcs.compile.option.f \
-f ./files.f -full64 \
-l $OUT/compile.log \
-Mdir=$OUT/vcs_simv.csrc \
-o $OUT/vcs_simv"
SIM_CMD="$OUT/vcs_simv +UVM_TESTNAME="
elif [[ "$SIMULATOR" == "irun" ]]; then
COMPILE_CMD="irun -64bit \
-access +rwc \
-f ./files.f \
-q -sv -uvm \
-vlog_ext +.vh -I. \
-uvmhome CDNS-1.2 \
-l ${OUT}/compile.log"
SIM_CMD="irun -R +UVM_TESTNAME="
else
echo "unsupported simulator $SIMULATOR"
return
fi
# Clean up previous runs
rm -rf ${OUT}
mkdir -p ${OUT}
mkdir -p ${OUT}/asm_tests
# Compilation
${COMPILE_CMD}
# Run sim
if [[ ${TEST} == "all" ]]; then
echo "Running regression with testlist:"
cat testlist
while read line; do
if ! [[ $line =~ ^\/\/ ]]; then
if [[ $line =~([a-z0-9_-]*)([[:space:]]*)\:([[:space:]]*)([0-9]*) ]]; then
SEED=`date +%s`
TEST=${BASH_REMATCH[1]}
ITERATION=${BASH_REMATCH[4]}
echo "Running ${TEST}, iteration count: ${ITERATION}"
${SIM_CMD}${TEST} +asm_file_name=${OUT}/asm_tests/${TEST} \
+ntb_random_seed=${SEED} \
-l ${OUT}/sim_${TEST}.log +num_of_tests=${ITERATION}
fi
fi
done < testlist
else
echo "Running test ${TEST} with $SIMULATOR.."
${SIM_CMD}${TEST} +asm_file_name=${OUT}/asm_tests/${TEST} \
+ntb_random_seed=${SEED} \
-l ${OUT}/sim_${TEST}.log \
+num_of_tests=${NUM_TESTS}
fi
# List all generated assembly tests
echo "==========================================================="
echo " Generated RISC-V assembly tests"
echo " ----------------------------------------------------------"
find $OUT/asm_tests -name "*.S" | sort -k11