-
Notifications
You must be signed in to change notification settings - Fork 1
/
runme.sh
executable file
·94 lines (80 loc) · 2.44 KB
/
runme.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
#!/usr/bin/env bash
set -e
#------------------------------------------------------------------------------
# Variables and setup
#------------------------------------------------------------------------------
test_ret=0
do_clean=0
# Use Icarus Verilog simulator
[[ -z $SIM ]] && SIM="icarus"
#------------------------------------------------------------------------------
# Grab arguments and values
#------------------------------------------------------------------------------
get_args() {
while [ "$1" != "" ]; do
case $1 in
-s | --simulator )
shift
SIM=$1
;;
-c | --clean )
do_clean=1
;;
-h | --help )
usage
exit 0
;;
* )
usage
exit 1
;;
esac
shift
done
}
#------------------------------------------------------------------------------
# Cleaner
#------------------------------------------------------------------------------
clean() {
echo "Clean-up"
rm -f "*.txt"
rm -f icarus.out
rm -fr build
}
#------------------------------------------------------------------------------
# Helper
#------------------------------------------------------------------------------
usage() {
cat << EOF
usage: bash ./run.sh ...
-c | --clean Clean-up and exit
-s | --simulator Choose between icarus or verilator (icarus is default)
-h | --help Brings up this menu
--simulator Choose between icarus or verilator (icarus is default)
EOF
}
compile() {
if [ "$SIM" == "icarus" ]; then
iverilog -g2012 -Wall -o icarus.out -f files.f fsm_example_testbench.sv ; vvp icarus.out
else
verilator -Wall --trace --Mdir build +1800-2017ext+sv \
+1800-2005ext+v -Wno-STMTDLY -Wno-UNUSED -Wno-UNDRIVEN -Wno-PINCONNECTEMPTY \
-Wpedantic -Wno-VARHIDDEN -Wno-lint \
+incdir+. -f files.f \
-cc --exe --build -j --top-module fsm_example_testbench \
fsm_example_testbench.sv sim_main.cpp
./build/Vfsm_example_testbench
fi
}
#------------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------------
main() {
get_args "$@"
if [ $do_clean -eq 1 ]; then
clean
else
compile
fi
}
main "$@"