RISC-V_Verilog/scripts/gen_simu_do.sh

37 lines
693 B
Bash
Raw Permalink Normal View History

2023-10-11 08:43:36 +00:00
#! /bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 <file_name> [signal]"
exit 1
fi
2023-11-20 05:21:26 +00:00
TB_FILE_NAME=tb_$1
FILE_NAME=$(echo "$1" | sed 's/\([[:alnum:]_]*\)[-.].*/\1/')
2023-10-11 08:43:36 +00:00
echo 'puts "Simulation script for ModelSim"
' > ./simu.do
2023-10-11 08:43:36 +00:00
# test if "$1".v and tb_"$1".v files exist
if [ ! -f "../rtl/""$FILE_NAME"".v" ]; then
2023-10-11 08:43:36 +00:00
echo "Error: $FILE_NAME.v file not found!"
exit 1
fi
if [ ! -f "../tb/""$TB_FILE_NAME"".v" ]; then
2023-11-20 05:21:26 +00:00
echo "Error: ""$TB_FILE_NAME"".v file not found!"
2023-10-11 08:43:36 +00:00
exit 1
fi
echo 'vlib work
vlog ../rtl/*.v
2023-11-20 05:21:26 +00:00
vlog ../tb/'"$TB_FILE_NAME"'.v
' >> ./simu.do
2023-10-11 08:43:36 +00:00
echo 'vsim tb_'"$FILE_NAME"'
' >> ./simu.do
2023-10-11 08:43:36 +00:00
# loop through all arguments from $3
echo 'run -all' >> ./simu.do
2023-10-11 08:43:36 +00:00
exit 0