-
Notifications
You must be signed in to change notification settings - Fork 4
/
flow.sh
executable file
·279 lines (227 loc) · 7.08 KB
/
flow.sh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/usr/bin/env bash
# -e: exit if one command fails
# -u: treat unset variable as an error
# -f: disable filename expansion upon seeing *, ?, ...
# -o pipefail: causes a pipeline to fail if any command fails
set -e -o pipefail
# Current script path; doesn't support symlink
FRISCV_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Bash color codes
Red='\033[0;31m'
Green='\033[0;32m'
Yellow='\033[0;33m'
Blue='\033[0;34m'
# Reset
NC='\033[0m'
TB="all"
SIMULATOR="all"
function printerror {
echo -e "${Red}ERROR: ${1}${NC}"
}
function printwarning {
echo -e "${Yellow}WARNING: ${1}${NC}"
}
function printinfo {
echo -e "${Blue}INFO: ${1}${NC}"
}
function printsuccess {
echo -e "${Green}SUCCESS: ${1}${NC}"
}
help() {
echo -e "${Blue}"
echo ""
echo "NAME"
echo ""
echo " FRISCV Flow"
echo ""
echo "SYNOPSIS"
echo ""
echo " ./flow.sh -h"
echo ""
echo " ./flow.sh help"
echo ""
echo " ./flow.sh syn"
echo ""
echo " ./flow.sh sim"
echo ""
echo "DESCRIPTION"
echo ""
echo " This flow handles the different operations available"
echo ""
echo " ./flow.sh help|-h"
echo ""
echo " Print the help menu"
echo ""
echo " ./flow.sh syn"
echo ""
echo " Launch the synthesis script relying on Yosys"
echo ""
echo " ./flow.sh sim"
echo ""
echo " List all available testsuites and options"
echo ""
echo " ./flow.sh sim wba-testsuite core icarus"
echo ""
echo " Run a specific testsuite using a particular testbench and simulator"
echo ""
echo -e "${NC}"
}
run_sims() {
# Run all simulation specified for CI run
# rm -f rtl.md5 force to rebuild the testbench and the sources
if [[ $1 == "core" ]] || [[ $1 == "all" ]]; then
if [[ $2 == "icarus" ]] || [[ $2 == "all" ]]; then
rm -f rtl.md5 && ./run.sh --simulator icarus --tb core --nocompile 1 --timeout 100000
fi
if [[ $2 == "verilator" ]] || [[ $2 == "all" ]]; then
rm -f rtl.md5 && ./run.sh --simulator verilator --tb core --nocompile 1 --timeout 100000
fi
fi
if [[ $1 == "platform" ]] || [[ $1 == "all" ]]; then
if [[ $2 == "icarus" ]] || [[ $2 == "all" ]]; then
rm -f rtl.md5 && ./run.sh --simulator icarus --tb platform --nocompile 1 --timeout 100000
fi
if [[ $2 == "verilator" ]] || [[ $2 == "all" ]]; then
rm -f rtl.md5 && ./run.sh --simulator verilator --tb platform --nocompile 1 --timeout 100000
fi
fi
}
print_testsuites() {
printerror "Plese specify a testsuite to run:"
echo " - wba-testsuite"
echo " - riscv-testsuite"
echo " - c-testsuite"
echo " - sv-testsuite"
echo " - all"
echo ""
printerror "Other options:"
echo " - core or platform (default both)"
echo " - icarus or verilator (default both)"
exit 1
}
check_setup() {
source script/setup.sh
if [[ ! $(type iverilog) ]]; then
printerror "Icarus-Verilog is not installed"
exit 1
fi
if [[ ! $(type verilator) ]]; then
printerror "Verilator is not installed"
exit 1
fi
}
main() {
echo ""
printinfo "Start FRISCV Flow"
# If no argument provided, preint help and exit
if [[ $# -eq 0 ]]; then
help
exit 1
fi
# Print help
if [[ $1 == "-h" || $1 == "help" ]]; then
help
exit 0
fi
if [[ $1 == "lint" ]]; then
set +e
printinfo "Start Verilator linting"
verilator --lint-only +1800-2017ext+sv \
-Wall -Wpedantic \
-Wno-VARHIDDEN \
-Wno-PINCONNECTEMPTY \
-Wno-PINMISSING \
-I./rtl\
-I./dep/svlogger\
./rtl/friscv_h.sv\
./rtl/friscv_rv32i_core.sv\
./rtl/friscv_control.sv\
./rtl/friscv_decoder.sv\
./rtl/friscv_pipeline.sv\
./rtl/friscv_alu.sv\
./rtl/friscv_processing.sv\
./rtl/friscv_memfy.sv\
./rtl/friscv_registers.sv\
./rtl/friscv_m_ext.sv\
./rtl/friscv_csr.sv\
./rtl/friscv_scfifo.sv\
./rtl/friscv_ram.sv\
./rtl/friscv_rambe.sv\
./rtl/friscv_dcache.sv\
./rtl/friscv_icache.sv\
./rtl/friscv_cache_block_fetcher.sv\
./rtl/friscv_cache_io_fetcher.sv\
./rtl/friscv_cache_ooo_mgt.sv\
./rtl/friscv_cache_pusher.sv\
./rtl/friscv_cache_blocks.sv\
./rtl/friscv_cache_memctrl.sv\
./rtl/friscv_axi_or_tracker.sv\
--top-module friscv_rv32i_core 2> lint.log
set -e
ec=$(grep -c "%Error:" lint.log)
if [[ $ec -gt 1 ]]; then
printerror "Lint failed, check ./lint.log for further details"
exit 1
else
printsuccess "Lint ran successfully"
exit 0
fi
fi
if [[ $1 == "sim" ]]; then
check_setup
[[ -z "$2" ]] && print_testsuites
[[ -n $3 ]] && TB="$3"
[[ -n $4 ]] && SIMULATOR="$4"
if [ "$2" == "wba-testsuite" ] || [ "$2" == "all" ]; then
echo ""
printinfo "Start WBA Simulation flow"
cd "${FRISCV_DIR}/test/wba_testsuite"
run_sims "$TB" "$SIMULATOR"
fi
if [ "$2" == "riscv-testsuite" ] || [ "$2" == "all" ]; then
echo ""
printinfo "Start RISCV Compliance flow"
cd "${FRISCV_DIR}/test/riscv-tests"
run_sims "$TB" "$SIMULATOR"
fi
if [ "$2" == "c-testsuite" ] || [ "$2" == "all" ]; then
echo ""
printinfo "Start C Simulation flow"
cd "${FRISCV_DIR}/test/c_testsuite"
run_sims "$TB" "$SIMULATOR"
fi
if [ "$2" == "priv_sec-testsuite" ] || [ "$2" == "all" ]; then
echo ""
printinfo "Start Privilege/Security Simulation flow"
cd "${FRISCV_DIR}/test/priv_sec_testsuite"
run_sims "$TB" "$SIMULATOR"
fi
if [ "$2" == "sv-testsuite" ] || [ "$2" == "all" ]; then
echo ""
printinfo "Start SV Simulation flow"
cd "${FRISCV_DIR}/test/sv"
./run.sh -c
./run.sh -m 10000 --timeout 100000 --tb "icache_testbench.sv"
./run.sh -c
./run.sh -m 10000 --timeout 100000 --tb "dcache_testbench.sv"
fi
exit 0
fi
if [[ $1 == "syn" ]]; then
ret=0
printinfo "Start synthesis flow"
cd "$FRISCV_DIR/syn/yosys"
echo "------------------------------------"
echo " Run ASIC synthesis"
echo "------------------------------------"
./syn_asic.sh | tee "$FRISCV_DIR/syn_asic.log"
ret=$((ret+$?))
echo "------------------------------------"
echo " Run Xilinx XC7 synthesis"
echo "------------------------------------"
./syn_x7.sh | tee "$FRISCV_DIR/syn_x7.log"
ret=$((ret+$?))
return $ret
fi
}
main "$@"