ref.[iverilog]
https://bleyer.org/icarus/
ref. [bash]
https://www.baeldung.com/linux/use-command-line-arguments-in-bash-script
https://daniel-sc.github.io/bash-shell-to-bat-converter/
[Win10]
01. https://bleyer.org/icarus/iverilog-v11-20210204-x64_setup.exe
02. set PATH, "控制台\系統及安全性\系統" -> 進階系統設定 -> 環境變數 -> 變數 Path -> Edit -> 新增 "C:\iverilog\bin" "C:\iverilog\gtkwave\bin"
03. open a text editor -> copy the following content and save as "v2w.sh"
#!/bin/bash
# define parameters
wavext=".vcd"
outfolder="output"
currentdir=$PWD
# main program
# info
#filename=$1
read filename
# fetch basename
basename=$(echo "$filename" | cut -f 1 -d '.')
outname="$basename$wavext"
echo "veriolog(*.v) to waveform(*.vcd): $filename to $outname"
# create sim folder if not exist
mkdir -p $outfolder
# iverilog commands
iverilog -o wave -y $PWD $filename
vvp -n wave -lxt2
rm wave
mv wave.vcd $PWD/output/$outname
gtkwave $PWD/output/$outname &
Here is the result:
04. place "*.v" & v2w.sh in the same folder and double-click on "v2w.sh". Then, fill in the main test bench *.v
#!/bin/bash
# define parameters
wavext=".vcd"
outfolder="output"
currentdir=$PWD
# main program
# info
#filename=$1
read filename
# fetch basename
basename=$(echo "$filename" | cut -f 1 -d '.')
outname="$basename$wavext"
echo "veriolog(*.v) to waveform(*.vcd): $filename to $outname"
# create sim folder if not exist
mkdir -p $outfolder
# iverilog commands
iverilog -o wave -y $PWD $filename
vvp -n wave -lxt2
rm wave
mv wave.vcd $PWD/output/$outname
gtkwave $PWD/output/$outname &
03.
>> shc -f v2w.sh
>> mv v2w.sh.x ~/bin/v2w
>> vi ~/.bashrc
PATH=$PATH:~/bin
04. in the folder of all the *.v
>> v2w testbench.v