2023-08-11 20:59:39 -05:00
|
|
|
#!/usr/bin/env bash
|
2014-12-25 10:52:31 -06:00
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
rm -rf test_cells
|
|
|
|
mkdir test_cells
|
|
|
|
cd test_cells
|
|
|
|
|
2014-12-25 13:28:16 -06:00
|
|
|
../../../yosys -p 'test_cell -muxdiv -w test all /$alu /$macc /$fa /$lcu /$lut /$shift /$shiftx'
|
2014-12-25 10:52:31 -06:00
|
|
|
|
|
|
|
cat > miter.tpl <<- EOT
|
|
|
|
; #model# (set-option :produce-models true)
|
|
|
|
(set-logic QF_UFBV)
|
|
|
|
%%
|
|
|
|
(declare-fun s () miter_s)
|
|
|
|
(assert (|miter_n trigger| s))
|
|
|
|
(check-sat)
|
|
|
|
; #model# (get-value ((|miter_n in_A| s) (|miter_n in_B| s) (|miter_n gold_Y| s) (|miter_n gate_Y| s) (|miter_n trigger| s)))
|
|
|
|
EOT
|
|
|
|
|
2014-12-25 13:28:16 -06:00
|
|
|
for x in $(set +x; ls test_*.il | sort -R); do
|
2014-12-25 10:52:31 -06:00
|
|
|
x=${x%.il}
|
|
|
|
cat > $x.ys <<- EOT
|
2024-11-04 17:36:31 -06:00
|
|
|
read_rtlil $x.il
|
2014-12-25 10:52:31 -06:00
|
|
|
copy gold gate
|
|
|
|
|
|
|
|
cd gate
|
|
|
|
techmap; opt; abc;;
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
miter -equiv -flatten -make_outputs gold gate miter
|
|
|
|
hierarchy -check -top miter
|
|
|
|
|
|
|
|
dump
|
|
|
|
write_smt2 -bv -tpl miter.tpl $x.smt2
|
|
|
|
EOT
|
2014-12-25 13:28:16 -06:00
|
|
|
../../../yosys -q $x.ys
|
|
|
|
if ! cvc4 $x.smt2 > $x.result; then
|
|
|
|
cat $x.result
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-12-25 10:52:31 -06:00
|
|
|
if ! grep unsat $x.result; then
|
|
|
|
echo "Proof failed! Extracting model..."
|
|
|
|
sed -i 's/^; #model# //' $x.smt2
|
|
|
|
cvc4 $x.smt2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
2014-12-25 13:28:16 -06:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo ""
|
|
|
|
echo " All tests passed."
|
|
|
|
echo ""
|
|
|
|
exit 0
|
|
|
|
|