b1c330d89cc0782cd3cec05c1ad26e4bd192c37f
9 backend_opts
="-noattr -noexpr"
13 toolsdir
="$(cd $(dirname $0); pwd)"
15 if [ ! -f $toolsdir/cmp_tbdata
-o $toolsdir/cmp_tbdata.c
-nt $toolsdir/cmp_tbdata
]; then
16 ( set -ex; gcc
-Wall -o $toolsdir/cmp_tbdata
$toolsdir/cmp_tbdata.c
; ) ||
exit 1
19 while getopts iml
:wkvrxs
:p
: opt
; do
26 libs
="$libs $(cd $(dirname $OPTARG); pwd)/$(basename $OPTARG)";;
34 backend_opts
="$backend_opts -norename" ;;
38 [[ "$OPTARG" == /* ]] || OPTARG
="$PWD/$OPTARG"
39 scriptfiles
="$scriptfiles $OPTARG" ;;
41 scriptopt
="$OPTARG" ;;
43 echo "Usage: $0 [-i] [-w] [-k] [-v] [-r] [-x] [-l libs] [-s script] [-p cmdstring] verilog-files\n" >&2
50 echo "verilog work $1" > $2.prj
53 -ifn $2.prj -ifmt mixed -ofn $2 -ofmt NGC -p xc6slx4-3-tqg144
54 -top $( grep ^module $1 | sed -r 's,[^0-9A-Za-z_]+, ,g' | awk '{ print $2; exit; }'; )
55 -opt_mode Speed -opt_level 1 -iobuf NO
60 xilver
=$
( ls -v /opt
/Xilinx
/ |
grep '^[0-9]' |
tail -n1; )
61 case "$( uname -m )" in
63 set --; .
/opt
/Xilinx
/$xilver/ISE_DS
/settings64.sh
;;
65 set --; .
/opt
/Xilinx
/$xilver/ISE_DS
/settings32.sh
;;
69 netgen
-w -ofmt verilog
$prefix.ngc
$prefix
77 exe
="$1"; output
="$2"; shift 2
78 if $use_modelsim; then
79 altver
=$
( ls -v /opt
/altera
/ |
grep '^[0-9]' |
tail -n1; )
80 /opt
/altera
/$altver/modelsim_ase
/bin
/vlib work
81 /opt
/altera
/$altver/modelsim_ase
/bin
/vlog
"$@"
82 /opt
/altera
/$altver/modelsim_ase
/bin
/vsim
-c -do 'run -all; exit;' testbench |
grep '#OUT#' > "$output"
87 xilver
=$
( ls -v /opt
/Xilinx
/ |
grep '^[0-9]' |
tail -n1; )
88 case "$( uname -m )" in
90 set --; .
/opt
/Xilinx
/$xilver/ISE_DS
/settings64.sh
;;
92 set --; .
/opt
/Xilinx
/$xilver/ISE_DS
/settings32.sh
;;
95 vlogcomp
"${files[@]}"
97 fuse
-o "$exe" -lib unisims_ver
-top testbench
-top glbl
99 fuse
-o "$exe" -top testbench
101 { echo "run all"; echo "exit"; } > run-all.tcl
102 PATH
="$PATH:" "$exe" -tclbatch run-all.tcl
> "$output"
105 iverilog
-s testbench
-o "$exe" "$@"
106 vvp
-n "$exe" > "$output"
110 shift $
((OPTIND
- 1))
115 if [ "$bn" == "$fn" ]; then
116 echo "Invalid argument: $fn" >&2
119 [[ "$bn" == *_tb
]] && continue
122 rm -f ${bn}.
{err
,log
}
129 if [ ! -f ..
/${bn}_tb.v
]; then
130 "$toolsdir"/..
/..
/yosys
-b autotest
-o ${bn}_tb.v
$fn
132 cp ..
/${bn}_tb.v
${bn}_tb.v
134 if $genvcd; then sed -i 's,// \$dump,$dump,g' ${bn}_tb.v
; fi
135 create_ref
$fn ${bn}_ref
136 compile_and_run
${bn}_tb_ref ${bn}_out_ref ${bn}_tb.v ${bn}_ref.v
$libs
137 if $genvcd; then mv testbench.vcd
${bn}_ref.vcd
; fi
141 "$toolsdir"/..
/..
/yosys
-b "verilog $backend_opts" "$@" -o ${bn}_syn
${test_count}.v
$fn $scriptfiles
142 compile_and_run
${bn}_tb_syn${test_count} ${bn}_out_syn${test_count} \
143 ${bn}_tb.v ${bn}_syn${test_count}.v
$libs \
144 "$toolsdir"/..
/..
/techlibs
/common
/simlib.v \
145 "$toolsdir"/..
/..
/techlibs
/common
/simcells.v
146 if $genvcd; then mv testbench.vcd
${bn}_syn
${test_count}.vcd
; fi
147 $toolsdir/cmp_tbdata
${bn}_out_ref ${bn}_out_syn${test_count}
148 test_count
=$
(( test_count
+ 1 ))
151 if [ -n "$scriptfiles" ]; then
153 elif [ -n "$scriptopt" ]; then
154 test_passes
-p "$scriptopt"
156 test_passes
-p "hierarchy; proc; opt; memory; opt; fsm; opt"
157 test_passes
-p "hierarchy; proc; opt; memory; opt; fsm; opt; techmap; opt; abc -dff; opt"
164 echo "Output written to console." > ${bn}.err
167 ( set -ex; body
; ) > ${bn}.err
2>&1
170 if [ -f ${bn}.log
]; then
171 mv ${bn}.err
${bn}.log
173 else echo "-> ERROR!"; $keeprunning ||
exit 1; fi