abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sswRarity2.c File Reference
#include "sswInt.h"
#include "aig/gia/giaAig.h"

Go to the source code of this file.

Data Structures

struct  Ssw_RarMan_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Ssw_RarMan_t_ 
Ssw_RarMan_t
 DECLARATIONS ///. More...
 

Functions

static int Ssw_RarGetBinPat (Ssw_RarMan_t *p, int iBin, int iPat)
 
static void Ssw_RarSetBinPat (Ssw_RarMan_t *p, int iBin, int iPat, int Value)
 
static void Ssw_RarAddToBinPat (Ssw_RarMan_t *p, int iBin, int iPat)
 
static Ssw_RarMan_tSsw_RarManStart (Aig_Man_t *pAig, int nWords, int nFrames, int nBinSize, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 
static void Ssw_RarManStop (Ssw_RarMan_t *p)
 
static void Ssw_RarUpdateCounters (Ssw_RarMan_t *p)
 
static void Ssw_RarTransferPatterns (Ssw_RarMan_t *p, Vec_Int_t *vInits)
 
static Vec_Int_tSsw_RarFindStartingState (Aig_Man_t *pAig, Abc_Cex_t *pCex)
 
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)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t

DECLARATIONS ///.

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

FileName [sswRarity.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Inductive prover with constraints.]

Synopsis [Rarity-driven refinement of equivalence classes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file sswRarity2.c.

Function Documentation

static void Ssw_RarAddToBinPat ( Ssw_RarMan_t p,
int  iBin,
int  iPat 
)
inlinestatic

Definition at line 65 of file sswRarity2.c.

66 {
67  assert( iBin >= 0 && iBin < Aig_ManRegNum(p->pAig) / p->nBinSize );
68  assert( iPat >= 0 && iPat < (1 << p->nBinSize) );
69  p->pRarity[iBin * (1 << p->nBinSize) + iPat]++;
70 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define assert(ex)
Definition: util_old.h:213
static Vec_Int_t* Ssw_RarFindStartingState ( Aig_Man_t pAig,
Abc_Cex_t pCex 
)
static

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

Synopsis [Performs fraiging for one node.]

Description [Returns the fraiged node.]

SideEffects []

SeeAlso []

Definition at line 257 of file sswRarity2.c.

258 {
259  Vec_Int_t * vInit;
260  Aig_Obj_t * pObj, * pObjLi;
261  int f, i, iBit;
262  // assign register outputs
263  Saig_ManForEachLi( pAig, pObj, i )
264  pObj->fMarkB = Abc_InfoHasBit( pCex->pData, i );
265  // simulate the timeframes
266  iBit = pCex->nRegs;
267  for ( f = 0; f <= pCex->iFrame; f++ )
268  {
269  // set the PI simulation information
270  Aig_ManConst1(pAig)->fMarkB = 1;
271  Saig_ManForEachPi( pAig, pObj, i )
272  pObj->fMarkB = Abc_InfoHasBit( pCex->pData, iBit++ );
273  Saig_ManForEachLiLo( pAig, pObjLi, pObj, i )
274  pObj->fMarkB = pObjLi->fMarkB;
275  // simulate internal nodes
276  Aig_ManForEachNode( pAig, pObj, i )
277  pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
278  & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
279  // assign the COs
280  Aig_ManForEachCo( pAig, pObj, i )
281  pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) );
282  }
283  assert( iBit == pCex->nBits );
284  // check that the output failed as expected -- cannot check because it is not an SRM!
285 // pObj = Aig_ManCo( pAig, pCex->iPo );
286 // if ( pObj->fMarkB != 1 )
287 // Abc_Print( 1, "The counter-example does not refine the output.\n" );
288  // record the new pattern
289  vInit = Vec_IntAlloc( Saig_ManRegNum(pAig) );
290  Saig_ManForEachLo( pAig, pObj, i )
291  Vec_IntPush( vInit, pObj->fMarkB );
292  return vInit;
293 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
unsigned int fMarkB
Definition: aig.h:80
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
for(p=first;p->value< newval;p=p->next)
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Saig_ManRegNum(Aig_Man_t *p)
Definition: saig.h:77
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91
static int Ssw_RarGetBinPat ( Ssw_RarMan_t p,
int  iBin,
int  iPat 
)
inlinestatic

Definition at line 53 of file sswRarity2.c.

54 {
55  assert( iBin >= 0 && iBin < Aig_ManRegNum(p->pAig) / p->nBinSize );
56  assert( iPat >= 0 && iPat < (1 << p->nBinSize) );
57  return p->pRarity[iBin * (1 << p->nBinSize) + iPat];
58 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define assert(ex)
Definition: util_old.h:213
static Ssw_RarMan_t* Ssw_RarManStart ( Aig_Man_t pAig,
int  nWords,
int  nFrames,
int  nBinSize,
int  fVerbose 
)
static

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file sswRarity2.c.

88 {
89  Ssw_RarMan_t * p;
90  if ( Aig_ManRegNum(pAig) < nBinSize || nBinSize <= 0 )
91  return NULL;
92  p = ABC_CALLOC( Ssw_RarMan_t, 1 );
93  p->pAig = pAig;
94  p->nWords = nWords;
95  p->nFrames = nFrames;
96  p->nBinSize = nBinSize;
97  p->fVerbose = fVerbose;
98  p->nGroups = Aig_ManRegNum(pAig) / nBinSize;
99  p->pRarity = ABC_CALLOC( int, (1 << nBinSize) * p->nGroups );
100  p->pGroupValues = ABC_CALLOC( int, p->nGroups );
101  p->pPatCosts = ABC_CALLOC( double, p->nWords * 32 );
102  p->pSml = Ssw_SmlStart( pAig, 0, nFrames, nWords );
103  p->vSimInfo = Ssw_SmlSimDataPointers( p->pSml );
104  return p;
105 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nWords
Definition: abcNpn.c:127
typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t
DECLARATIONS ///.
Definition: sswRarity.c:33
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Ssw_Sml_t * Ssw_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
Definition: sswSim.c:1148
Vec_Ptr_t * Ssw_SmlSimDataPointers(Ssw_Sml_t *p)
Definition: sswSim.c:1189
static void Ssw_RarManStop ( Ssw_RarMan_t p)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file sswRarity2.c.

119 {
120  if ( p->pSml ) Ssw_SmlStop( p->pSml );
121  if ( p->ppClasses ) Ssw_ClassesStop( p->ppClasses );
122  Vec_PtrFreeP( &p->vSimInfo );
123  Vec_IntFreeP( &p->vInits );
124  ABC_FREE( p->pGroupValues );
125  ABC_FREE( p->pPatCosts );
126  ABC_FREE( p->pRarity );
127  ABC_FREE( p );
128 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Ssw_ClassesStop(Ssw_Cla_t *p)
Definition: sswClass.c:189
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
void Ssw_SmlStop(Ssw_Sml_t *p)
Definition: sswSim.c:1211
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
static void Ssw_RarSetBinPat ( Ssw_RarMan_t p,
int  iBin,
int  iPat,
int  Value 
)
inlinestatic

Definition at line 59 of file sswRarity2.c.

60 {
61  assert( iBin >= 0 && iBin < Aig_ManRegNum(p->pAig) / p->nBinSize );
62  assert( iPat >= 0 && iPat < (1 << p->nBinSize) );
63  p->pRarity[iBin * (1 << p->nBinSize) + iPat] = Value;
64 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define assert(ex)
Definition: util_old.h:213
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
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 Ssw_SmlCheckNonConstOutputs(Ssw_Sml_t *p)
Definition: sswSim.c:980
int Ssw_ClassesClassNum(Ssw_Cla_t *p)
Definition: sswClass.c:275
static int Aig_ManConstrNum(Aig_Man_t *p)
Definition: aig.h:261
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Ssw_ClassesCand1Num(Ssw_Cla_t *p)
Definition: sswClass.c:259
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
int Ssw_ClassesRefine(Ssw_Cla_t *p, int fRecursive)
Definition: sswClass.c:1034
static abctime Abc_Clock()
Definition: abc_global.h:279
int Ssw_SmlObjIsConstWord(Ssw_Sml_t *p, Aig_Obj_t *pObj)
Definition: sswSim.c:102
int nWords
Definition: abcNpn.c:127
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static void Ssw_RarManStop(Ssw_RarMan_t *p)
Definition: sswRarity2.c:118
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
int Ssw_SmlObjsAreEqualWord(Ssw_Sml_t *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: sswSim.c:124
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
void Ssw_ClassesPrint(Ssw_Cla_t *p, int fVeryVerbose)
Definition: sswClass.c:414
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t
DECLARATIONS ///.
Definition: sswRarity.c:33
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Ssw_SmlInitializeSpecial(Ssw_Sml_t *p, Vec_Int_t *vInit)
Definition: sswSim.c:928
Ssw_Cla_t * Ssw_ClassesPrepareFromReprs(Aig_Man_t *pAig)
Definition: sswClass.c:768
Ssw_Cla_t * Ssw_ClassesPrepareSimple(Aig_Man_t *pAig, int fLatchCorr, int nMaxLevs)
Definition: sswClass.c:724
static void Ssw_RarUpdateCounters(Ssw_RarMan_t *p)
Definition: sswRarity2.c:142
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Ssw_SmlSimulateOne(Ssw_Sml_t *p)
Definition: sswSim.c:1005
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Int_t * Ssw_RarFindStartingState(Aig_Man_t *pAig, Abc_Cex_t *pCex)
Definition: sswRarity2.c:257
static Ssw_RarMan_t * Ssw_RarManStart(Aig_Man_t *pAig, int nWords, int nFrames, int nBinSize, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: sswRarity2.c:87
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Ssw_RarTransferPatterns(Ssw_RarMan_t *p, Vec_Int_t *vInits)
Definition: sswRarity2.c:188
int Ssw_ClassesRefineConst1(Ssw_Cla_t *p, int fRecursive)
Definition: sswClass.c:1119
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 }
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition: giaAig.c:367
void Gia_ManReprFromAigRepr(Aig_Man_t *pAig, Gia_Man_t *pGia)
Definition: giaAig.c:487
int * pNexts
Definition: gia.h:122
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int nWords
Definition: abcNpn.c:127
void Gia_ManReprToAigRepr2(Aig_Man_t *pAig, Gia_Man_t *pGia)
Definition: giaAig.c:459
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
#define ABC_FREE(obj)
Definition: abc_global.h:232
Gia_Rpr_t * pReprs
Definition: gia.h:121
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
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 }
int Ssw_SmlCheckNonConstOutputs(Ssw_Sml_t *p)
Definition: sswSim.c:980
static int Aig_ManConstrNum(Aig_Man_t *p)
Definition: aig.h:261
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
static abctime Abc_Clock()
Definition: abc_global.h:279
int nWords
Definition: abcNpn.c:127
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static void Ssw_RarManStop(Ssw_RarMan_t *p)
Definition: sswRarity2.c:118
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t
DECLARATIONS ///.
Definition: sswRarity.c:33
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Ssw_SmlInitializeSpecial(Ssw_Sml_t *p, Vec_Int_t *vInit)
Definition: sswSim.c:928
static void Ssw_RarUpdateCounters(Ssw_RarMan_t *p)
Definition: sswRarity2.c:142
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Ssw_SmlSimulateOne(Ssw_Sml_t *p)
Definition: sswSim.c:1005
static Ssw_RarMan_t * Ssw_RarManStart(Aig_Man_t *pAig, int nWords, int nFrames, int nBinSize, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: sswRarity2.c:87
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Ssw_RarTransferPatterns(Ssw_RarMan_t *p, Vec_Int_t *vInits)
Definition: sswRarity2.c:188
static void Ssw_RarTransferPatterns ( Ssw_RarMan_t p,
Vec_Int_t vInits 
)
static

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

Synopsis [Select best patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 188 of file sswRarity2.c.

189 {
190  Aig_Obj_t * pObj;
191  unsigned * pData;
192  int i, k, Value;
193 
194  // for each pattern
195  for ( k = 0; k < p->nWords * 32; k++ )
196  {
197  for ( i = 0; i < p->nGroups; i++ )
198  p->pGroupValues[i] = 0;
199  // compute its group values
200  Saig_ManForEachLi( p->pAig, pObj, i )
201  {
202  pData = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjId(pObj) ) + p->nWords * (p->nFrames - 1);
203  if ( Abc_InfoHasBit(pData, k) && i / p->nBinSize < p->nGroups )
204  p->pGroupValues[i / p->nBinSize] |= (1 << (i % p->nBinSize));
205  }
206  // find the cost of its values
207  p->pPatCosts[k] = 0.0;
208  for ( i = 0; i < p->nGroups; i++ )
209  {
210  Value = Ssw_RarGetBinPat( p, i, p->pGroupValues[i] );
211  assert( Value > 0 );
212  p->pPatCosts[k] += 1.0/(Value*Value);
213  }
214  // print the result
215 // Abc_Print( 1, "%3d : %9.6f\n", k, p->pPatCosts[k] );
216  }
217 
218  // choose as many as there are words
219  Vec_IntClear( vInits );
220  for ( i = 0; i < p->nWords; i++ )
221  {
222  // select the best
223  int iPatBest = -1;
224  double iCostBest = -ABC_INFINITY;
225  for ( k = 0; k < p->nWords * 32; k++ )
226  if ( iCostBest < p->pPatCosts[k] )
227  {
228  iCostBest = p->pPatCosts[k];
229  iPatBest = k;
230  }
231  // remove from costs
232  assert( iPatBest >= 0 );
233  p->pPatCosts[iPatBest] = -ABC_INFINITY;
234  // set the flops
235  Saig_ManForEachLi( p->pAig, pObj, k )
236  {
237  pData = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjId(pObj) ) + p->nWords * (p->nFrames - 1);
238  Vec_IntPush( vInits, Abc_InfoHasBit(pData, iPatBest) );
239  }
240 //Abc_Print( 1, "Best pattern %5d\n", iPatBest );
241  }
242  assert( Vec_IntSize(vInits) == Aig_ManRegNum(p->pAig) * p->nWords );
243 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
static int Ssw_RarGetBinPat(Ssw_RarMan_t *p, int iBin, int iPat)
Definition: sswRarity2.c:53
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static void Ssw_RarUpdateCounters ( Ssw_RarMan_t p)
static

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

Synopsis [Updates rarity counters.]

Description []

SideEffects []

SeeAlso []

Definition at line 142 of file sswRarity2.c.

143 {
144  Aig_Obj_t * pObj;
145  unsigned * pData;
146  int i, k;
147 /*
148  Saig_ManForEachLi( p->pAig, pObj, i )
149  {
150  pData = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjId(pObj) ) + p->nWords * (p->nFrames - 1);
151  Extra_PrintBinary( stdout, pData, 32 ); Abc_Print( 1, "\n" );
152  }
153 */
154  for ( k = 0; k < p->nWords * 32; k++ )
155  {
156  for ( i = 0; i < p->nGroups; i++ )
157  p->pGroupValues[i] = 0;
158  Saig_ManForEachLi( p->pAig, pObj, i )
159  {
160  pData = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjId(pObj) ) + p->nWords * (p->nFrames - 1);
161  if ( Abc_InfoHasBit(pData, k) && i / p->nBinSize < p->nGroups )
162  p->pGroupValues[i / p->nBinSize] |= (1 << (i % p->nBinSize));
163  }
164  for ( i = 0; i < p->nGroups; i++ )
165  Ssw_RarAddToBinPat( p, i, p->pGroupValues[i] );
166  }
167 /*
168  for ( i = 0; i < p->nGroups; i++ )
169  {
170  for ( k = 0; k < (1 << p->nBinSize); k++ )
171  Abc_Print( 1, "%d ", Ssw_RarGetBinPat(p, i, k) );
172  Abc_Print( 1, "\n" );
173  }
174 */
175 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
static void Ssw_RarAddToBinPat(Ssw_RarMan_t *p, int iBin, int iPat)
Definition: sswRarity2.c:65
Definition: aig.h:69
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286