-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtbrun_tbw
executable file
·135 lines (119 loc) · 3.62 KB
/
tbrun_tbw
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# $Id: tbrun_tbw 1172 2019-06-29 07:27:24Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2014-2019 by Walter F.J. Mueller <[email protected]>
#
# Revision History:
# Date Rev Version Comment
# 2016-09-03 805 1.2.2 add TIMEFORMAT and time for make commands
# 2016-08-21 800 1.2.1 add -norun, -nomake
# 2016-08-06 795 1.2 use tbfilt; fixup -lsuf logic
# 2016-07-03 782 1.1.4 drop ghdl_assert_filter (use --ieee=... at ghdl lvl)
# 2016-06-25 778 1.1.3 drop make ghdl_tmp_clean logic
# 2016-06-05 773 1.1.2 use _bsim.log for behavioral sim log
# 2016-04-17 762 1.1.1 don't create '-run' for [IX]Sim anymore (now default)
# 2016-02-06 727 1.1 add vivado xsim support; Makefile.ise support
# 2014-12-27 622 1.0.1 add --stack, --ghw, --tbw, --pcom
# 2014-12-26 621 1.0 Initial version
#
docmd ()
{
if [[ -z "$optdry" ]] ; then
echo "$2"
eval "$1"
else
echo "$1"
fi
}
optdry=""
optnomake=""
optnorun=""
optlsuf=""
optstack=""
optghw=""
opttbw=""
optpcom=""
# handle options
while (( $# > 0 )) ; do
case $1 in
-dry|--dry) optdry=$1 ; shift 1 ;;
-nomake|--nomake) optnomake=$1 ; shift 1 ;;
-norun|--norun) optnorun=$1 ; shift 1 ;;
-lsuf|--lsuf) optlsuf=$2 ; shift 2 ;;
-stack|--stack) optstack=$2 ; shift 2 ;;
-ghw|--ghw) optghw=$2 ; shift 2 ;;
-tbw|--tbw) opttbw=$2 ; shift 2 ;;
-pcom|--pcom) optpcom=$1 ; shift 1 ;;
-*) echo "tbrun_tbw-E: invalid option '$1'"; exit 1 ;;
*) break;;
esac
done
tbench=$1
stimfile=$2
# complain if no tbench defined
if (( $# == 0 )) ; then
echo "Usage: tbrun_tbw [opts] testbench [stimfile]"
echo " Options:"
echo " --dry dry run, print commands, don't execute"
echo " --nomake don't execute make step"
echo " --norun don't execute run step"
echo " --lsuf suff use '_<suff>.log' as suffix for log file"
echo " --stack nnn use <nnn> as ghdl stack size"
echo " --ghw fname write ghw file with name '<fname>.ghw"
echo " --tbw opts append <opts> to tbw command"
echo " --pcom print test comments"
exit 1
fi
# defaults
isghdl=true
makeopts=""
# check for ISim
isisim=""
if [[ $tbench =~ _ISim ]] ; then
isisim=true
isghdl=""
if [[ -f "Makefile.ise" ]] ; then
makeopts="-f Makefile.ise"
fi
fi
# check for XSim
isxsim=""
if [[ $tbench =~ _XSim ]] ; then
isxsim=true
isghdl=""
fi
# issue makes
if [[ -z "$optnomake" ]] ; then
cmd="TIMEFORMAT=$'real %3lR user %3lU sys %3lS'"
cmd+=$'\n'
cmd+="time make $makeopts $tbench"
docmd "$cmd"
exitstat=$?
if (( $exitstat > 0 )) ; then exit $exitstat; fi
echo ""
fi
# check for test bench
if [[ ! -x $tbench ]] ; then
echo "tbrun_tbw-E: $tbench not existing or not executable"
exit 1
fi
# determine logfile name
logsuff="_bsim"
if [[ $tbench =~ _[fsorept]sim$ ]] ; then logsuff=""; fi
if [[ -n "$optlsuf" ]] ; then logsuff+="_$optlsuf"; fi
logfile="${tbench}${logsuff}.log"
# now build actual test command (a tbw | tbfilt pipe)
cmdtb="tbw $tbench"
if [[ -n "$stimfile" ]] ; then cmdtb+=" $stimfile"; fi
if [[ -n "$opttbw" ]] ; then cmdtb+=" $opttbw"; fi
if [[ -n "$optstack" ]] ; then cmdtb+=" --stack-max-size=$optstack"; fi
if [[ -n "$optghw" ]] ; then cmdtb+=" --wave=$optghw.ghw"; fi
cmdtb+=" 2>&1"
cmdtf="tbfilt -tee $logfile"
if [[ -n "$optpcom" ]] ; then cmdtf+=" -pcom"; fi
cmd="(export TIMEFORMAT=$'real %3lR user %3lU sys %3lS'; time $cmdtb) 2>&1"
cmd+=" | $cmdtf"
txt="$cmdtb | $cmdtf"
if [[ -z "$optnorun" ]] ; then
docmd "$cmd" "$txt"
fi