-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest.sh
More file actions
40 lines (32 loc) · 909 Bytes
/
test.sh
File metadata and controls
40 lines (32 loc) · 909 Bytes
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
#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Usage: $0 [module file(s)] [testbench file]"
exit 1
fi
MODULE_DIR="modules"
TESTBENCH_DIR="testbenches"
RESULTS_DIR="${TESTBENCH_DIR}/results"
mkdir -p "$RESULTS_DIR"
result_file_prefix=$(basename "$1" .v)
result_file="${RESULTS_DIR}/${result_file_prefix}_result.vvp"
# Build the full paths for the module files and testbench file
module_files=""
for file in "$@"; do
if [[ "$file" == *"_tb.v" ]]; then
testbench_file="${TESTBENCH_DIR}/${file}"
else
module_files="${module_files} ${MODULE_DIR}/${file}"
fi
done
# Check if the testbench file exists
if [ ! -f "$testbench_file" ]; then
echo "Error: Testbench file '$testbench_file' not found."
exit 2
fi
# Run iverilog
iverilog -o "$result_file" $module_files "$testbench_file"
if [ $? -ne 0 ]; then
echo "Error: iverilog failed."
exit 3
fi
vvp "$result_file"