-
Notifications
You must be signed in to change notification settings - Fork 2
/
wopen
executable file
·59 lines (50 loc) · 1.52 KB
/
wopen
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
#!/usr/bin/env bash
# Open GTKWave
#
# This script launches GTKWave with the custom command script(gtkwave_cfg.tcl).
# The script searches for and opens a VCD-file in the directory from which it was launched or
# gets dump-file name as parameter.
# Time-stamp: <2023-12-22 13:37:04>
SCRIPT_NAME=$(basename "${BASH_SOURCE##*/}")
if [ "$1" = '-h' ] || [ "$1" = '--help' ] || [ "$1" = '-help' ]; then
echo "Usage:"
echo " $SCRIPT_NAME [vcd-fname]"
echo
echo "OPTIONS:"
echo " vcd-fname"
echo " Name of a vcd-file."
echo " By default open local *.vcd file if only one file exist."
exit 0
fi
FNAME=""
find_file() {
IFS=$'\n' f_arr=($(find . -maxdepth 1 -type f \( -name "*.vcd" \)))
num_files=${#f_arr[@]}
if [ "$num_files" -eq 0 ]; then
echo "ERROR! Can't find dump file!"
exit 1
elif [ "$num_files" -gt 1 ]; then
echo "ERROR! There must be only one vcd-file in the directory!"
echo "Find files: ${f_arr[@]}"
exit 1
else
FNAME=${f_arr[0]}
fi
}
if [ "$#" -eq 1 ]; then
FNAME="$1"
if [ ! -s "$FNAME" ]; then
echo "ERROR! Can't find input file: '$FNAME'!"
exit 1
fi
else
find_file
fi
PATH2SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
gtkwave -S "$PATH2SCRIPT"/gtkwave_cfg.tcl "$FNAME"
# This is for the sake of Emacs.
# Local Variables:
# time-stamp-end: "$"
# time-stamp-format: "<%:y-%02m-%02d %02H:%02M:%02S>"
# time-stamp-start: "Time-stamp: "
# End: