9 backend_opts
="-noattr -noexpr"
12 toolsdir
="$(cd $(dirname $0); pwd)"
14 if [ ! -f $toolsdir/cmp_tbdata
-o $toolsdir/cmp_tbdata.c
-nt $toolsdir/cmp_tbdata
]; then
15 ( set -ex; gcc
-Wall -o $toolsdir/cmp_tbdata
$toolsdir/cmp_tbdata.c
; ) ||
exit 1
18 while getopts xml
:wkvrs
:p
: opt
; do
25 libs
="$libs $(cd $(dirname $OPTARG); pwd)/$(basename $OPTARG)";;
33 backend_opts
="$backend_opts -norename" ;;
35 [[ "$OPTARG" == /* ]] || OPTARG
="$PWD/$OPTARG"
36 scriptfiles
="$scriptfiles $OPTARG" ;;
38 scriptopt
="$OPTARG" ;;
40 echo "Usage: $0 [-x|-m] [-w] [-k] [-v] [-r] [-l libs] [-s script] [-p cmdstring] verilog-files\n" >&2
50 exe
="$1"; output
="$2"; shift 2
51 if $use_modelsim; then
52 altver
=$
( ls -v /opt
/altera
/ |
grep '^[0-9]' |
tail -n1; )
53 /opt
/altera
/$altver/modelsim_ase
/bin
/vlib work
54 /opt
/altera
/$altver/modelsim_ase
/bin
/vlog
"$@"
55 /opt
/altera
/$altver/modelsim_ase
/bin
/vsim
-c -do 'run -all; exit;' testbench |
grep '#OUT#' > "$output"
60 xilver
=$
( ls -v /opt
/Xilinx
/Vivado
/ |
grep '^[0-9]' |
tail -n1; )
61 /opt
/Xilinx
/Vivado
/$xilver/bin
/xvlog
"${files[@]}"
62 /opt
/Xilinx
/Vivado
/$xilver/bin
/xelab
-R work.testbench |
grep '#OUT#' > "$output"
65 iverilog
-s testbench
-o "$exe" "$@"
66 vvp
-n "$exe" > "$output"
75 if [ "$bn" == "$fn" ]; then
76 echo "Invalid argument: $fn" >&2
79 [[ "$bn" == *_tb
]] && continue
89 if [ ! -f ..
/${bn}_tb.v
]; then
90 "$toolsdir"/..
/..
/yosys
-b autotest
-o ${bn}_tb.v
$fn
92 cp ..
/${bn}_tb.v
${bn}_tb.v
94 if $genvcd; then sed -i 's,// \$dump,$dump,g' ${bn}_tb.v
; fi
95 create_ref
$fn ${bn}_ref
96 compile_and_run
${bn}_tb_ref ${bn}_out_ref ${bn}_tb.v ${bn}_ref.v
$libs
97 if $genvcd; then mv testbench.vcd
${bn}_ref.vcd
; fi
101 "$toolsdir"/..
/..
/yosys
-b "verilog $backend_opts" "$@" -o ${bn}_syn
${test_count}.v
$fn $scriptfiles
102 compile_and_run
${bn}_tb_syn${test_count} ${bn}_out_syn${test_count} \
103 ${bn}_tb.v ${bn}_syn${test_count}.v
$libs \
104 "$toolsdir"/..
/..
/techlibs
/common
/simlib.v \
105 "$toolsdir"/..
/..
/techlibs
/common
/simcells.v
106 if $genvcd; then mv testbench.vcd
${bn}_syn
${test_count}.vcd
; fi
107 $toolsdir/cmp_tbdata
${bn}_out_ref ${bn}_out_syn${test_count}
108 test_count
=$
(( test_count
+ 1 ))
111 if [ -n "$scriptfiles" ]; then
113 elif [ -n "$scriptopt" ]; then
114 test_passes
-p "$scriptopt"
116 test_passes
-p "hierarchy; proc; opt; memory; opt; fsm; opt"
117 test_passes
-p "hierarchy; proc; opt; memory; opt; fsm; opt; techmap; opt; abc -dff; opt"
124 echo "Output written to console." > ${bn}.err
127 ( set -ex; body
; ) > ${bn}.err
2>&1
130 if [ -f ${bn}.log
]; then
131 mv ${bn}.err
${bn}.log
133 else echo "-> ERROR!"; $keeprunning ||
exit 1; fi