ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcCexMin2.c File Reference
#include "aig/gia/gia.h"
#include "bmc.h"
Include dependency graph for bmcCexMin2.c:

Go to the source code of this file.

Functions

int Gia_ManAnnotateUnrolling (Gia_Man_t *p, Abc_Cex_t *pCex, int fJustMax)
 FUNCTION DEFINITIONS ///.
 
Gia_Man_tGia_ManCreateUnate (Gia_Man_t *p, Abc_Cex_t *pCex, int iFrame, int nRealPis, int fUseAllObjects)
 
Abc_Cex_tGia_ManCexMin (Gia_Man_t *p, Abc_Cex_t *pCex, int iFrameStart, int nRealPis, int fJustMax, int fUseAll, int fVerbose)
 

Function Documentation

◆ Gia_ManAnnotateUnrolling()

int Gia_ManAnnotateUnrolling ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int fJustMax )

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Annotates the unrolling with CEX value/priority.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file bmcCexMin2.c.

73{
74 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
75 int RetValue, f, k, Value, Value0, Value1, iBit;
76 // start storage for internal info
77 assert( p->vTruths == NULL );
78 p->nTtWords = Abc_BitWordNum( 2 * Gia_ManObjNum(p) );
79 p->vTruths = Vec_IntStart( (pCex->iFrame + 1) * p->nTtWords );
80 // assign values to all objects (const0 and RO in frame0 are assigned 0)
82 for ( f = 0, iBit = pCex->nRegs; f <= pCex->iFrame; f++ )
83 {
84 Gia_ManForEachPi( p, pObj, k )
85 if ( (pObj->fMark0 = Abc_InfoHasBit(pCex->pData, iBit++)) )
86 Gia_ManAddTwo( p, f, pObj, 1 );
87 Gia_ManForEachAnd( p, pObj, k )
88 if ( (pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj))) )
89 Gia_ManAddTwo( p, f, pObj, 1 );
90 Gia_ManForEachCo( p, pObj, k )
91 if ( (pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) )
92 Gia_ManAddTwo( p, f, pObj, 1 );
93 if ( f == pCex->iFrame )
94 break;
95 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
96 if ( (pObjRo->fMark0 = pObjRi->fMark0) )
97 Gia_ManAddTwo( p, f+1, pObjRo, 1 );
98 }
99 assert( iBit == pCex->nBits );
100 // check the output value
101 RetValue = Gia_ManPo(p, pCex->iPo)->fMark0;
102 if ( RetValue != 1 )
103 printf( "Counter-example is invalid.\n" );
104 // assign justification to nodes
106 pObj = Gia_ManPo(p, pCex->iPo);
107 pObj->fMark0 = 1;
108 Gia_ManAddTwo( p, pCex->iFrame, pObj, 2 );
109 for ( f = pCex->iFrame; f >= 0; f-- )
110 {
111 // transfer to CO drivers
112 Gia_ManForEachCo( p, pObj, k )
113 if ( (Gia_ObjFanin0(pObj)->fMark0 = pObj->fMark0) )
114 {
115 pObj->fMark0 = 0;
116 Gia_ManAddTwo( p, f, Gia_ObjFanin0(pObj), 2 );
117 }
118 // compute justification
119 Gia_ManForEachAndReverse( p, pObj, k )
120 {
121 if ( !pObj->fMark0 )
122 continue;
123 pObj->fMark0 = 0;
124 Value = (1 & Gia_ManGetTwo(p, f, pObj));
125 Value0 = (1 & Gia_ManGetTwo(p, f, Gia_ObjFanin0(pObj))) ^ Gia_ObjFaninC0(pObj);
126 Value1 = (1 & Gia_ManGetTwo(p, f, Gia_ObjFanin1(pObj))) ^ Gia_ObjFaninC1(pObj);
127 if ( Value0 == Value1 )
128 {
129 assert( Value == (Value0 & Value1) );
130 if ( fJustMax || Value == 1 )
131 {
132 Gia_ObjFanin0(pObj)->fMark0 = Gia_ObjFanin1(pObj)->fMark0 = 1;
133 Gia_ManAddTwo( p, f, Gia_ObjFanin0(pObj), 2 );
134 Gia_ManAddTwo( p, f, Gia_ObjFanin1(pObj), 2 );
135 }
136 else
137 {
138 Gia_ObjFanin0(pObj)->fMark0 = 1;
139 Gia_ManAddTwo( p, f, Gia_ObjFanin0(pObj), 2 );
140 }
141 }
142 else if ( Value0 == 0 )
143 {
144 assert( Value == 0 );
145 Gia_ObjFanin0(pObj)->fMark0 = 1;
146 Gia_ManAddTwo( p, f, Gia_ObjFanin0(pObj), 2 );
147 }
148 else if ( Value1 == 0 )
149 {
150 assert( Value == 0 );
151 Gia_ObjFanin1(pObj)->fMark0 = 1;
152 Gia_ManAddTwo( p, f, Gia_ObjFanin1(pObj), 2 );
153 }
154 else assert( 0 );
155 }
156 if ( f == 0 )
157 break;
158 // transfer to RIs
159 Gia_ManForEachPi( p, pObj, k )
160 pObj->fMark0 = 0;
161 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
162 if ( (pObjRi->fMark0 = pObjRo->fMark0) )
163 {
164 pObjRo->fMark0 = 0;
165 Gia_ManAddTwo( p, f-1, pObjRi, 2 );
166 }
167 }
169 return RetValue;
170}
Cube * p
Definition exorList.c:222
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachAndReverse(p, pObj, i)
Definition gia.h:1222
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition giaUtil.c:256
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition gia.h:1256
unsigned fMark0
Definition gia.h:81
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCexMin()

Abc_Cex_t * Gia_ManCexMin ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int iFrameStart,
int nRealPis,
int fJustMax,
int fUseAll,
int fVerbose )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file bmcCexMin2.c.

318{
319 Gia_Man_t * pNew;
320 int f, RetValue;
321 // check CEX
322 assert( pCex->nPis == Gia_ManPiNum(p) );
323// assert( pCex->nRegs == Gia_ManRegNum(p) );
324 assert( pCex->iPo < Gia_ManPoNum(p) );
325 // check frames
326 assert( iFrameStart >= 0 && iFrameStart <= pCex->iFrame );
327 // check primary inputs
328 assert( nRealPis < Gia_ManPiNum(p) );
329 // prepare
330 RetValue = Gia_ManAnnotateUnrolling( p, pCex, fJustMax );
331 if ( nRealPis >= 0 ) // refinement
332 {
333 pNew = Gia_ManCreateUnate( p, pCex, iFrameStart, nRealPis, fUseAll );
334 printf( "%3d : ", iFrameStart );
335 Gia_ManPrintStats( pNew, NULL );
336 if ( fVerbose )
337 Gia_AigerWrite( pNew, "temp.aig", 0, 0, 0 );
338 Gia_ManStop( pNew );
339 }
340 else // CEX min
341 {
342 for ( f = pCex->iFrame; f >= iFrameStart; f-- )
343 {
344 pNew = Gia_ManCreateUnate( p, pCex, f, -1, fUseAll );
345 printf( "%3d : ", f );
346 Gia_ManPrintStats( pNew, NULL );
347 if ( fVerbose )
348 Gia_AigerWrite( pNew, "temp.aig", 0, 0, 0 );
349 Gia_ManStop( pNew );
350 }
351 }
352 Vec_IntFreeP( &p->vTruths );
353 p->nTtWords = 0;
354 return NULL;
355}
Gia_Man_t * Gia_ManCreateUnate(Gia_Man_t *p, Abc_Cex_t *pCex, int iFrame, int nRealPis, int fUseAllObjects)
Definition bmcCexMin2.c:183
int Gia_ManAnnotateUnrolling(Gia_Man_t *p, Abc_Cex_t *pCex, int fJustMax)
FUNCTION DEFINITIONS ///.
Definition bmcCexMin2.c:72
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition giaMan.c:495
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
Definition giaAiger.c:1595
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCreateUnate()

Gia_Man_t * Gia_ManCreateUnate ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int iFrame,
int nRealPis,
int fUseAllObjects )

Function*************************************************************

Synopsis [Computing AIG characterizing all justifying assignments.]

Description [Used in CEX minimization.]

SideEffects []

SeeAlso []

Definition at line 183 of file bmcCexMin2.c.

184{
185 Gia_Man_t * pNew, * pTemp;
186 Gia_Obj_t * pObj, * pObjRo, * pObjRi;
187 int f, k, Value;
188 assert( iFrame >= 0 && iFrame <= pCex->iFrame );
189 pNew = Gia_ManStart( 1000 );
190 pNew->pName = Abc_UtilStrsav( "unate" );
192 // set flop outputs
193 if ( nRealPis < 0 ) // CEX min
194 {
195 Gia_ManForEachRo( p, pObj, k )
196 {
197 if ( fUseAllObjects )
198 {
199 int Value = Gia_ManAppendCi(pNew);
200 if ( (Gia_ManGetTwo(p, iFrame, pObj) >> 1) ) // in the path
201 pObj->Value = Value;
202 }
203 else if ( (Gia_ManGetTwo(p, iFrame, pObj) >> 1) ) // in the path
204 pObj->Value = Gia_ManAppendCi(pNew);
205 }
206 }
207 else
208 {
209 Gia_ManForEachRo( p, pObj, k )
210 pObj->Value = (Gia_ManGetTwo(p, iFrame, pObj) >> 1);
211 }
212 Gia_ManHashAlloc( pNew );
213 for ( f = iFrame; f <= pCex->iFrame; f++ )
214 {
215/*
216 printf( " F%03d ", f );
217 Gia_ManForEachRo( p, pObj, k )
218 printf( "%d", pObj->Value > 0 );
219 printf( "\n" );
220*/
221 // set const0 to const1 if present
222 pObj = Gia_ManConst0(p);
223 pObj->Value = (Gia_ManGetTwo(p, f, pObj) >> 1);
224 // set primary inputs
225 if ( nRealPis < 0 ) // CEX min
226 {
227 Gia_ManForEachPi( p, pObj, k )
228 pObj->Value = (Gia_ManGetTwo(p, f, pObj) >> 1);
229 }
230 else
231 {
232 Gia_ManForEachPi( p, pObj, k )
233 {
234 pObj->Value = (Gia_ManGetTwo(p, f, pObj) >> 1);
235 if ( k >= nRealPis )
236 {
237 if ( fUseAllObjects )
238 {
239 int Value = Gia_ManAppendCi(pNew);
240 if ( (Gia_ManGetTwo(p, f, pObj) >> 1) ) // in the path
241 pObj->Value = Value;
242 }
243 else if ( (Gia_ManGetTwo(p, f, pObj) >> 1) ) // in the path
244 pObj->Value = Gia_ManAppendCi(pNew);
245 }
246 }
247 }
248 // traverse internal nodes
249 Gia_ManForEachAnd( p, pObj, k )
250 {
251 pObj->Value = 0;
252 Value = Gia_ManGetTwo(p, f, pObj);
253 if ( !(Value >> 1) ) // not in the path
254 continue;
255 if ( Gia_ObjFanin0(pObj)->Value && Gia_ObjFanin1(pObj)->Value )
256 {
257 if ( 1 & Gia_ManGetTwo(p, f, pObj) ) // value 1
258 {
259 if ( Gia_ObjFanin0(pObj)->Value > 1 && Gia_ObjFanin1(pObj)->Value > 1 )
260 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
261 else if ( Gia_ObjFanin0(pObj)->Value > 1 )
262 pObj->Value = Gia_ObjFanin0(pObj)->Value;
263 else if ( Gia_ObjFanin1(pObj)->Value > 1 )
264 pObj->Value = Gia_ObjFanin1(pObj)->Value;
265 else
266 pObj->Value = 1;
267 }
268 else // value 0
269 {
270 if ( Gia_ObjFanin0(pObj)->Value > 1 && Gia_ObjFanin1(pObj)->Value > 1 )
271 pObj->Value = Gia_ManHashOr( pNew, Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value );
272 else if ( Gia_ObjFanin0(pObj)->Value > 1 )
273 pObj->Value = Gia_ObjFanin0(pObj)->Value;
274 else if ( Gia_ObjFanin1(pObj)->Value > 1 )
275 pObj->Value = Gia_ObjFanin1(pObj)->Value;
276 else
277 pObj->Value = 1;
278 }
279 }
280 else if ( Gia_ObjFanin0(pObj)->Value )
281 pObj->Value = Gia_ObjFanin0(pObj)->Value;
282 else if ( Gia_ObjFanin1(pObj)->Value )
283 pObj->Value = Gia_ObjFanin1(pObj)->Value;
284 else assert( 0 );
285 }
286 Gia_ManForEachCo( p, pObj, k )
287 pObj->Value = Gia_ObjFanin0(pObj)->Value;
288 if ( f == pCex->iFrame )
289 break;
290 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
291 pObjRo->Value = pObjRi->Value;
292 }
293 Gia_ManHashStop( pNew );
294 // create primary output
295 pObj = Gia_ManPo(p, pCex->iPo);
296 assert( (Gia_ManGetTwo(p, pCex->iFrame, pObj) >> 1) );
297 assert( pObj->Value );
298 Gia_ManAppendCo( pNew, pObj->Value );
299 // cleanup
300 pNew = Gia_ManCleanup( pTemp = pNew );
301 Gia_ManStop( pTemp );
302 return pNew;
303}
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
void Gia_ManCleanValue(Gia_Man_t *p)
Definition giaUtil.c:351
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function: