ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sswDyn.c
Go to the documentation of this file.
1
20
21#include "sswInt.h"
22#include "misc/bar/bar.h"
23
25
26
30
34
47{
48 Aig_Obj_t * pObj, * pObjFrames;
49 int f, i;
50 Aig_ManConst1( p->pFrames )->fMarkA = 1;
51 Aig_ManConst1( p->pFrames )->fMarkB = 1;
52 for ( f = 0; f < p->nFrames; f++ )
53 {
54 Saig_ManForEachPi( p->pAig, pObj, i )
55 {
56 pObjFrames = Ssw_ObjFrame( p, pObj, f );
57 assert( Aig_ObjIsCi(pObjFrames) );
58 assert( pObjFrames->fMarkB == 0 );
59 pObjFrames->fMarkA = 1;
60 pObjFrames->fMarkB = 1;
61 }
62 }
63}
64
76void Ssw_ManCollectPis_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vNewPis )
77{
78 assert( !Aig_IsComplement(pObj) );
79 if ( pObj->fMarkA )
80 return;
81 pObj->fMarkA = 1;
82 if ( Aig_ObjIsCi(pObj) )
83 {
84 Vec_PtrPush( vNewPis, pObj );
85 return;
86 }
87 assert( Aig_ObjIsNode(pObj) );
88 Ssw_ManCollectPis_rec( Aig_ObjFanin0(pObj), vNewPis );
89 Ssw_ManCollectPis_rec( Aig_ObjFanin1(pObj), vNewPis );
90}
91
104{
105 Aig_Obj_t * pFanout;
106 int iFanout = -1, i;
107 assert( !Aig_IsComplement(pObj) );
108 if ( pObj->fMarkB )
109 return;
110 pObj->fMarkB = 1;
111 if ( pObj->Id > p->nSRMiterMaxId )
112 return;
113 if ( Aig_ObjIsCo(pObj) )
114 {
115 // skip if it is a register input PO
116 if ( Aig_ObjCioId(pObj) >= Aig_ManCoNum(p->pFrames)-Aig_ManRegNum(p->pAig) )
117 return;
118 // add the number of this constraint
119 Vec_IntPush( vNewPos, Aig_ObjCioId(pObj)/2 );
120 return;
121 }
122 // visit the fanouts
123 assert( p->pFrames->pFanData != NULL );
124 Aig_ObjForEachFanout( p->pFrames, pObj, pFanout, iFanout, i )
125 Ssw_ManCollectPos_rec( p, pFanout, vNewPos );
126}
127
143{
144 Aig_Obj_t * pObjFrames, * pReprFrames;
145 Aig_Obj_t * pTemp, * pObj0, * pObj1;
146 int i, iConstr, RetValue;
147
148 assert( pRepr != pObj );
149 // get the corresponding frames nodes
150 pReprFrames = Aig_Regular( Ssw_ObjFrame( p, pRepr, p->pPars->nFramesK ) );
151 pObjFrames = Aig_Regular( Ssw_ObjFrame( p, pObj, p->pPars->nFramesK ) );
152 assert( pReprFrames != pObjFrames );
153 /*
154 // compute the AIG support
155 Vec_PtrClear( p->vNewLos );
156 Ssw_ManCollectPis_rec( pRepr, p->vNewLos );
157 Ssw_ManCollectPis_rec( pObj, p->vNewLos );
158 // add logic cones for register outputs
159 Vec_PtrForEachEntry( Aig_Obj_t *, p->vNewLos, pTemp, i )
160 {
161 pObj0 = Aig_Regular( Ssw_ObjFrame( p, pTemp, p->pPars->nFramesK ) );
162 Ssw_CnfNodeAddToSolver( p->pMSat, pObj0 );
163 }
164*/
165 // add cones for the nodes
166 Ssw_CnfNodeAddToSolver( p->pMSat, pReprFrames );
167 Ssw_CnfNodeAddToSolver( p->pMSat, pObjFrames );
168
169 // compute the frames support
170 Vec_PtrClear( p->vNewLos );
171 Ssw_ManCollectPis_rec( pReprFrames, p->vNewLos );
172 Ssw_ManCollectPis_rec( pObjFrames, p->vNewLos );
173 // these nodes include both nodes corresponding to PIs and LOs
174 // (the nodes corresponding to PIs should be labeled with fMarkB!)
175
176 // collect the related constraint POs
177 Vec_IntClear( p->vNewPos );
178 Vec_PtrForEachEntry( Aig_Obj_t *, p->vNewLos, pTemp, i )
179 Ssw_ManCollectPos_rec( p, pTemp, p->vNewPos );
180 // check if the corresponding pairs are added
181 Vec_IntForEachEntry( p->vNewPos, iConstr, i )
182 {
183 pObj0 = Aig_ManCo( p->pFrames, 2*iConstr );
184 pObj1 = Aig_ManCo( p->pFrames, 2*iConstr+1 );
185// if ( pObj0->fMarkB && pObj1->fMarkB )
186 if ( pObj0->fMarkB || pObj1->fMarkB )
187 {
188 pObj0->fMarkB = 1;
189 pObj1->fMarkB = 1;
190 Ssw_NodesAreConstrained( p, Aig_ObjChild0(pObj0), Aig_ObjChild0(pObj1) );
191 }
192 }
193 if ( p->pMSat->pSat->qtail != p->pMSat->pSat->qhead )
194 {
195 RetValue = sat_solver_simplify(p->pMSat->pSat);
196 assert( RetValue != 0 );
197 }
198}
199
212{
213 Aig_Obj_t * pObj, * pObjFraig;
214 unsigned * pInfo;
215 int i, f, nFrames;
216
217 // transfer simulation information
218 Aig_ManForEachCi( p->pAig, pObj, i )
219 {
220 pObjFraig = Ssw_ObjFrame( p, pObj, 0 );
221 if ( pObjFraig == Aig_ManConst0(p->pFrames) )
222 {
223 Ssw_SmlObjAssignConst( p->pSml, pObj, 0, 0 );
224 continue;
225 }
226 assert( !Aig_IsComplement(pObjFraig) );
227 assert( Aig_ObjIsCi(pObjFraig) );
228 pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjCioId(pObjFraig) );
229 Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, 0 );
230 }
231 // set random simulation info for the second frame
232 for ( f = 1; f < p->nFrames; f++ )
233 {
234 Saig_ManForEachPi( p->pAig, pObj, i )
235 {
236 pObjFraig = Ssw_ObjFrame( p, pObj, f );
237 assert( !Aig_IsComplement(pObjFraig) );
238 assert( Aig_ObjIsCi(pObjFraig) );
239 pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjCioId(pObjFraig) );
240 Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, f );
241 }
242 }
243 // create random info
244 nFrames = Ssw_SmlNumFrames( p->pSml );
245 for ( ; f < nFrames; f++ )
246 {
247 Saig_ManForEachPi( p->pAig, pObj, i )
248 Ssw_SmlAssignRandomFrame( p->pSml, pObj, f );
249 }
250}
251
264{
265 int RetValue1, RetValue2;
266 abctime clk = Abc_Clock();
267 // transfer PI simulation information from storage
268// Ssw_SmlAssignDist1Plus( p->pSml, p->pPatWords );
270 // simulate internal nodes
271// Ssw_SmlSimulateOneFrame( p->pSml );
272 Ssw_SmlSimulateOne( p->pSml );
273 // check equivalence classes
274 RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 1 );
275 RetValue2 = Ssw_ClassesRefine( p->ppClasses, 1 );
276 // prepare simulation info for the next round
277 Vec_PtrCleanSimInfo( p->vSimInfo, 0, 1 );
278 p->nPatterns = 0;
279 p->nSimRounds++;
280p->timeSimSat += Abc_Clock() - clk;
281 return RetValue1 > 0 || RetValue2 > 0;
282}
283
296{
297 Aig_Obj_t * pObj, * pRepr, ** ppClass;
298 int i, k, nSize, RetValue1, RetValue2;
299 abctime clk = Abc_Clock();
300 p->nSimRounds++;
301 // transfer PI simulation information from storage
302// Ssw_SmlAssignDist1Plus( p->pSml, p->pPatWords );
304 // determine const1 cands and classes to be simulated
305 Vec_PtrClear( p->vResimConsts );
306 Vec_PtrClear( p->vResimClasses );
307 Aig_ManIncrementTravId( p->pAig );
308 for ( i = p->iNodeStart; i < p->iNodeLast + p->pPars->nResimDelta; i++ )
309 {
310 if ( i >= Aig_ManObjNumMax( p->pAig ) )
311 break;
312 pObj = Aig_ManObj( p->pAig, i );
313 if ( pObj == NULL )
314 continue;
315 if ( Ssw_ObjIsConst1Cand(p->pAig, pObj) )
316 {
317 Vec_PtrPush( p->vResimConsts, pObj );
318 continue;
319 }
320 pRepr = Aig_ObjRepr(p->pAig, pObj);
321 if ( pRepr == NULL )
322 continue;
323 if ( Aig_ObjIsTravIdCurrent(p->pAig, pRepr) )
324 continue;
325 Aig_ObjSetTravIdCurrent(p->pAig, pRepr);
326 Vec_PtrPush( p->vResimClasses, pRepr );
327 }
328 // simulate internal nodes
329// Ssw_SmlSimulateOneFrame( p->pSml );
330// Ssw_SmlSimulateOne( p->pSml );
331 // resimulate dynamically
332// Aig_ManIncrementTravId( p->pAig );
333// Aig_ObjIsTravIdCurrent( p->pAig, Aig_ManConst1(p->pAig) );
334 p->nVisCounter++;
335 Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimConsts, pObj, i )
336 Ssw_SmlSimulateOneDyn_rec( p->pSml, pObj, p->nFrames-1, p->pVisited, p->nVisCounter );
337 // resimulate the cone of influence of the cand classes
338 Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimClasses, pRepr, i )
339 {
340 ppClass = Ssw_ClassesReadClass( p->ppClasses, pRepr, &nSize );
341 for ( k = 0; k < nSize; k++ )
342 Ssw_SmlSimulateOneDyn_rec( p->pSml, ppClass[k], p->nFrames-1, p->pVisited, p->nVisCounter );
343 }
344
345 // check equivalence classes
346// RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 1 );
347// RetValue2 = Ssw_ClassesRefine( p->ppClasses, 1 );
348 // refine these nodes
349 RetValue1 = Ssw_ClassesRefineConst1Group( p->ppClasses, p->vResimConsts, 1 );
350 RetValue2 = 0;
351 Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimClasses, pRepr, i )
352 RetValue2 += Ssw_ClassesRefineOneClass( p->ppClasses, pRepr, 1 );
353
354 // prepare simulation info for the next round
355 Vec_PtrCleanSimInfo( p->vSimInfo, 0, 1 );
356 p->nPatterns = 0;
357 p->nSimRounds++;
358p->timeSimSat += Abc_Clock() - clk;
359 return RetValue1 > 0 || RetValue2 > 0;
360}
361
374{
375 Bar_Progress_t * pProgress = NULL;
376 Aig_Obj_t * pObj, * pObjNew;
377 int i, f;
378 abctime clk;
379
380 // perform speculative reduction
381clk = Abc_Clock();
382 // create timeframes
383 p->pFrames = Ssw_FramesWithClasses( p );
384 Aig_ManFanoutStart( p->pFrames );
385 p->nSRMiterMaxId = Aig_ManObjNumMax( p->pFrames );
386
387 // map constants and PIs of the last frame
388 f = p->pPars->nFramesK;
389 Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
390 Saig_ManForEachPi( p->pAig, pObj, i )
391 Ssw_ObjSetFrame( p, pObj, f, Aig_ObjCreateCi(p->pFrames) );
392 Aig_ManSetCioIds( p->pFrames );
393 // label nodes corresponding to primary inputs
395p->timeReduce += Abc_Clock() - clk;
396
397 // prepare simulation info
398 assert( p->vSimInfo == NULL );
399 p->vSimInfo = Vec_PtrAllocSimInfo( Aig_ManCiNum(p->pFrames), 1 );
400 Vec_PtrCleanSimInfo( p->vSimInfo, 0, 1 );
401
402 // sweep internal nodes
403 p->fRefined = 0;
404 Ssw_ClassesClearRefined( p->ppClasses );
405 if ( p->pPars->fVerbose )
406 pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) );
407 p->iNodeStart = 0;
408 Aig_ManForEachObj( p->pAig, pObj, i )
409 {
410 if ( p->iNodeStart == 0 )
411 p->iNodeStart = i;
412 if ( p->pPars->fVerbose )
413 Bar_ProgressUpdate( pProgress, i, NULL );
414 if ( Saig_ObjIsLo(p->pAig, pObj) )
415 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 0, NULL );
416 else if ( Aig_ObjIsNode(pObj) )
417 {
418 pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
419 Ssw_ObjSetFrame( p, pObj, f, pObjNew );
420 p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 0, NULL );
421 }
422 // check if it is time to recycle the solver
423 if ( p->pMSat->pSat == NULL ||
424 (p->pPars->nSatVarMax2 &&
425 p->pMSat->nSatVars > p->pPars->nSatVarMax2 &&
426 p->nRecycleCalls > p->pPars->nRecycleCalls2) )
427 {
428 // resimulate
429 if ( p->nPatterns > 0 )
430 {
431 p->iNodeLast = i;
432 if ( p->pPars->fLocalSim )
434 else
436 p->iNodeStart = i+1;
437 }
438// Abc_Print( 1, "Recycling SAT solver with %d vars and %d calls.\n",
439// p->pMSat->nSatVars, p->nRecycleCalls );
440// Aig_ManCleanMarkAB( p->pAig );
441 Aig_ManCleanMarkAB( p->pFrames );
442 // label nodes corresponding to primary inputs
444 // replace the solver
445 if ( p->pMSat )
446 {
447 p->nVarsMax = Abc_MaxInt( p->nVarsMax, p->pMSat->nSatVars );
448 p->nCallsMax = Abc_MaxInt( p->nCallsMax, p->pMSat->nSolverCalls );
449 Ssw_SatStop( p->pMSat );
450 p->nRecycles++;
451 p->nRecyclesTotal++;
452 p->nRecycleCalls = 0;
453 }
454 p->pMSat = Ssw_SatStart( 0 );
455 assert( p->nPatterns == 0 );
456 }
457 // resimulate
458 if ( p->nPatterns == 32 )
459 {
460 p->iNodeLast = i;
461 if ( p->pPars->fLocalSim )
463 else
465 p->iNodeStart = i+1;
466 }
467 }
468 // resimulate
469 if ( p->nPatterns > 0 )
470 {
471 p->iNodeLast = i;
472 if ( p->pPars->fLocalSim )
474 else
476 }
477 // collect stats
478 if ( p->pPars->fVerbose )
479 Bar_ProgressStop( pProgress );
480
481 // cleanup
482// Ssw_ClassesCheck( p->ppClasses );
483 return p->fRefined;
484}
485
489
490
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigFanout.c:56
void Aig_ManSetCioIds(Aig_Man_t *p)
Definition aigUtil.c:978
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition aig.h:427
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigUtil.c:44
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
void Aig_ManCleanMarkAB(Aig_Man_t *p)
Definition aigUtil.c:186
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
Cube * p
Definition exorList.c:222
#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
Aig_Obj_t ** Ssw_ClassesReadClass(Ssw_Cla_t *p, Aig_Obj_t *pRepr, int *pnSize)
Definition sswClass.c:307
int Ssw_ClassesRefineConst1Group(Ssw_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
Definition sswClass.c:1074
void Ssw_ClassesClearRefined(Ssw_Cla_t *p)
Definition sswClass.c:243
int Ssw_ClassesRefineConst1(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1119
int Ssw_ClassesRefineOneClass(Ssw_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition sswClass.c:970
int Ssw_ClassesRefine(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1034
void Ssw_SatStop(Ssw_Sat_t *p)
Definition sswCnf.c:81
void Ssw_CnfNodeAddToSolver(Ssw_Sat_t *p, Aig_Obj_t *pObj)
Definition sswCnf.c:351
ABC_NAMESPACE_IMPL_START Ssw_Sat_t * Ssw_SatStart(int fPolarFlip)
DECLARATIONS ///.
Definition sswCnf.c:45
int Ssw_ManSweepResimulateDynLocal(Ssw_Man_t *p, int f)
Definition sswDyn.c:295
int Ssw_ManSweepDyn(Ssw_Man_t *p)
Definition sswDyn.c:373
void Ssw_ManLoadSolver(Ssw_Man_t *p, Aig_Obj_t *pRepr, Aig_Obj_t *pObj)
Definition sswDyn.c:142
void Ssw_ManCollectPis_rec(Aig_Obj_t *pObj, Vec_Ptr_t *vNewPis)
Definition sswDyn.c:76
int Ssw_ManSweepResimulateDyn(Ssw_Man_t *p, int f)
Definition sswDyn.c:263
void Ssw_ManSweepTransferDyn(Ssw_Man_t *p)
Definition sswDyn.c:211
ABC_NAMESPACE_IMPL_START void Ssw_ManLabelPiNodes(Ssw_Man_t *p)
DECLARATIONS ///.
Definition sswDyn.c:46
void Ssw_ManCollectPos_rec(Ssw_Man_t *p, Aig_Obj_t *pObj, Vec_Int_t *vNewPos)
Definition sswDyn.c:103
typedefABC_NAMESPACE_HEADER_START struct Ssw_Man_t_ Ssw_Man_t
INCLUDES ///.
Definition sswInt.h:47
void Ssw_SmlAssignRandomFrame(Ssw_Sml_t *p, Aig_Obj_t *pObj, int iFrame)
Definition sswSim.c:538
void Ssw_SmlSimulateOne(Ssw_Sml_t *p)
Definition sswSim.c:1005
int Ssw_ManSweepNode(Ssw_Man_t *p, Aig_Obj_t *pObj, int f, int fBmc, Vec_Int_t *vPairs)
Definition sswSweep.c:187
void Ssw_SmlSimulateOneDyn_rec(Ssw_Sml_t *p, Aig_Obj_t *pObj, int f, int *pVisited, int nVisCounter)
Definition sswSim.c:1076
void Ssw_SmlObjSetWord(Ssw_Sml_t *p, Aig_Obj_t *pObj, unsigned Word, int iWord, int iFrame)
Definition sswSim.c:603
void Ssw_SmlObjAssignConst(Ssw_Sml_t *p, Aig_Obj_t *pObj, int fConst1, int iFrame)
Definition sswSim.c:560
int Ssw_NodesAreConstrained(Ssw_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew)
Definition sswSat.c:196
int Ssw_SmlNumFrames(Ssw_Sml_t *p)
Definition sswSim.c:1288
int Id
Definition aig.h:85
unsigned int fMarkB
Definition aig.h:80
unsigned int fMarkA
Definition aig.h:79
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55