ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cecSimBack.c
Go to the documentation of this file.
1
20
21#include "cecInt.h"
22#include "aig/gia/giaAig.h"
23
25
26
30
34
46int Cec_ObjSatVerify( Gia_Man_t * p, Gia_Obj_t * pRoot, int Value )
47{
48 Gia_Obj_t * pObj;
49 int i, RetValue = 1;
50 printf( "Obj = %4d Value = %d ", Gia_ObjId(p, pRoot), Value );
51 Gia_ObjTerSimSet0( Gia_ManConst0(p) );
52 Gia_ManForEachCi( p, pObj, i )
53 if ( !Gia_ObjIsTravIdCurrent(p, pObj) )
54 Gia_ObjTerSimSetX( pObj ), printf( "x" );
55 else if ( pObj->fMark0 )
56 Gia_ObjTerSimSet1( pObj ), printf( "1" );
57 else
58 Gia_ObjTerSimSet0( pObj ), printf( "0" );
59 printf( " " );
60 Gia_ManForEachAnd( p, pObj, i )
61 Gia_ObjTerSimAnd( pObj );
62 if ( Value ? Gia_ObjTerSimGet1(pRoot) : Gia_ObjTerSimGet0(pRoot) )
63 printf( "Verification successful.\n" );
64 else
65 printf( "Verification failed.\n" ), RetValue = 0;
66 return RetValue;
67}
68
81{
82 Gia_Obj_t * pFan0, * pFan1;
83 if ( Gia_ObjIsTravIdCurrent(p, pObj) )
84 return Value == (int)pObj->fMark0;
85 Gia_ObjSetTravIdCurrent(p, pObj);
86 pObj->fMark0 = Value;
87 if ( !Gia_ObjIsAnd(pObj) )
88 return 1;
89 pFan0 = Gia_ObjFanin0(pObj);
90 pFan1 = Gia_ObjFanin1(pObj);
91 if ( Value )
92 {
93 return Cec_ManCheckSat2_rec( p, pFan0, !Gia_ObjFaninC0(pObj), vValues ) &&
94 Cec_ManCheckSat2_rec( p, pFan1, !Gia_ObjFaninC1(pObj), vValues );
95 }
96 if ( Gia_ObjIsTravIdCurrent(p, pFan0) ) // already assigned
97 {
98 if ( Gia_ObjFaninC0(pObj) == (int)pFan0->fMark0 ) // justified
99 return 1;
100 return Cec_ManCheckSat2_rec( p, pFan1, Gia_ObjFaninC1(pObj), vValues );
101 }
102 if ( Gia_ObjIsTravIdCurrent(p, pFan1) ) // already assigned
103 {
104 if ( Gia_ObjFaninC1(pObj) == (int)pFan1->fMark0 ) // justified
105 return 1;
106 return Cec_ManCheckSat2_rec( p, pFan0, Gia_ObjFaninC0(pObj), vValues );
107 }
108 return Cec_ManCheckSat2_rec( p, pFan0, Gia_ObjFaninC0(pObj), vValues );
109}
110word Cec_ManCheckSat2( Gia_Man_t * p, Gia_Obj_t * pObj, int Value, Vec_Wrd_t * vValues )
111{
112 return 0;
113}
114
126int Cec_ManCheckSat_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int Value )
127{
128 Gia_Obj_t * pFan0, * pFan1;
129 if ( Gia_ObjIsTravIdCurrent(p, pObj) )
130 return Value == (int)pObj->fMark0;
131 Gia_ObjSetTravIdCurrent(p, pObj);
132 pObj->fMark0 = Value;
133 if ( !Gia_ObjIsAnd(pObj) )
134 return 1;
135 pFan0 = Gia_ObjFanin0(pObj);
136 pFan1 = Gia_ObjFanin1(pObj);
137 if ( Value )
138 {
139 return Cec_ManCheckSat_rec( p, pFan0, !Gia_ObjFaninC0(pObj) ) &&
140 Cec_ManCheckSat_rec( p, pFan1, !Gia_ObjFaninC1(pObj) );
141 }
142 if ( Gia_ObjIsTravIdCurrent(p, pFan0) ) // already assigned
143 {
144 if ( Gia_ObjFaninC0(pObj) == (int)pFan0->fMark0 ) // justified
145 return 1;
146 return Cec_ManCheckSat_rec( p, pFan1, Gia_ObjFaninC1(pObj) );
147 }
148 if ( Gia_ObjIsTravIdCurrent(p, pFan1) ) // already assigned
149 {
150 if ( Gia_ObjFaninC1(pObj) == (int)pFan1->fMark0 ) // justified
151 return 1;
152 return Cec_ManCheckSat_rec( p, pFan0, Gia_ObjFaninC0(pObj) );
153 }
154 return Cec_ManCheckSat_rec( p, pFan0, Gia_ObjFaninC0(pObj) );
155}
157{
158 abctime clk = Abc_Clock();
159 Vec_Wrd_t * vValues = Vec_WrdStart( Gia_ManObjNum(p) );
160 Gia_Obj_t * pObj;
161 int i, Count = 0;
162 word Res;
164 //Gia_ManForEachAnd( p, pObj, i )
165 // printf( "%d", pObj->fPhase );
166 //printf( "\n" );
167 //return;
168
169 Gia_ManForEachAnd( p, pObj, i )
170 {
172 //Gia_ManCleanMark0( p );
173 Res = Cec_ManCheckSat_rec( p, pObj, !pObj->fPhase );
174 //if ( Res )
175 // Cec_ObjSatVerify( p, pObj, !pObj->fPhase );
176
177 //Res = Cec_ManCheckSat2_rec( p, pObj, !pObj->fPhase ? ~(word)0 : 0, vValues );
178 //if ( Res )
179 // Cec_ObjSatVerify2( p, pObj, !pObj->fPhase, Res );
180
181 Count += (int)(Res > 0);
182 }
183 Vec_WrdFree( vValues );
184 printf( "Obj = %6d. SAT = %6d. ", Gia_ManAndNum(p), Count );
185 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
186}
187
191
192
194
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
word Cec_ManCheckSat2(Gia_Man_t *p, Gia_Obj_t *pObj, int Value, Vec_Wrd_t *vValues)
Definition cecSimBack.c:110
int Cec_ManCheckSat_rec(Gia_Man_t *p, Gia_Obj_t *pObj, int Value)
Definition cecSimBack.c:126
ABC_NAMESPACE_IMPL_START int Cec_ObjSatVerify(Gia_Man_t *p, Gia_Obj_t *pRoot, int Value)
DECLARATIONS ///.
Definition cecSimBack.c:46
word Cec_ManCheckSat2_rec(Gia_Man_t *p, Gia_Obj_t *pObj, word Value, Vec_Wrd_t *vValues)
Definition cecSimBack.c:80
void Cec_ManSimBack(Gia_Man_t *p)
Definition cecSimBack.c:156
Cube * p
Definition exorList.c:222
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
void Gia_ManSetPhase(Gia_Man_t *p)
Definition giaUtil.c:420
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
unsigned fPhase
Definition gia.h:87
unsigned fMark0
Definition gia.h:81
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42