-
Notifications
You must be signed in to change notification settings - Fork 38
/
sim-module
executable file
·67 lines (54 loc) · 1.38 KB
/
sim-module
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
#!/bin/bash
set -o errexit
# Should give an arg
if [ $# == 0 ]
then
echo "? executes the testbench for the module"
echo "syntax:"
echo " ./sim-module <module-name>"
exit
fi
# create sim scratch work directory
test -d sim/scratch && rm -rf sim/scratch
mkdir -p sim/scratch/src
# copy verilog code files from hdl directory into sim work dir
for FILE in $(find ./hdl/* -name "*.v" -type f -print)
do
cp -n $FILE ./sim/scratch/src/ || { echo "ERROR duplicate filename ${FILE}" ; exit 1; }
done
# copy verilog header files from hdl directory into sim work dir
for FILE in $(find ./hdl/*/ -name "*.vh" -type f -print)
do
cp -n $FILE ./sim/scratch/src/ || { echo "ERROR duplicate filename ${FILE}" ; exit 1; }
done
# copy SystemVerilog code files from hdl directory into sim work dir
for FILE in $(find ./hdl/*/ -name "*.sv" -type f -print)
do
cp -n $FILE ./sim/scratch/src/ || { echo "ERROR duplicate filename ${FILE}" ; exit 1; }
done
# cd into the working dir
cd sim/scratch/src
# UUT should contain the name of the unit under test
if [ -f $1_tb.v ]
then
UUT=$1
else
echo "syntax:"
echo " ./sim-module <module-name>"
echo ""
echo "Where <module-name>_tb.v should exist"
exit
fi
# compile current unit
echo "UUT = $UUT"
iverilog -o ../$UUT ${UUT}_tb.v
cd ..
# run current simul/testbench
if [ -f $UUT ]
then
./$UUT
else
echo "iverilog failed"
exit
fi
echo "test for unit ${UUT} done"