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

Go to the source code of this file.

Classes

struct  Ssw_RarMan_t_
 

Functions

int Ssw_RarSimulate2 (Aig_Man_t *pAig, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, int fVerbose)
 
int Ssw_RarSignalFilter2 (Aig_Man_t *pAig, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, Abc_Cex_t *pCex, int fLatchOnly, int fVerbose)
 
int Ssw_RarSignalFilterGia2 (Gia_Man_t *p, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, Abc_Cex_t *pCex, int fLatchOnly, int fVerbose)
 

Function Documentation

◆ Ssw_RarSignalFilter2()

int Ssw_RarSignalFilter2 ( Aig_Man_t * pAig,
int nFrames,
int nWords,
int nBinSize,
int nRounds,
int TimeOut,
Abc_Cex_t * pCex,
int fLatchOnly,
int fVerbose )

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

Synopsis [Filter equivalence classes of nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file sswRarity2.c.

387{
388 int fMiter = 0;
389 Ssw_RarMan_t * p;
390 int r, i, k;
391 abctime clkTotal = Abc_Clock();
392 abctime nTimeToStop = TimeOut ? TimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0;
393 int RetValue = -1;
394 assert( Aig_ManRegNum(pAig) > 0 );
395 assert( Aig_ManConstrNum(pAig) == 0 );
396 // consider the case of empty AIG
397 if ( Aig_ManNodeNum(pAig) == 0 )
398 return -1;
399 if ( fVerbose )
400 Abc_Print( 1, "Filtering equivs with %d words through %d frames with %d binsize, %d rounds, and %d sec timeout.\n",
401 nWords, nFrames, nBinSize, nRounds, TimeOut );
402 // reset random numbers
403 Aig_ManRandom( 1 );
404
405 // create manager
406 p = Ssw_RarManStart( pAig, nWords, nFrames, nBinSize, fVerbose );
407 // compute starting state if needed
408 assert( p->vInits == NULL );
409 if ( pCex )
410 p->vInits = Ssw_RarFindStartingState( pAig, pCex );
411 else
412 p->vInits = Vec_IntStart( Aig_ManRegNum(pAig) );
413 // duplicate the array
414 for ( i = 1; i < nWords; i++ )
415 for ( k = 0; k < Aig_ManRegNum(pAig); k++ )
416 Vec_IntPush( p->vInits, Vec_IntEntry(p->vInits, k) );
417 assert( Vec_IntSize(p->vInits) == Aig_ManRegNum(pAig) * nWords );
418 // initialize simulation manager
419 Ssw_SmlInitializeSpecial( p->pSml, p->vInits );
420
421 // create trivial equivalence classes with all nodes being candidates for constant 1
422 if ( pAig->pReprs == NULL )
423 p->ppClasses = Ssw_ClassesPrepareSimple( pAig, fLatchOnly, 0 );
424 else
425 p->ppClasses = Ssw_ClassesPrepareFromReprs( pAig );
426 Ssw_ClassesSetData( p->ppClasses, p->pSml, NULL, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
427 // print the stats
428 if ( fVerbose )
429 {
430 Abc_Print( 1, "Initial : " );
431 Ssw_ClassesPrint( p->ppClasses, 0 );
432 }
433 // refine classes using BMC
434 for ( r = 0; r < nRounds; r++ )
435 {
436 // start filtering equivalence classes
437 if ( Ssw_ClassesCand1Num(p->ppClasses) == 0 && Ssw_ClassesClassNum(p->ppClasses) == 0 )
438 {
439 Abc_Print( 1, "All equivalences are refined away.\n" );
440 break;
441 }
442 // simulate
443 Ssw_SmlSimulateOne( p->pSml );
444 if ( fMiter && Ssw_SmlCheckNonConstOutputs(p->pSml) )
445 {
446 if ( fVerbose ) Abc_Print( 1, "\n" );
447 Abc_Print( 1, "Simulation asserted a PO in frame f: %d <= f < %d.\n", r * nFrames, (r+1) * nFrames );
448 RetValue = 0;
449 break;
450 }
451 // check equivalence classes
452 Ssw_ClassesRefineConst1( p->ppClasses, 1 );
453 Ssw_ClassesRefine( p->ppClasses, 1 );
454 // printout
455 if ( fVerbose )
456 {
457 Abc_Print( 1, "Round %3d: ", r );
458 Ssw_ClassesPrint( p->ppClasses, 0 );
459 }
460 // get initialization patterns
461 Ssw_RarUpdateCounters( p );
462 Ssw_RarTransferPatterns( p, p->vInits );
463 Ssw_SmlInitializeSpecial( p->pSml, p->vInits );
464 // check timeout
465 if ( TimeOut && Abc_Clock() > nTimeToStop )
466 {
467 if ( fVerbose ) Abc_Print( 1, "\n" );
468 Abc_Print( 1, "Reached timeout (%d seconds).\n", TimeOut );
469 break;
470 }
471 }
472 if ( r == nRounds )
473 {
474 Abc_Print( 1, "Simulation did not assert POs in the first %d frames. ", nRounds * nFrames );
475 Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
476 }
477 // cleanup
478 Ssw_RarManStop( p );
479 return -1;
480}
int nWords
Definition abcNpn.c:127
ABC_INT64_T abctime
Definition abc_global.h:332
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
unsigned Aig_ManRandom(int fReset)
Definition aigUtil.c:1170
Cube * p
Definition exorList.c:222
Ssw_Cla_t * Ssw_ClassesPrepareFromReprs(Aig_Man_t *pAig)
Definition sswClass.c:768
int Ssw_ClassesCand1Num(Ssw_Cla_t *p)
Definition sswClass.c:259
Ssw_Cla_t * Ssw_ClassesPrepareSimple(Aig_Man_t *pAig, int fLatchCorr, int nMaxLevs)
Definition sswClass.c:724
int Ssw_ClassesRefineConst1(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1119
int Ssw_ClassesClassNum(Ssw_Cla_t *p)
Definition sswClass.c:275
void Ssw_ClassesPrint(Ssw_Cla_t *p, int fVeryVerbose)
Definition sswClass.c:414
void Ssw_ClassesSetData(Ssw_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
Definition sswClass.c:167
int Ssw_ClassesRefine(Ssw_Cla_t *p, int fRecursive)
Definition sswClass.c:1034
void Ssw_SmlSimulateOne(Ssw_Sml_t *p)
Definition sswSim.c:1005
int Ssw_SmlObjIsConstWord(Ssw_Sml_t *p, Aig_Obj_t *pObj)
Definition sswSim.c:102
typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t
DECLARATIONS ///.
Definition sswRarity.c:33
int Ssw_SmlObjsAreEqualWord(Ssw_Sml_t *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition sswSim.c:124
void Ssw_SmlInitializeSpecial(Ssw_Sml_t *p, Vec_Int_t *vInit)
Definition sswSim.c:928
int Ssw_SmlCheckNonConstOutputs(Ssw_Sml_t *p)
Definition sswSim.c:980
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ssw_RarSignalFilterGia2()

int Ssw_RarSignalFilterGia2 ( Gia_Man_t * p,
int nFrames,
int nWords,
int nBinSize,
int nRounds,
int TimeOut,
Abc_Cex_t * pCex,
int fLatchOnly,
int fVerbose )

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

Synopsis [Filter equivalence classes of nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 493 of file sswRarity2.c.

494{
495 Aig_Man_t * pAig;
496 int RetValue;
497 pAig = Gia_ManToAigSimple( p );
498 if ( p->pReprs != NULL )
499 {
500 Gia_ManReprToAigRepr2( pAig, p );
501 ABC_FREE( p->pReprs );
502 ABC_FREE( p->pNexts );
503 }
504 RetValue = Ssw_RarSignalFilter2( pAig, nFrames, nWords, nBinSize, nRounds, TimeOut, pCex, fLatchOnly, fVerbose );
505 Gia_ManReprFromAigRepr( pAig, p );
506 Aig_ManStop( pAig );
507 return RetValue;
508}
#define ABC_FREE(obj)
Definition abc_global.h:267
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
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition giaAig.c:408
void Gia_ManReprFromAigRepr(Aig_Man_t *pAig, Gia_Man_t *pGia)
Definition giaAig.c:528
void Gia_ManReprToAigRepr2(Aig_Man_t *pAig, Gia_Man_t *pGia)
Definition giaAig.c:500
int Ssw_RarSignalFilter2(Aig_Man_t *pAig, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, Abc_Cex_t *pCex, int fLatchOnly, int fVerbose)
Definition sswRarity2.c:386
Here is the call graph for this function:

◆ Ssw_RarSimulate2()

int Ssw_RarSimulate2 ( Aig_Man_t * pAig,
int nFrames,
int nWords,
int nBinSize,
int nRounds,
int TimeOut,
int fVerbose )

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

Synopsis [Perform sequential simulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file sswRarity2.c.

308{
309 int fMiter = 1;
310 Ssw_RarMan_t * p;
311 int r;
312 abctime clk, clkTotal = Abc_Clock();
313 abctime nTimeToStop = TimeOut ? TimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0;
314 int RetValue = -1;
315 assert( Aig_ManRegNum(pAig) > 0 );
316 assert( Aig_ManConstrNum(pAig) == 0 );
317 // consider the case of empty AIG
318 if ( Aig_ManNodeNum(pAig) == 0 )
319 return -1;
320 if ( fVerbose )
321 Abc_Print( 1, "Simulating %d words through %d frames with %d binsize, %d rounds, and %d sec timeout.\n",
322 nWords, nFrames, nBinSize, nRounds, TimeOut );
323 // reset random numbers
324 Aig_ManRandom( 1 );
325
326 // create manager
327 p = Ssw_RarManStart( pAig, nWords, nFrames, nBinSize, fVerbose );
328 p->vInits = Vec_IntStart( Aig_ManRegNum(pAig) * nWords );
329 Ssw_SmlInitializeSpecial( p->pSml, p->vInits );
330
331 // perform simulation rounds
332 for ( r = 0; r < nRounds; r++ )
333 {
334 clk = Abc_Clock();
335 // simulate
336 Ssw_SmlSimulateOne( p->pSml );
337 if ( fMiter && Ssw_SmlCheckNonConstOutputs(p->pSml) )
338 {
339 if ( fVerbose ) Abc_Print( 1, "\n" );
340 Abc_Print( 1, "Simulation asserted a PO in frame f: %d <= f < %d.\n", r * nFrames, (r+1) * nFrames );
341 RetValue = 0;
342 break;
343 }
344 // get initialization patterns
345 Ssw_RarUpdateCounters( p );
346 Ssw_RarTransferPatterns( p, p->vInits );
347 Ssw_SmlInitializeSpecial( p->pSml, p->vInits );
348 // printout
349 if ( fVerbose )
350 {
351// Abc_Print( 1, "Round %3d: ", r );
352// Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
353 Abc_Print( 1, "." );
354 }
355 // check timeout
356 if ( TimeOut && Abc_Clock() > nTimeToStop )
357 {
358 if ( fVerbose ) Abc_Print( 1, "\n" );
359 Abc_Print( 1, "Reached timeout (%d seconds).\n", TimeOut );
360 break;
361 }
362 }
363 if ( r == nRounds )
364 {
365 if ( fVerbose ) Abc_Print( 1, "\n" );
366 Abc_Print( 1, "Simulation did not assert POs in the first %d frames. ", nRounds * nFrames );
367 Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
368 }
369 // cleanup
370 Ssw_RarManStop( p );
371 return RetValue;
372}
Here is the call graph for this function: