ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sswSweep.c File Reference
#include "sswInt.h"
#include "misc/bar/bar.h"
Include dependency graph for sswSweep.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Ssw_ManGetSatVarValue (Ssw_Man_t *p, Aig_Obj_t *pObj, int f)
 DECLARATIONS ///.
 
void Ssw_CheckConstraints (Ssw_Man_t *p)
 
void Ssw_SmlSavePatternAigPhase (Ssw_Man_t *p, int f)
 
void Ssw_SmlSavePatternAig (Ssw_Man_t *p, int f)
 
void Ssw_SmlAddPatternDyn (Ssw_Man_t *p)
 
int Ssw_ManSweepNode (Ssw_Man_t *p, Aig_Obj_t *pObj, int f, int fBmc, Vec_Int_t *vPairs)
 
int Ssw_ManSweepBmc (Ssw_Man_t *p)
 
void Ssw_ManDumpEquivMiter (Aig_Man_t *p, Vec_Int_t *vPairs, int Num, int fAddOuts)
 
int Ssw_ManSweep (Ssw_Man_t *p)
 

Function Documentation

◆ Ssw_CheckConstraints()

void Ssw_CheckConstraints ( Ssw_Man_t * p)

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

Synopsis [Performs fraiging for the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file sswSweep.c.

85{
86 Aig_Obj_t * pObj, * pObj2;
87 int nConstrPairs, i;
88 int Counter = 0;
89 nConstrPairs = Aig_ManCoNum(p->pFrames)-Aig_ManRegNum(p->pAig);
90 assert( (nConstrPairs & 1) == 0 );
91 for ( i = 0; i < nConstrPairs; i += 2 )
92 {
93 pObj = Aig_ManCo( p->pFrames, i );
94 pObj2 = Aig_ManCo( p->pFrames, i+1 );
95 if ( Ssw_NodesAreEquiv( p, Aig_ObjFanin0(pObj), Aig_ObjFanin0(pObj2) ) != 1 )
96 {
97 Ssw_NodesAreConstrained( p, Aig_ObjChild0(pObj), Aig_ObjChild0(pObj2) );
98 Counter++;
99 }
100 }
101 Abc_Print( 1, "Total constraints = %d. Added constraints = %d.\n", nConstrPairs/2, Counter );
102}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
Cube * p
Definition exorList.c:222
int Ssw_NodesAreEquiv(Ssw_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
DECLARATIONS ///.
Definition sswSat.c:45
int Ssw_NodesAreConstrained(Ssw_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition sswSat.c:196
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Ssw_ManDumpEquivMiter()

void Ssw_ManDumpEquivMiter ( Aig_Man_t * p,
Vec_Int_t * vPairs,
int Num,
int fAddOuts )

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

Synopsis [Generates AIG with the following nodes put into seq miters.]

Description []

SideEffects []

SeeAlso []

Definition at line 342 of file sswSweep.c.

343{
344 FILE * pFile;
345 char pBuffer[16];
346 Aig_Man_t * pNew;
347 sprintf( pBuffer, "equiv%03d.aig", Num );
348 pFile = fopen( pBuffer, "w" );
349 if ( pFile == NULL )
350 {
351 Abc_Print( 1, "Cannot open file %s for writing.\n", pBuffer );
352 return;
353 }
354 fclose( pFile );
355 pNew = Saig_ManCreateEquivMiter( p, vPairs, fAddOuts );
356 Ioa_WriteAiger( pNew, pBuffer, 0, 0 );
357 Aig_ManStop( pNew );
358 Abc_Print( 1, "AIG with %4d disproved equivs is dumped into file \"%s\".\n", Vec_IntSize(vPairs)/2, pBuffer );
359}
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Aig_Man_t * Saig_ManCreateEquivMiter(Aig_Man_t *pAig, Vec_Int_t *vPairs, int fAddOuts)
Definition saigDup.c:91
char * sprintf()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_ManGetSatVarValue()

ABC_NAMESPACE_IMPL_START int Ssw_ManGetSatVarValue ( Ssw_Man_t * p,
Aig_Obj_t * pObj,
int f )

DECLARATIONS ///.

CFile****************************************************************

FileName [sswSweep.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Inductive prover with constraints.]

Synopsis [One round of SAT sweeping.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 1, 2008.]

Revision [

Id
sswSweep.c,v 1.00 2008/09/01 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Retrives value of the PI in the original AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file sswSweep.c.

47{
48 int fUseNoBoundary = 0;
49 Aig_Obj_t * pObjFraig;
50 int Value;
51// assert( Aig_ObjIsCi(pObj) );
52 pObjFraig = Ssw_ObjFrame( p, pObj, f );
53 if ( fUseNoBoundary )
54 {
55 Value = Ssw_CnfGetNodeValue( p->pMSat, Aig_Regular(pObjFraig) );
56 Value ^= Aig_IsComplement(pObjFraig);
57 }
58 else
59 {
60 int nVarNum = Ssw_ObjSatNum( p->pMSat, Aig_Regular(pObjFraig) );
61 Value = (!nVarNum)? 0 : (Aig_IsComplement(pObjFraig) ^ sat_solver_var_value( p->pMSat->pSat, nVarNum ));
62 }
63
64// Value = (Aig_IsComplement(pObjFraig) ^ ((!nVarNum)? 0 : sat_solver_var_value( p->pSat, nVarNum )));
65// Value = (!nVarNum)? Aig_ManRandom(0) & 1 : (Aig_IsComplement(pObjFraig) ^ sat_solver_var_value( p->pSat, nVarNum ));
66 if ( p->pPars->fPolarFlip )
67 {
68 if ( Aig_Regular(pObjFraig)->fPhase ) Value ^= 1;
69 }
70 return Value;
71}
int Ssw_CnfGetNodeValue(Ssw_Sat_t *p, Aig_Obj_t *pObj)
Definition sswCnf.c:402
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_ManSweep()

int Ssw_ManSweep ( Ssw_Man_t * p)

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

Synopsis [Performs fraiging for the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 373 of file sswSweep.c.

374{
375 static int Counter;
376 Bar_Progress_t * pProgress = NULL;
377 Aig_Obj_t * pObj, * pObj2, * pObjNew;
378 int nConstrPairs, i, f;
379 abctime clk;
380 Vec_Int_t * vObjPairs;
381
382 // perform speculative reduction
383clk = Abc_Clock();
384 // create timeframes
385 p->pFrames = Ssw_FramesWithClasses( p );
386 // add constants
387 nConstrPairs = Aig_ManCoNum(p->pFrames)-Aig_ManRegNum(p->pAig);
388 assert( (nConstrPairs & 1) == 0 );
389 for ( i = 0; i < nConstrPairs; i += 2 )
390 {
391 pObj = Aig_ManCo( p->pFrames, i );
392 pObj2 = Aig_ManCo( p->pFrames, i+1 );
393 Ssw_NodesAreConstrained( p, Aig_ObjChild0(pObj), Aig_ObjChild0(pObj2) );
394 }
395 // build logic cones for register inputs
396 for ( i = 0; i < Aig_ManRegNum(p->pAig); i++ )
397 {
398 pObj = Aig_ManCo( p->pFrames, nConstrPairs + i );
399 Ssw_CnfNodeAddToSolver( p->pMSat, Aig_ObjFanin0(pObj) );//
400 }
401 sat_solver_simplify( p->pMSat->pSat );
402
403 // map constants and PIs of the last frame
404 f = p->pPars->nFramesK;
405 Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
406 Saig_ManForEachPi( p->pAig, pObj, i )
407 Ssw_ObjSetFrame( p, pObj, f, Aig_ObjCreateCi(p->pFrames) );
408p->timeReduce += Abc_Clock() - clk;
409
410 // sweep internal nodes
411 p->fRefined = 0;
412 Ssw_ClassesClearRefined( p->ppClasses );
413 if ( p->pPars->fVerbose )
414 pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) );
415 vObjPairs = (p->pPars->fEquivDump || p->pPars->fEquivDump2)? Vec_IntAlloc(1000) : NULL;
416 Aig_ManForEachObj( p->pAig, pObj, i )
417 {
418 if ( p->pPars->fVerbose )
419 Bar_ProgressUpdate( pProgress, i, NULL );
420 if ( Saig_ObjIsLo(p->pAig, pObj) )
421 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 0, vObjPairs );
422 else if ( Aig_ObjIsNode(pObj) )
423 {
424 pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
425 Ssw_ObjSetFrame( p, pObj, f, pObjNew );
426 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 0, vObjPairs );
427 }
428 }
429 if ( p->pPars->fVerbose )
430 Bar_ProgressStop( pProgress );
431
432 // cleanup
433// Ssw_ClassesCheck( p->ppClasses );
434 if ( p->pPars->fEquivDump )
435 Ssw_ManDumpEquivMiter( p->pAig, vObjPairs, Counter++, 1 );
436 if ( p->pPars->fEquivDump2 && !p->fRefined )
437 Ssw_ManDumpEquivMiter( p->pAig, vObjPairs, 0, 0 );
438 Vec_IntFreeP( &vObjPairs );
439 return p->fRefined;
440}
ABC_INT64_T abctime
Definition abc_global.h:332
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
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_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
void Bar_ProgressStop(Bar_Progress_t *p)
Definition bar.c:126
Bar_Progress_t * Bar_ProgressStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition bar.c:66
struct Bar_Progress_t_ Bar_Progress_t
BASIC TYPES ///.
Definition bar.h:48
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
int sat_solver_simplify(sat_solver *s)
Definition satSolver.c:1515
Aig_Man_t * Ssw_FramesWithClasses(Ssw_Man_t *p)
Definition sswAig.c:203
void Ssw_ClassesClearRefined(Ssw_Cla_t *p)
Definition sswClass.c:243
void Ssw_CnfNodeAddToSolver(Ssw_Sat_t *p, Aig_Obj_t *pObj)
Definition sswCnf.c:351
void Ssw_ManDumpEquivMiter(Aig_Man_t *p, Vec_Int_t *vPairs, int Num, int fAddOuts)
Definition sswSweep.c:342
int Ssw_ManSweepNode(Ssw_Man_t *p, Aig_Obj_t *pObj, int f, int fBmc, Vec_Int_t *vPairs)
Definition sswSweep.c:187
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_ManSweepBmc()

int Ssw_ManSweepBmc ( Ssw_Man_t * p)

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

Synopsis [Performs fraiging for the internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file sswSweep.c.

273{
274 Bar_Progress_t * pProgress = NULL;
275 Aig_Obj_t * pObj, * pObjNew, * pObjLi, * pObjLo;
276 int i, f;
277 abctime clk;
278clk = Abc_Clock();
279
280 // start initialized timeframes
281 p->pFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
282 Saig_ManForEachLo( p->pAig, pObj, i )
283 Ssw_ObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrames) );
284
285 // sweep internal nodes
286 p->fRefined = 0;
287 if ( p->pPars->fVerbose )
288 pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
289 for ( f = 0; f < p->pPars->nFramesK; f++ )
290 {
291 // map constants and PIs
292 Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
293 Saig_ManForEachPi( p->pAig, pObj, i )
294 Ssw_ObjSetFrame( p, pObj, f, Aig_ObjCreateCi(p->pFrames) );
295 // sweep flops
296 Saig_ManForEachLo( p->pAig, pObj, i )
297 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 1, NULL );
298 // sweep internal nodes
299 Aig_ManForEachNode( p->pAig, pObj, i )
300 {
301 if ( p->pPars->fVerbose )
302 Bar_ProgressUpdate( pProgress, Aig_ManObjNumMax(p->pAig) * f + i, NULL );
303 pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
304 Ssw_ObjSetFrame( p, pObj, f, pObjNew );
305 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 1, NULL );
306 }
307 // quit if this is the last timeframe
308 if ( f == p->pPars->nFramesK - 1 )
309 break;
310 // transfer latch input to the latch outputs
311 Aig_ManForEachCo( p->pAig, pObj, i )
312 Ssw_ObjSetFrame( p, pObj, f, Ssw_ObjChild0Fra(p, pObj, f) );
313 // build logic cones for register outputs
314 Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
315 {
316 pObjNew = Ssw_ObjFrame( p, pObjLi, f );
317 Ssw_ObjSetFrame( p, pObjLo, f+1, pObjNew );
318 Ssw_CnfNodeAddToSolver( p->pMSat, Aig_Regular(pObjNew) );//
319 }
320 }
321 if ( p->pPars->fVerbose )
322 Bar_ProgressStop( pProgress );
323
324 // cleanup
325// Ssw_ClassesCheck( p->ppClasses );
326p->timeBmc += Abc_Clock() - clk;
327 return p->fRefined;
328}
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_ManSweepNode()

int Ssw_ManSweepNode ( Ssw_Man_t * p,
Aig_Obj_t * pObj,
int f,
int fBmc,
Vec_Int_t * vPairs )

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

Synopsis [Performs fraiging for one node.]

Description [Returns the fraiged node.]

SideEffects []

SeeAlso []

Definition at line 187 of file sswSweep.c.

188{
189 Aig_Obj_t * pObjRepr, * pObjFraig, * pObjFraig2, * pObjReprFraig;
190 int RetValue;
191 abctime clk;
192 // get representative of this class
193 pObjRepr = Aig_ObjRepr( p->pAig, pObj );
194 if ( pObjRepr == NULL )
195 return 0;
196 // get the fraiged node
197 pObjFraig = Ssw_ObjFrame( p, pObj, f );
198 // get the fraiged representative
199 pObjReprFraig = Ssw_ObjFrame( p, pObjRepr, f );
200 // check if constant 0 pattern distinquishes these nodes
201 assert( pObjFraig != NULL && pObjReprFraig != NULL );
202 assert( (pObj->fPhase == pObjRepr->fPhase) == (Aig_ObjPhaseReal(pObjFraig) == Aig_ObjPhaseReal(pObjReprFraig)) );
203 // if the fraiged nodes are the same, return
204 if ( Aig_Regular(pObjFraig) == Aig_Regular(pObjReprFraig) )
205 return 0;
206 // add constraints on demand
207 if ( !fBmc && p->pPars->fDynamic )
208 {
209clk = Abc_Clock();
210 Ssw_ManLoadSolver( p, pObjRepr, pObj );
211 p->nRecycleCalls++;
212p->timeMarkCones += Abc_Clock() - clk;
213 }
214 // call equivalence checking
215 if ( Aig_Regular(pObjFraig) != Aig_ManConst1(p->pFrames) )
216 RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjReprFraig), Aig_Regular(pObjFraig) );
217 else
218 RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjFraig), Aig_Regular(pObjReprFraig) );
219 if ( RetValue == 1 ) // proved equivalent
220 {
221 pObjFraig2 = Aig_NotCond( pObjReprFraig, pObj->fPhase ^ pObjRepr->fPhase );
222 Ssw_ObjSetFrame( p, pObj, f, pObjFraig2 );
223 if ( p->pPars->fEquivDump2 && vPairs )
224 {
225 Vec_IntPush( vPairs, pObjRepr->Id );
226 Vec_IntPush( vPairs, pObj->Id );
227 }
228 return 0;
229 }
230 if ( p->pPars->fEquivDump && vPairs )
231 {
232 Vec_IntPush( vPairs, pObjRepr->Id );
233 Vec_IntPush( vPairs, pObj->Id );
234 }
235 if ( RetValue == -1 ) // timed out
236 {
237 Ssw_ClassesRemoveNode( p->ppClasses, pObj );
238 return 1;
239 }
240 // disproved the equivalence
241 if ( !fBmc && p->pPars->fDynamic )
242 {
244 p->nPatterns++;
245 return 1;
246 }
247 else
249 if ( !p->pPars->fConstrs )
250 Ssw_ManResimulateWord( p, pObj, pObjRepr, f );
251 else
252 Ssw_ManResimulateBit( p, pObj, pObjRepr );
253 assert( Aig_ObjRepr( p->pAig, pObj ) != pObjRepr );
254 if ( Aig_ObjRepr( p->pAig, pObj ) == pObjRepr )
255 {
256 Abc_Print( 1, "Ssw_ManSweepNode(): Failed to refine representative.\n" );
257 }
258 return 1;
259}
void Ssw_ClassesRemoveNode(Ssw_Cla_t *p, Aig_Obj_t *pObj)
Definition sswClass.c:448
void Ssw_ManLoadSolver(Ssw_Man_t *p, Aig_Obj_t *pRepr, Aig_Obj_t *pObj)
Definition sswDyn.c:142
void Ssw_ManResimulateBit(Ssw_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
DECLARATIONS ///.
Definition sswSimSat.c:45
void Ssw_ManResimulateWord(Ssw_Man_t *p, Aig_Obj_t *pCand, Aig_Obj_t *pRepr, int f)
Definition sswSimSat.c:92
void Ssw_SmlSavePatternAig(Ssw_Man_t *p, int f)
Definition sswSweep.c:136
void Ssw_SmlAddPatternDyn(Ssw_Man_t *p)
Definition sswSweep.c:157
int Id
Definition aig.h:85
unsigned int fPhase
Definition aig.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_SmlAddPatternDyn()

void Ssw_SmlAddPatternDyn ( Ssw_Man_t * p)

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

Synopsis [Saves one counter-example into internal storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 157 of file sswSweep.c.

158{
159 Aig_Obj_t * pObj;
160 unsigned * pInfo;
161 int i, nVarNum;
162 // iterate through the PIs of the frames
163 Vec_PtrForEachEntry( Aig_Obj_t *, p->pMSat->vUsedPis, pObj, i )
164 {
165 assert( Aig_ObjIsCi(pObj) );
166 nVarNum = Ssw_ObjSatNum( p->pMSat, pObj );
167 assert( nVarNum > 0 );
168 if ( sat_solver_var_value( p->pMSat->pSat, nVarNum ) )
169 {
170 pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjCioId(pObj) );
171 Abc_InfoSetBit( pInfo, p->nPatterns );
172 }
173 }
174}
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the caller graph for this function:

◆ Ssw_SmlSavePatternAig()

void Ssw_SmlSavePatternAig ( Ssw_Man_t * p,
int f )

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

Synopsis [Copy pattern from the solver into the internal storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file sswSweep.c.

137{
138 Aig_Obj_t * pObj;
139 int i;
140 memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
141 Aig_ManForEachCi( p->pAig, pObj, i )
142 if ( Ssw_ManGetSatVarValue( p, pObj, f ) )
143 Abc_InfoSetBit( p->pPatWords, i );
144}
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
ABC_NAMESPACE_IMPL_START int Ssw_ManGetSatVarValue(Ssw_Man_t *p, Aig_Obj_t *pObj, int f)
DECLARATIONS ///.
Definition sswSweep.c:46
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_SmlSavePatternAigPhase()

void Ssw_SmlSavePatternAigPhase ( Ssw_Man_t * p,
int f )

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

Synopsis [Copy pattern from the solver into the internal storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file sswSweep.c.

116{
117 Aig_Obj_t * pObj;
118 int i;
119 memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
120 Aig_ManForEachCi( p->pAig, pObj, i )
121 if ( Aig_ObjPhaseReal( Ssw_ObjFrame(p, pObj, f) ) )
122 Abc_InfoSetBit( p->pPatWords, i );
123}
Here is the call graph for this function: