ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
fraBmc.c File Reference
#include "fra.h"
Include dependency graph for fraBmc.c:

Go to the source code of this file.

Classes

struct  Fra_Bmc_t_
 DECLARATIONS ///. More...
 

Functions

int Fra_BmcNodesAreEqual (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 FUNCTION DEFINITIONS ///.
 
int Fra_BmcNodeIsConst (Aig_Obj_t *pObj)
 
void Fra_BmcFilterImplications (Fra_Man_t *p, Fra_Bmc_t *pBmc)
 
Fra_Bmc_tFra_BmcStart (Aig_Man_t *pAig, int nPref, int nDepth)
 
void Fra_BmcStop (Fra_Bmc_t *p)
 
Aig_Man_tFra_BmcFrames (Fra_Bmc_t *p, int fKeepPos)
 
void Fra_BmcPerform (Fra_Man_t *p, int nPref, int nDepth)
 
void Fra_BmcPerformSimple (Aig_Man_t *pAig, int nFrames, int nBTLimit, int fRewrite, int fVerbose)
 

Function Documentation

◆ Fra_BmcFilterImplications()

void Fra_BmcFilterImplications ( Fra_Man_t * p,
Fra_Bmc_t * pBmc )

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

Synopsis [Refines implications using BMC.]

Description [The input is the combinational FRAIG manager, which is used to FRAIG the timeframes. ]

SideEffects []

SeeAlso []

Definition at line 121 of file fraBmc.c.

122{
123 Aig_Obj_t * pLeft, * pRight;
124 Aig_Obj_t * pLeftT, * pRightT;
125 Aig_Obj_t * pLeftF, * pRightF;
126 int i, f, Imp, Left, Right;
127 int fComplL, fComplR;
128 assert( p->nFramesAll == 1 );
129 assert( p->pManAig == pBmc->pAigFrames );
130 Vec_IntForEachEntry( pBmc->vImps, Imp, i )
131 {
132 if ( Imp == 0 )
133 continue;
134 Left = Fra_ImpLeft(Imp);
135 Right = Fra_ImpRight(Imp);
136 // get the corresponding nodes
137 pLeft = Aig_ManObj( pBmc->pAig, Left );
138 pRight = Aig_ManObj( pBmc->pAig, Right );
139 // iterate through the timeframes
140 for ( f = pBmc->nPref; f < pBmc->nFramesAll; f++ )
141 {
142 // get timeframe nodes
143 pLeftT = Bmc_ObjFrames( pLeft, f );
144 pRightT = Bmc_ObjFrames( pRight, f );
145 // get the corresponding FRAIG nodes
146 pLeftF = Fra_ObjFraig( Aig_Regular(pLeftT), 0 );
147 pRightF = Fra_ObjFraig( Aig_Regular(pRightT), 0 );
148 // get the complemented attributes
149 fComplL = pLeft->fPhase ^ Aig_IsComplement(pLeftF) ^ Aig_IsComplement(pLeftT);
150 fComplR = pRight->fPhase ^ Aig_IsComplement(pRightF) ^ Aig_IsComplement(pRightT);
151 // check equality
152 if ( Aig_Regular(pLeftF) == Aig_Regular(pRightF) )
153 {
154 if ( fComplL == fComplR ) // x => x - always true
155 continue;
156 assert( fComplL != fComplR );
157 // consider 4 possibilities:
158 // NOT(1) => 1 or 0 => 1 - always true
159 // 1 => NOT(1) or 1 => 0 - never true
160 // NOT(x) => x or x - not always true
161 // x => NOT(x) or NOT(x) - not always true
162 if ( Aig_ObjIsConst1(Aig_Regular(pLeftF)) && fComplL ) // proved implication
163 continue;
164 // disproved implication
165 Vec_IntWriteEntry( pBmc->vImps, i, 0 );
166 break;
167 }
168 // check the implication
169 if ( Fra_NodesAreImp( p, Aig_Regular(pLeftF), Aig_Regular(pRightF), fComplL, fComplR ) != 1 )
170 {
171 Vec_IntWriteEntry( pBmc->vImps, i, 0 );
172 break;
173 }
174 }
175 }
176 Fra_ImpCompactArray( pBmc->vImps );
177}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Cube * p
Definition exorList.c:222
void Fra_ImpCompactArray(Vec_Int_t *vImps)
Definition fraImp.c:607
int Fra_NodesAreImp(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
Definition fraSat.c:209
unsigned int fPhase
Definition aig.h:78
Aig_Man_t * pAigFrames
Definition fraBmc.c:41
int nPref
Definition fraBmc.c:34
Aig_Man_t * pAig
Definition fraBmc.c:40
Vec_Int_t * vImps
Definition fraBmc.c:38
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fra_BmcFrames()

Aig_Man_t * Fra_BmcFrames ( Fra_Bmc_t * p,
int fKeepPos )

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

Synopsis [Constructs initialized timeframes of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file fraBmc.c.

238{
239 Aig_Man_t * pAigFrames;
240 Aig_Obj_t * pObj, * pObjNew;
241 Aig_Obj_t ** pLatches;
242 int i, k, f;
243
244 // start the fraig package
245 pAigFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * p->nFramesAll );
246 pAigFrames->pName = Abc_UtilStrsav( p->pAig->pName );
247 pAigFrames->pSpec = Abc_UtilStrsav( p->pAig->pSpec );
248 // create PI nodes for the frames
249 for ( f = 0; f < p->nFramesAll; f++ )
250 Bmc_ObjSetFrames( Aig_ManConst1(p->pAig), f, Aig_ManConst1(pAigFrames) );
251 for ( f = 0; f < p->nFramesAll; f++ )
252 Aig_ManForEachPiSeq( p->pAig, pObj, i )
253 Bmc_ObjSetFrames( pObj, f, Aig_ObjCreateCi(pAigFrames) );
254 // set initial state for the latches
255 Aig_ManForEachLoSeq( p->pAig, pObj, i )
256 Bmc_ObjSetFrames( pObj, 0, Aig_ManConst0(pAigFrames) );
257
258 // add timeframes
259 pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
260 for ( f = 0; f < p->nFramesAll; f++ )
261 {
262 // add internal nodes of this frame
263 Aig_ManForEachNode( p->pAig, pObj, i )
264 {
265 pObjNew = Aig_And( pAigFrames, Bmc_ObjChild0Frames(pObj,f), Bmc_ObjChild1Frames(pObj,f) );
266 Bmc_ObjSetFrames( pObj, f, pObjNew );
267 }
268 if ( f == p->nFramesAll - 1 )
269 break;
270 // save the latch input values
271 k = 0;
272 Aig_ManForEachLiSeq( p->pAig, pObj, i )
273 pLatches[k++] = Bmc_ObjChild0Frames(pObj,f);
274 assert( k == Aig_ManRegNum(p->pAig) );
275 // insert them to the latch output values
276 k = 0;
277 Aig_ManForEachLoSeq( p->pAig, pObj, i )
278 Bmc_ObjSetFrames( pObj, f+1, pLatches[k++] );
279 assert( k == Aig_ManRegNum(p->pAig) );
280 }
281 ABC_FREE( pLatches );
282 if ( fKeepPos )
283 {
284 for ( f = 0; f < p->nFramesAll; f++ )
285 Aig_ManForEachPoSeq( p->pAig, pObj, i )
286 Aig_ObjCreateCo( pAigFrames, Bmc_ObjChild0Frames(pObj,f) );
287 Aig_ManCleanup( pAigFrames );
288 }
289 else
290 {
291 // add POs to all the dangling nodes
292 Aig_ManForEachObj( pAigFrames, pObjNew, i )
293 if ( Aig_ObjIsNode(pObjNew) && pObjNew->nRefs == 0 )
294 Aig_ObjCreateCo( pAigFrames, pObjNew );
295 }
296 // return the new manager
297 return pAigFrames;
298}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition aig.h:447
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
int Aig_ManCleanup(Aig_Man_t *p)
Definition aigMan.c:265
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition aig.h:438
#define Aig_ManForEachPoSeq(p, pObj, i)
Definition aig.h:444
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition aig.h:441
unsigned int nRefs
Definition aig.h:81
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fra_BmcNodeIsConst()

int Fra_BmcNodeIsConst ( Aig_Obj_t * pObj)

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

Synopsis [Returns 1 if the node is costant.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file fraBmc.c.

104{
105 Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
106 return Fra_BmcNodesAreEqual( pObj, Aig_ManConst1(p->pManAig) );
107}
int Fra_BmcNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
FUNCTION DEFINITIONS ///.
Definition fraBmc.c:72
struct Fra_Man_t_ Fra_Man_t
Definition fra.h:56
void * pData
Definition aig.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fra_BmcNodesAreEqual()

int Fra_BmcNodesAreEqual ( Aig_Obj_t * pObj0,
Aig_Obj_t * pObj1 )

FUNCTION DEFINITIONS ///.

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

Synopsis [Returns 1 if the nodes are equivalent.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file fraBmc.c.

73{
74 Fra_Man_t * p = (Fra_Man_t *)pObj0->pData;
75 Aig_Obj_t * pObjFrames0, * pObjFrames1;
76 Aig_Obj_t * pObjFraig0, * pObjFraig1;
77 int i;
78 for ( i = p->pBmc->nPref; i < p->pBmc->nFramesAll; i++ )
79 {
80 pObjFrames0 = Aig_Regular( Bmc_ObjFrames(pObj0, i) );
81 pObjFrames1 = Aig_Regular( Bmc_ObjFrames(pObj1, i) );
82 if ( pObjFrames0 == pObjFrames1 )
83 continue;
84 pObjFraig0 = Aig_Regular( Bmc_ObjFraig(pObjFrames0) );
85 pObjFraig1 = Aig_Regular( Bmc_ObjFraig(pObjFrames1) );
86 if ( pObjFraig0 != pObjFraig1 )
87 return 0;
88 }
89 return 1;
90}
Here is the caller graph for this function:

◆ Fra_BmcPerform()

void Fra_BmcPerform ( Fra_Man_t * p,
int nPref,
int nDepth )

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

Synopsis [Performs BMC for the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file fraBmc.c.

312{
313 Aig_Obj_t * pObj;
314 int i, nImpsOld = 0;
315 abctime clk = Abc_Clock();
316 assert( p->pBmc == NULL );
317 // derive and fraig the frames
318 p->pBmc = Fra_BmcStart( p->pManAig, nPref, nDepth );
319 p->pBmc->pAigFrames = Fra_BmcFrames( p->pBmc, 0 );
320 // if implications are present, configure the AIG manager to check them
321 if ( p->pCla->vImps )
322 {
323 p->pBmc->pAigFrames->pImpFunc = (void (*) (void*, void*))Fra_BmcFilterImplications;
324 p->pBmc->pAigFrames->pImpData = p->pBmc;
325 p->pBmc->vImps = p->pCla->vImps;
326 nImpsOld = Vec_IntSize(p->pCla->vImps);
327 }
328 p->pBmc->pAigFraig = Fra_FraigEquivence( p->pBmc->pAigFrames, 1000000, 0 );
329 p->pBmc->pObjToFraig = p->pBmc->pAigFrames->pObjCopies;
330 p->pBmc->pAigFrames->pObjCopies = NULL;
331 // annotate frames nodes with pointers to the manager
332 Aig_ManForEachObj( p->pBmc->pAigFrames, pObj, i )
333 pObj->pData = p;
334 // report the results
335 if ( p->pPars->fVerbose )
336 {
337 printf( "Original AIG = %d. Init %d frames = %d. Fraig = %d. ",
338 Aig_ManNodeNum(p->pBmc->pAig), p->pBmc->nFramesAll,
339 Aig_ManNodeNum(p->pBmc->pAigFrames), Aig_ManNodeNum(p->pBmc->pAigFraig) );
340 ABC_PRT( "Time", Abc_Clock() - clk );
341 printf( "Before BMC: " );
342// Fra_ClassesPrint( p->pCla, 0 );
343 printf( "Const = %5d. Class = %5d. Lit = %5d. ",
344 Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
345 if ( p->pCla->vImps )
346 printf( "Imp = %5d. ", nImpsOld );
347 printf( "\n" );
348 }
349 // refine the classes
350 p->pCla->pFuncNodeIsConst = Fra_BmcNodeIsConst;
351 p->pCla->pFuncNodesAreEqual = Fra_BmcNodesAreEqual;
352 Fra_ClassesRefine( p->pCla );
353 Fra_ClassesRefine1( p->pCla, 1, NULL );
354 p->pCla->pFuncNodeIsConst = Fra_SmlNodeIsConst;
355 p->pCla->pFuncNodesAreEqual = Fra_SmlNodesAreEqual;
356 // report the results
357 if ( p->pPars->fVerbose )
358 {
359 printf( "After BMC: " );
360// Fra_ClassesPrint( p->pCla, 0 );
361 printf( "Const = %5d. Class = %5d. Lit = %5d. ",
362 Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla) );
363 if ( p->pCla->vImps )
364 printf( "Imp = %5d. ", Vec_IntSize(p->pCla->vImps) );
365 printf( "\n" );
366 }
367 // free the BMC manager
368 Fra_BmcStop( p->pBmc );
369 p->pBmc = NULL;
370}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Fra_Bmc_t * Fra_BmcStart(Aig_Man_t *pAig, int nPref, int nDepth)
Definition fraBmc.c:191
void Fra_BmcStop(Fra_Bmc_t *p)
Definition fraBmc.c:216
Aig_Man_t * Fra_BmcFrames(Fra_Bmc_t *p, int fKeepPos)
Definition fraBmc.c:237
void Fra_BmcFilterImplications(Fra_Man_t *p, Fra_Bmc_t *pBmc)
Definition fraBmc.c:121
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition fraClass.c:527
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition fraSim.c:86
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition fraCore.c:468
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition fraClass.c:493
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition fraClass.c:164
int Fra_BmcNodeIsConst(Aig_Obj_t *pObj)
Definition fraBmc.c:103
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition fraSim.c:109
int Fra_BmcNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
FUNCTION DEFINITIONS ///.
Definition fraBmc.c:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fra_BmcPerformSimple()

void Fra_BmcPerformSimple ( Aig_Man_t * pAig,
int nFrames,
int nBTLimit,
int fRewrite,
int fVerbose )

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

Synopsis [Performs BMC for the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 383 of file fraBmc.c.

384{
385 extern Fra_Man_t * Fra_LcrAigPrepare( Aig_Man_t * pAig );
386 Fra_Man_t * pTemp;
387 Fra_Bmc_t * pBmc;
388 Aig_Man_t * pAigTemp;
389 abctime clk;
390 int iOutput;
391 // derive and fraig the frames
392 clk = Abc_Clock();
393 pBmc = Fra_BmcStart( pAig, 0, nFrames );
394 pTemp = Fra_LcrAigPrepare( pAig );
395 pTemp->pBmc = pBmc;
396 pBmc->pAigFrames = Fra_BmcFrames( pBmc, 1 );
397 if ( fVerbose )
398 {
399 printf( "AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
400 Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), Aig_ManRegNum(pAig),
401 Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
402 printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
403 nFrames, Aig_ManCiNum(pBmc->pAigFrames), Aig_ManCoNum(pBmc->pAigFrames),
404 Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) );
405 ABC_PRT( "Time", Abc_Clock() - clk );
406 }
407 if ( fRewrite )
408 {
409 clk = Abc_Clock();
410 pBmc->pAigFrames = Dar_ManRwsat( pAigTemp = pBmc->pAigFrames, 1, 0 );
411 Aig_ManStop( pAigTemp );
412 if ( fVerbose )
413 {
414 printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
415 Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) );
416 ABC_PRT( "Time", Abc_Clock() - clk );
417 }
418 }
419 clk = Abc_Clock();
420 iOutput = Fra_FraigMiterAssertedOutput( pBmc->pAigFrames );
421 if ( iOutput >= 0 )
422 pAig->pSeqModel = Abc_CexMakeTriv( Aig_ManRegNum(pAig), Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), iOutput );
423 else
424 {
425 pBmc->pAigFraig = Fra_FraigEquivence( pBmc->pAigFrames, nBTLimit, 1 );
426 iOutput = Fra_FraigMiterAssertedOutput( pBmc->pAigFraig );
427 if ( pBmc->pAigFraig->pData )
428 {
429 pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, (int *)pBmc->pAigFraig->pData );
430 ABC_FREE( pBmc->pAigFraig->pData );
431 }
432 else if ( iOutput >= 0 )
433 pAig->pSeqModel = Abc_CexMakeTriv( Aig_ManRegNum(pAig), Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig), Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig), iOutput );
434 }
435 if ( fVerbose )
436 {
437 printf( "Fraiged init frames: Node = %6d. Lev = %5d. ",
438 pBmc->pAigFraig? Aig_ManNodeNum(pBmc->pAigFraig) : -1,
439 pBmc->pAigFraig? Aig_ManLevelNum(pBmc->pAigFraig) : -1 );
440 ABC_PRT( "Time", Abc_Clock() - clk );
441 }
442 Fra_BmcStop( pBmc );
443 ABC_FREE( pTemp );
444}
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition darScript.c:71
int Aig_ManLevelNum(Aig_Man_t *p)
Definition aigDfs.c:500
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
Fra_Man_t * Fra_LcrAigPrepare(Aig_Man_t *pAig)
Definition fraLcr.c:158
struct Fra_Bmc_t_ Fra_Bmc_t
Definition fra.h:59
Abc_Cex_t * Fra_SmlCopyCounterExample(Aig_Man_t *pAig, Aig_Man_t *pFrames, int *pModel)
Definition fraSim.c:1123
int Fra_FraigMiterAssertedOutput(Aig_Man_t *p)
Definition fraCore.c:125
Aig_Man_t * pAigFraig
Definition fraBmc.c:42
Fra_Bmc_t * pBmc
Definition fra.h:202
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)
Definition utilCex.c:85
Here is the call graph for this function:

◆ Fra_BmcStart()

Fra_Bmc_t * Fra_BmcStart ( Aig_Man_t * pAig,
int nPref,
int nDepth )

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

Synopsis [Starts the BMC manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 191 of file fraBmc.c.

192{
193 Fra_Bmc_t * p;
194 p = ABC_ALLOC( Fra_Bmc_t, 1 );
195 memset( p, 0, sizeof(Fra_Bmc_t) );
196 p->pAig = pAig;
197 p->nPref = nPref;
198 p->nDepth = nDepth;
199 p->nFramesAll = nPref + nDepth;
200 p->pObjToFrames = ABC_ALLOC( Aig_Obj_t *, p->nFramesAll * Aig_ManObjNumMax(pAig) );
201 memset( p->pObjToFrames, 0, sizeof(Aig_Obj_t *) * p->nFramesAll * Aig_ManObjNumMax(pAig) );
202 return p;
203}
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Fra_BmcStop()

void Fra_BmcStop ( Fra_Bmc_t * p)

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

Synopsis [Stops the BMC manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 216 of file fraBmc.c.

217{
218 Aig_ManStop( p->pAigFrames );
219 if ( p->pAigFraig )
220 Aig_ManStop( p->pAigFraig );
221 ABC_FREE( p->pObjToFrames );
222 ABC_FREE( p->pObjToFraig );
223 ABC_FREE( p );
224}
Here is the call graph for this function:
Here is the caller graph for this function: