-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake
65 lines (55 loc) · 1.23 KB
/
make
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
#!/bin/bash
TOP_VERILOG_FILE="top_sim_testbench"
INST_ASM_FILE="test/inst.asm"
IVERILOG_CC="iverilog"
VVP_CC="vvp"
RM_CC="rm -rf"
function printmsg() {
echo -e "\033[36m$1\033[0m"
}
function printerror() {
echo -e "\033[31m$1\033[0m"
}
function run_test() {
$IVERILOG_CC -o "$1.vvp" \
"$1.v" && \
$VVP_CC "$1.vvp"
}
function transform() {
node transform.js "$INST_ASM_FILE" $@
}
function clean() {
$RM_CC *.vvp
$RM_CC *.vcd
$RM_CC *.out
}
if [ "$1" == "clean" ]; then
printmsg "Cleaning..."
clean && \
exit 0
elif [ "$1" == "inst" ]; then
printmsg "Analyzing instruction file..."
transform ${@:2} && \
exit 0
elif [ "$1" == "test" ]; then
printmsg "Running test..."
run_test "$TOP_VERILOG_FILE" && \
exit 0
elif [ "$1" == "" ]; then
printmsg "Analyzing instruction file..."
transform ${@:2} && \
printmsg "Running \"$TOP_VERILOG_FILE.v\" ..." && \
run_test "$TOP_VERILOG_FILE" && \
exit 0
else
if [[ "$1" =~ \.v$ ]]; then
TOP_VERILOG_FILE=${1%.*}
else
TOP_VERILOG_FILE=$1
fi
printmsg "Running \"$TOP_VERILOG_FILE.v\" ..." && \
run_test "$TOP_VERILOG_FILE" && \
exit 0
fi
printerror "\033[31mFailed\033[0m"
exit 1