forked from llvm/circt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
equiv-rtl.sh
executable file
·78 lines (74 loc) · 1.51 KB
/
equiv-rtl.sh
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
#!/usr/bin/env bash
##===- utils/equiv-rtl.sh - Formal Equivalence via yosys------*- Script -*-===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
##===----------------------------------------------------------------------===##
#
# This script checks two input verilog files for equivalence using yosys.
#
# Usage equiv-rtl.sh File1.v File2.v TopLevelModuleName
#
##===----------------------------------------------------------------------===##
if [ "$4" != "" ]; then
mdir=$4
else
mdir=.
fi
echo "Comparing $1 and $2 with $3 Missing Dir $mdir"
yosys -q -p "
read_verilog $1
hierarchy -libdir $mdir
rename $3 top1
proc
memory
flatten top1
read_verilog $2
hierarchy -libdir $mdir
rename $3 top2
proc
memory
flatten top2
clean -purge
opt -purge
equiv_make top1 top2 equiv
hierarchy -top equiv
equiv_simple -undef
equiv_induct -undef
equiv_status -assert
"
if [ $? -eq 0 ]
then
echo "PASS,INDUCT"
exit 0
fi
#repeat with sat
echo "Trying SAT $1 and $2 with $3 Missing Dir $mdir"
yosys -q -p "
read_verilog $1
hierarchy -libdir $mdir
rename $3 top1
proc
memory
flatten top1
read_verilog $2
hierarchy -libdir $mdir
rename $3 top2
proc
memory
flatten top2
opt
miter -equiv -make_assert -flatten top1 top2 equiv
hierarchy -top equiv
opt
sat -prove-asserts -seq 4 -verify
"
if [ $? -eq 0 ]
then
echo "PASS,SAT"
exit 0
fi
echo "FAIL"
exit 1