abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fraClass.c File Reference
#include "fra.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
Aig_Obj_t
Fra_ObjNext (Aig_Obj_t **ppNexts, Aig_Obj_t *pObj)
 DECLARATIONS ///. More...
 
static void Fra_ObjSetNext (Aig_Obj_t **ppNexts, Aig_Obj_t *pObj, Aig_Obj_t *pNext)
 
Fra_Cla_tFra_ClassesStart (Aig_Man_t *pAig)
 FUNCTION DEFINITIONS ///. More...
 
void Fra_ClassesStop (Fra_Cla_t *p)
 
void Fra_ClassesCopyReprs (Fra_Cla_t *p, Vec_Ptr_t *vFailed)
 
int Fra_ClassCount (Aig_Obj_t **pClass)
 
int Fra_ClassesCountLits (Fra_Cla_t *p)
 
int Fra_ClassesCountPairs (Fra_Cla_t *p)
 
void Fra_PrintClass (Fra_Cla_t *p, Aig_Obj_t **pClass)
 
void Fra_ClassesPrint (Fra_Cla_t *p, int fVeryVerbose)
 
void Fra_ClassesPrepare (Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
 
Aig_Obj_t ** Fra_RefineClassOne (Fra_Cla_t *p, Aig_Obj_t **ppClass)
 
int Fra_RefineClassLastIter (Fra_Cla_t *p, Vec_Ptr_t *vClasses)
 
int Fra_ClassesRefine (Fra_Cla_t *p)
 
int Fra_ClassesRefine1 (Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
 
void Fra_ClassesTest (Fra_Cla_t *p, int Id1, int Id2)
 
void Fra_ClassesLatchCorr (Fra_Man_t *p)
 
void Fra_ClassesPostprocess (Fra_Cla_t *p)
 
void Fra_ClassesSelectRepr (Fra_Cla_t *p)
 
static Aig_Obj_tFra_ObjEqu (Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
 
static void Fra_ObjSetEqu (Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj, Aig_Obj_t *pNode)
 
static Aig_Obj_tFra_ObjChild0Equ (Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
 
static Aig_Obj_tFra_ObjChild1Equ (Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
 
static void Fra_ClassesDeriveNode (Aig_Man_t *pManFraig, Aig_Obj_t *pObj, Aig_Obj_t **ppEquivs)
 
Aig_Man_tFra_ClassesDeriveAig (Fra_Cla_t *p, int nFramesK)
 

Function Documentation

int Fra_ClassCount ( Aig_Obj_t **  pClass)

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file fraClass.c.

146 {
147  Aig_Obj_t * pTemp;
148  int i;
149  for ( i = 0; (pTemp = pClass[i]); i++ );
150  return i;
151 }
Definition: aig.h:69
void Fra_ClassesCopyReprs ( Fra_Cla_t p,
Vec_Ptr_t vFailed 
)

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file fraClass.c.

115 {
116  Aig_Obj_t * pObj;
117  int i;
119  memmove( p->pAig->pReprs, p->pMemRepr, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p->pAig) );
120  if ( Vec_PtrSize(p->vClasses1) == 0 && Vec_PtrSize(p->vClasses) == 0 )
121  {
122  Aig_ManForEachObj( p->pAig, pObj, i )
123  {
124  if ( p->pAig->pReprs[i] != NULL )
125  printf( "Classes are not cleared!\n" );
126  assert( p->pAig->pReprs[i] == NULL );
127  }
128  }
129  if ( vFailed )
130  Vec_PtrForEachEntry( Aig_Obj_t *, vFailed, pObj, i )
131  p->pAig->pReprs[pObj->Id] = NULL;
132 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
char * memmove()
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesCountLits ( Fra_Cla_t p)

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

Synopsis [Count the number of literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file fraClass.c.

165 {
166  Aig_Obj_t ** pClass;
167  int i, nNodes, nLits = 0;
168  nLits = Vec_PtrSize( p->vClasses1 );
169  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
170  {
171  nNodes = Fra_ClassCount( pClass );
172  assert( nNodes > 1 );
173  nLits += nNodes - 1;
174  }
175  return nLits;
176 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Fra_ClassCount(Aig_Obj_t **pClass)
Definition: fraClass.c:145
Definition: aig.h:69
Vec_Ptr_t * vClasses1
Definition: fra.h:155
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesCountPairs ( Fra_Cla_t p)

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

Synopsis [Count the number of pairs.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file fraClass.c.

190 {
191  Aig_Obj_t ** pClass;
192  int i, nNodes, nPairs = 0;
193  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
194  {
195  nNodes = Fra_ClassCount( pClass );
196  assert( nNodes > 1 );
197  nPairs += nNodes * (nNodes - 1) / 2;
198  }
199  return nPairs;
200 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
int Fra_ClassCount(Aig_Obj_t **pClass)
Definition: fraClass.c:145
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Aig_Man_t* Fra_ClassesDeriveAig ( Fra_Cla_t p,
int  nFramesK 
)

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

Synopsis [Derives AIG for the partitioned problem.]

Description []

SideEffects []

SeeAlso []

Definition at line 796 of file fraClass.c.

797 {
798  Aig_Man_t * pManFraig;
799  Aig_Obj_t * pObj, * pObjNew;
800  Aig_Obj_t ** pLatches, ** ppEquivs;
801  int i, k, f, nFramesAll = nFramesK + 1;
802  assert( Aig_ManRegNum(p->pAig) > 0 );
804  assert( nFramesK > 0 );
805  // start the fraig package
806  pManFraig = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * nFramesAll );
807  pManFraig->pName = Abc_UtilStrsav( p->pAig->pName );
808  pManFraig->pSpec = Abc_UtilStrsav( p->pAig->pSpec );
809  // allocate place for the node mapping
810  ppEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) );
811  Fra_ObjSetEqu( ppEquivs, Aig_ManConst1(p->pAig), Aig_ManConst1(pManFraig) );
812  // create latches for the first frame
813  Aig_ManForEachLoSeq( p->pAig, pObj, i )
814  Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
815  // add timeframes
816  pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) );
817  for ( f = 0; f < nFramesAll; f++ )
818  {
819  // create PIs for this frame
820  Aig_ManForEachPiSeq( p->pAig, pObj, i )
821  Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreateCi(pManFraig) );
822  // set the constraints on the latch outputs
823  Aig_ManForEachLoSeq( p->pAig, pObj, i )
824  Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
825  // add internal nodes of this frame
826  Aig_ManForEachNode( p->pAig, pObj, i )
827  {
828  pObjNew = Aig_And( pManFraig, Fra_ObjChild0Equ(ppEquivs, pObj), Fra_ObjChild1Equ(ppEquivs, pObj) );
829  Fra_ObjSetEqu( ppEquivs, pObj, pObjNew );
830  Fra_ClassesDeriveNode( pManFraig, pObj, ppEquivs );
831  }
832  if ( f == nFramesAll - 1 )
833  break;
834  if ( f == nFramesAll - 2 )
835  pManFraig->nAsserts = Aig_ManCoNum(pManFraig);
836  // save the latch input values
837  k = 0;
838  Aig_ManForEachLiSeq( p->pAig, pObj, i )
839  pLatches[k++] = Fra_ObjChild0Equ( ppEquivs, pObj );
840  // insert them to the latch output values
841  k = 0;
842  Aig_ManForEachLoSeq( p->pAig, pObj, i )
843  Fra_ObjSetEqu( ppEquivs, pObj, pLatches[k++] );
844  }
845  ABC_FREE( pLatches );
846  ABC_FREE( ppEquivs );
847  // mark the asserts
848  assert( Aig_ManCoNum(pManFraig) % nFramesAll == 0 );
849 printf( "Assert miters = %6d. Output miters = %6d.\n",
850  pManFraig->nAsserts, Aig_ManCoNum(pManFraig) - pManFraig->nAsserts );
851  // remove dangling nodes
852  Aig_ManCleanup( pManFraig );
853  return pManFraig;
854 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
#define Assert(cond, msg)
Definition: zutil.h:268
static Aig_Obj_t * Fra_ObjChild0Equ(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:746
static Aig_Obj_t * Fra_ObjChild1Equ(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:747
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
for(p=first;p->value< newval;p=p->next)
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static void Fra_ClassesDeriveNode(Aig_Man_t *pManFraig, Aig_Obj_t *pObj, Aig_Obj_t **ppEquivs)
Definition: fraClass.c:760
static void Fra_ObjSetEqu(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fraClass.c:744
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAig
Definition: fra.h:152
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
#define assert(ex)
Definition: util_old.h:213
#define Aig_ManForEachLiSeq(p, pObj, i)
Definition: aig.h:447
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Definition: aig.h:438
static void Fra_ClassesDeriveNode ( Aig_Man_t pManFraig,
Aig_Obj_t pObj,
Aig_Obj_t **  ppEquivs 
)
inlinestatic

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

Synopsis [Add the node and its constraints to the new AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 760 of file fraClass.c.

761 {
762  Aig_Obj_t * pObjNew, * pObjRepr, * pObjReprNew, * pMiter;//, * pObjNew2;
763  // skip nodes without representative
764  if ( (pObjRepr = Fra_ClassObjRepr(pObj)) == NULL )
765  return;
766  assert( pObjRepr->Id < pObj->Id );
767  // get the new node
768  pObjNew = Fra_ObjEqu( ppEquivs, pObj );
769  // get the new node of the representative
770  pObjReprNew = Fra_ObjEqu( ppEquivs, pObjRepr );
771  // if this is the same node, no need to add constraints
772  if ( Aig_Regular(pObjNew) == Aig_Regular(pObjReprNew) )
773  return;
774  // these are different nodes - perform speculative reduction
775 // pObjNew2 = Aig_NotCond( pObjReprNew, pObj->fPhase ^ pObjRepr->fPhase );
776  // set the new node
777 // Fra_ObjSetEqu( ppEquivs, pObj, pObjNew2 );
778  // add the constraint
779  pMiter = Aig_Exor( pManFraig, Aig_Regular(pObjNew), Aig_Regular(pObjReprNew) );
780  pMiter = Aig_NotCond( pMiter, Aig_Regular(pMiter)->fPhase ^ Aig_IsComplement(pMiter) );
781  pMiter = Aig_Not( pMiter );
782  Aig_ObjCreateCo( pManFraig, pMiter );
783 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
static Aig_Obj_t * Fra_ObjEqu(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:743
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:220
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
Definition: aig.h:69
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
int Id
Definition: aig.h:85
void Fra_ClassesLatchCorr ( Fra_Man_t p)

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

Synopsis [Creates latch correspondence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file fraClass.c.

616 {
617  Aig_Obj_t * pObj;
618  int i, nEntries = 0;
619  Vec_PtrClear( p->pCla->vClasses1 );
620  Aig_ManForEachLoSeq( p->pManAig, pObj, i )
621  {
622  Vec_PtrPush( p->pCla->vClasses1, pObj );
624  }
625  // allocate room for classes
626  p->pCla->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) );
627  p->pCla->pMemClassesFree = p->pCla->pMemClasses + 2*nEntries;
628 }
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
Aig_Man_t * pManAig
Definition: fra.h:191
Fra_Cla_t * pCla
Definition: fra.h:198
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
#define Aig_ManForEachLoSeq(p, pObj, i)
Definition: aig.h:441
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
void Fra_ClassesPostprocess ( Fra_Cla_t p)

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

Synopsis [Postprocesses the classes by removing half of the less useful.]

Description []

SideEffects []

SeeAlso []

Definition at line 641 of file fraClass.c.

642 {
643  int Ratio = 2;
644  Fra_Sml_t * pComb;
645  Aig_Obj_t * pObj, * pRepr, ** ppClass;
646  int * pWeights, WeightMax = 0, i, k, c;
647  // perform combinational simulation
648  pComb = Fra_SmlSimulateComb( p->pAig, 32, 0 );
649  // compute the weight of each node in the classes
650  pWeights = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) );
651  memset( pWeights, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) );
652  Aig_ManForEachObj( p->pAig, pObj, i )
653  {
654  pRepr = Fra_ClassObjRepr( pObj );
655  if ( pRepr == NULL )
656  continue;
657  pWeights[i] = Fra_SmlNodeNotEquWeight( pComb, pRepr->Id, pObj->Id );
658  WeightMax = Abc_MaxInt( WeightMax, pWeights[i] );
659  }
660  Fra_SmlStop( pComb );
661  printf( "Before: Const = %6d. Class = %6d. ", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
662  // remove nodes from classes whose weight is less than WeightMax/Ratio
663  k = 0;
664  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
665  {
666  if ( pWeights[pObj->Id] >= WeightMax/Ratio )
667  Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
668  else
669  Fra_ClassObjSetRepr( pObj, NULL );
670  }
671  Vec_PtrShrink( p->vClasses1, k );
672  // in each class, compact the nodes
673  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
674  {
675  k = 1;
676  for ( c = 1; ppClass[c]; c++ )
677  {
678  if ( pWeights[ppClass[c]->Id] >= WeightMax/Ratio )
679  ppClass[k++] = ppClass[c];
680  else
681  Fra_ClassObjSetRepr( ppClass[c], NULL );
682  }
683  ppClass[k] = NULL;
684  }
685  // remove classes with only repr
686  k = 0;
687  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
688  if ( ppClass[1] != NULL )
689  Vec_PtrWriteEntry( p->vClasses, k++, ppClass );
690  Vec_PtrShrink( p->vClasses, k );
691  printf( "After: Const = %6d. Class = %6d. \n", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
692  ABC_FREE( pWeights );
693 }
char * memset()
Vec_Ptr_t * vClasses
Definition: fra.h:154
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition: fraSim.c:856
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
int Fra_SmlNodeNotEquWeight(Fra_Sml_t *p, int Left, int Right)
Definition: fraSim.c:133
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
int Id
Definition: aig.h:85
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
void Fra_ClassesPrepare ( Fra_Cla_t p,
int  fLatchCorr,
int  nMaxLevs 
)

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

Synopsis [Creates initial simulation classes.]

Description [Assumes that simulation info is assigned.]

SideEffects []

SeeAlso []

Definition at line 276 of file fraClass.c.

277 {
278  Aig_Obj_t ** ppTable, ** ppNexts;
279  Aig_Obj_t * pObj, * pTemp;
280  int i, k, nTableSize, nEntries, nNodes, iEntry;
281 
282  // allocate the hash table hashing simulation info into nodes
283  nTableSize = Abc_PrimeCudd( Aig_ManObjNumMax(p->pAig) );
284  ppTable = ABC_FALLOC( Aig_Obj_t *, nTableSize );
285  ppNexts = ABC_FALLOC( Aig_Obj_t *, nTableSize );
286  memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize );
287 
288  // add all the nodes to the hash table
289  Vec_PtrClear( p->vClasses1 );
290  Aig_ManForEachObj( p->pAig, pObj, i )
291  {
292  if ( fLatchCorr )
293  {
294  if ( !Aig_ObjIsCi(pObj) )
295  continue;
296  }
297  else
298  {
299  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
300  continue;
301  // skip the node with more that the given number of levels
302  if ( nMaxLevs && (int)pObj->Level > nMaxLevs )
303  continue;
304  }
305  // hash the node by its simulation info
306  iEntry = p->pFuncNodeHash( pObj, nTableSize );
307  // check if the node belongs to the class of constant 1
308  if ( p->pFuncNodeIsConst( pObj ) )
309  {
310  Vec_PtrPush( p->vClasses1, pObj );
312  continue;
313  }
314  // add the node to the class
315  if ( ppTable[iEntry] == NULL )
316  {
317  ppTable[iEntry] = pObj;
318  Fra_ObjSetNext( ppNexts, pObj, pObj );
319  }
320  else
321  {
322  Fra_ObjSetNext( ppNexts, pObj, Fra_ObjNext(ppNexts,ppTable[iEntry]) );
323  Fra_ObjSetNext( ppNexts, ppTable[iEntry], pObj );
324  }
325  }
326 
327  // count the total number of nodes in the non-trivial classes
328  // mark the representative nodes of each equivalence class
329  nEntries = 0;
330  for ( i = 0; i < nTableSize; i++ )
331  if ( ppTable[i] && ppTable[i] != Fra_ObjNext(ppNexts, ppTable[i]) )
332  {
333  for ( pTemp = Fra_ObjNext(ppNexts, ppTable[i]), k = 1;
334  pTemp != ppTable[i];
335  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
336  assert( k > 1 );
337  nEntries += k;
338  // mark the node
339  assert( ppTable[i]->fMarkA == 0 );
340  ppTable[i]->fMarkA = 1;
341  }
342 
343  // allocate room for classes
344  p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) );
345  p->pMemClassesFree = p->pMemClasses + 2*nEntries;
346 
347  // copy the entries into storage in the topological order
348  Vec_PtrClear( p->vClasses );
349  nEntries = 0;
350  Aig_ManForEachObj( p->pAig, pObj, i )
351  {
352  if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
353  continue;
354  // skip the nodes that are not representatives of non-trivial classes
355  if ( pObj->fMarkA == 0 )
356  continue;
357  pObj->fMarkA = 0;
358  // add the class of nodes
359  Vec_PtrPush( p->vClasses, p->pMemClasses + 2*nEntries );
360  // count the number of entries in this class
361  for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
362  pTemp != pObj;
363  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ );
364  nNodes = k;
365  assert( nNodes > 1 );
366  // add the nodes to the class in the topological order
367  p->pMemClasses[2*nEntries] = pObj;
368  for ( pTemp = Fra_ObjNext(ppNexts, pObj), k = 1;
369  pTemp != pObj;
370  pTemp = Fra_ObjNext(ppNexts, pTemp), k++ )
371  {
372  p->pMemClasses[2*nEntries+nNodes-k] = pTemp;
373  Fra_ClassObjSetRepr( pTemp, pObj );
374  }
375  // add as many empty entries
376  p->pMemClasses[2*nEntries + nNodes] = NULL;
377  // increment the number of entries
378  nEntries += k;
379  }
380  ABC_FREE( ppTable );
381  ABC_FREE( ppNexts );
382  // now it is time to refine the classes
383  Fra_ClassesRefine( p );
384 // Fra_ClassesPrint( p, 0 );
385 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
unsigned Level
Definition: aig.h:82
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int fMarkA
Definition: aig.h:79
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Fra_ObjSetNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj, Aig_Obj_t *pNext)
Definition: fraClass.c:43
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static ABC_NAMESPACE_IMPL_START Aig_Obj_t * Fra_ObjNext(Aig_Obj_t **ppNexts, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: fraClass.c:42
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Aig_Man_t * pAig
Definition: fra.h:152
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int(* pFuncNodeHash)(Aig_Obj_t *, int)
Definition: fra.h:165
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
void Fra_ClassesPrint ( Fra_Cla_t p,
int  fVeryVerbose 
)

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 236 of file fraClass.c.

237 {
238  Aig_Obj_t ** pClass;
239  Aig_Obj_t * pObj;
240  int i;
241 
242  printf( "Const = %5d. Class = %5d. Lit = %5d. ",
244  if ( p->vImps && Vec_IntSize(p->vImps) > 0 )
245  printf( "Imp = %5d. ", Vec_IntSize(p->vImps) );
246  printf( "\n" );
247 
248  if ( fVeryVerbose )
249  {
250  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
251  assert( Fra_ClassObjRepr(pObj) == Aig_ManConst1(p->pAig) );
252  printf( "Constants { " );
253  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
254  printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
255  printf( "}\n" );
256  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
257  {
258  printf( "%3d (%3d) : ", i, Fra_ClassCount(pClass) );
259  Fra_PrintClass( p, pClass );
260  }
261  printf( "\n" );
262  }
263 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Definition: aig.h:69
Vec_Int_t * vImps
Definition: fra.h:163
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesRefine ( Fra_Cla_t p)

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

Synopsis [Refines the classes after simulation.]

Description [Assumes that simulation info is assigned. Returns the number of classes refined.]

SideEffects []

SeeAlso []

Definition at line 493 of file fraClass.c.

494 {
495  Vec_Ptr_t * vTemp;
496  Aig_Obj_t ** pClass;
497  int i, nRefis;
498  // refine the classes
499  nRefis = 0;
501  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
502  {
503  // add the class to the new array
504  assert( pClass[0] != NULL );
505  Vec_PtrPush( p->vClassesTemp, pClass );
506  // refine the class iteratively
507  nRefis += Fra_RefineClassLastIter( p, p->vClassesTemp );
508  }
509  // exchange the class representation
510  vTemp = p->vClassesTemp;
511  p->vClassesTemp = p->vClasses;
512  p->vClasses = vTemp;
513  return nRefis;
514 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Fra_RefineClassLastIter(Fra_Cla_t *p, Vec_Ptr_t *vClasses)
Definition: fraClass.c:457
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Fra_ClassesRefine1 ( Fra_Cla_t p,
int  fRefineNewClass,
int *  pSkipped 
)

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

Synopsis [Refines constant 1 equivalence class.]

Description []

SideEffects []

SeeAlso []

Definition at line 527 of file fraClass.c.

528 {
529  Aig_Obj_t * pObj, ** ppClass;
530  int i, k, nRefis = 1;
531  // check if there is anything to refine
532  if ( Vec_PtrSize(p->vClasses1) == 0 )
533  return 0;
534  // make sure constant 1 class contains only non-constant nodes
536  // collect all the nodes to be refined
537  k = 0;
538  Vec_PtrClear( p->vClassNew );
539  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
540  {
541  if ( p->pFuncNodeIsConst( pObj ) )
542  Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
543  else
544  Vec_PtrPush( p->vClassNew, pObj );
545  }
546  Vec_PtrShrink( p->vClasses1, k );
547  if ( Vec_PtrSize(p->vClassNew) == 0 )
548  return 0;
549 /*
550  printf( "Refined const-1 class: {" );
551  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
552  printf( " %d", pObj->Id );
553  printf( " }\n" );
554 */
555  if ( Vec_PtrSize(p->vClassNew) == 1 )
556  {
558  return 1;
559  }
560  // create a new class composed of these nodes
561  ppClass = p->pMemClassesFree;
562  p->pMemClassesFree += 2 * Vec_PtrSize(p->vClassNew);
563  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
564  {
565  ppClass[i] = pObj;
566  ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
567  Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
568  }
569  assert( ppClass[0] != NULL );
570  Vec_PtrPush( p->vClasses, ppClass );
571  // iteratively refine this class
572  if ( fRefineNewClass )
573  nRefis += Fra_RefineClassLastIter( p, p->vClasses );
574  else if ( pSkipped )
575  (*pSkipped)++;
576  return nRefis;
577 }
Aig_Obj_t ** pMemClassesFree
Definition: fra.h:158
int Fra_RefineClassLastIter(Fra_Cla_t *p, Vec_Ptr_t *vClasses)
Definition: fraClass.c:457
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Vec_Ptr_t * vClasses1
Definition: fra.h:155
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Aig_Man_t * pAig
Definition: fra.h:152
Vec_Ptr_t * vClassNew
Definition: fra.h:160
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
void Fra_ClassesSelectRepr ( Fra_Cla_t p)

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

Synopsis [Postprocesses the classes by selecting representative lowest in top order.]

Description []

SideEffects []

SeeAlso []

Definition at line 706 of file fraClass.c.

707 {
708  Aig_Obj_t ** pClass, * pNodeMin;
709  int i, c, cMinSupp, nSuppSizeMin, nSuppSizeCur;
710  // reassign representatives in each class
711  Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
712  {
713  // collect support sizes and find the min-support node
714  cMinSupp = -1;
715  pNodeMin = NULL;
716  nSuppSizeMin = ABC_INFINITY;
717  for ( c = 0; pClass[c]; c++ )
718  {
719  nSuppSizeCur = Aig_SupportSize( p->pAig, pClass[c] );
720 // nSuppSizeCur = 1;
721  if ( nSuppSizeMin > nSuppSizeCur ||
722  (nSuppSizeMin == nSuppSizeCur && pNodeMin->Level > pClass[c]->Level) )
723  {
724  nSuppSizeMin = nSuppSizeCur;
725  pNodeMin = pClass[c];
726  cMinSupp = c;
727  }
728  }
729  // skip the case when the repr did not change
730  if ( cMinSupp == 0 )
731  continue;
732  // make the new node the representative of the class
733  pClass[cMinSupp] = pClass[0];
734  pClass[0] = pNodeMin;
735  // set the representative
736  for ( c = 0; pClass[c]; c++ )
737  Fra_ClassObjSetRepr( pClass[c], c? pClass[0] : NULL );
738  }
739 }
unsigned Level
Definition: aig.h:82
Vec_Ptr_t * vClasses
Definition: fra.h:154
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigDfs.c:758
Definition: aig.h:69
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Aig_Man_t * pAig
Definition: fra.h:152
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Fra_Cla_t* Fra_ClassesStart ( Aig_Man_t pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis [Starts representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 60 of file fraClass.c.

61 {
62  Fra_Cla_t * p;
63  p = ABC_ALLOC( Fra_Cla_t, 1 );
64  memset( p, 0, sizeof(Fra_Cla_t) );
65  p->pAig = pAig;
67  memset( p->pMemRepr, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) );
68  p->vClasses = Vec_PtrAlloc( 100 );
69  p->vClasses1 = Vec_PtrAlloc( 100 );
70  p->vClassesTemp = Vec_PtrAlloc( 100 );
71  p->vClassOld = Vec_PtrAlloc( 100 );
72  p->vClassNew = Vec_PtrAlloc( 100 );
76  return p;
77 }
char * memset()
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
Definition: fraSim.c:86
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
int(* pFuncNodesAreEqual)(Aig_Obj_t *, Aig_Obj_t *)
Definition: fra.h:167
Vec_Ptr_t * vClassOld
Definition: fra.h:159
Definition: aig.h:69
int(* pFuncNodeIsConst)(Aig_Obj_t *)
Definition: fra.h:166
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
Vec_Ptr_t * vClasses1
Definition: fra.h:155
int Fra_SmlNodeHash(Aig_Obj_t *pObj, int nTableSize)
DECLARATIONS ///.
Definition: fraSim.c:46
Aig_Man_t * pAig
Definition: fra.h:152
Vec_Ptr_t * vClassNew
Definition: fra.h:160
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraSim.c:109
int(* pFuncNodeHash)(Aig_Obj_t *, int)
Definition: fra.h:165
void Fra_ClassesStop ( Fra_Cla_t p)

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

Synopsis [Stop representation of equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 90 of file fraClass.c.

91 {
92  ABC_FREE( p->pMemClasses );
93  ABC_FREE( p->pMemRepr );
94  if ( p->vClassesTemp ) Vec_PtrFree( p->vClassesTemp );
95  if ( p->vClassNew ) Vec_PtrFree( p->vClassNew );
96  if ( p->vClassOld ) Vec_PtrFree( p->vClassOld );
97  if ( p->vClasses1 ) Vec_PtrFree( p->vClasses1 );
98  if ( p->vClasses ) Vec_PtrFree( p->vClasses );
99  if ( p->vImps ) Vec_IntFree( p->vImps );
100  ABC_FREE( p );
101 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
Vec_Ptr_t * vClassesTemp
Definition: fra.h:156
Vec_Ptr_t * vClassOld
Definition: fra.h:159
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
Vec_Int_t * vImps
Definition: fra.h:163
Vec_Ptr_t * vClasses1
Definition: fra.h:155
Vec_Ptr_t * vClassNew
Definition: fra.h:160
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Fra_ClassesTest ( Fra_Cla_t p,
int  Id1,
int  Id2 
)

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

Synopsis [Starts representation of equivalence classes with one class.]

Description []

SideEffects []

SeeAlso []

Definition at line 590 of file fraClass.c.

591 {
592  Aig_Obj_t ** pClass;
593  p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 4 );
594  pClass = p->pMemClasses;
595  assert( Id1 < Id2 );
596  pClass[0] = Aig_ManObj( p->pAig, Id1 );
597  pClass[1] = Aig_ManObj( p->pAig, Id2 );
598  pClass[2] = NULL;
599  pClass[3] = NULL;
600  Fra_ClassObjSetRepr( pClass[1], pClass[0] );
601  Vec_PtrPush( p->vClasses, pClass );
602 }
Vec_Ptr_t * vClasses
Definition: fra.h:154
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
Definition: aig.h:69
Aig_Obj_t ** pMemClasses
Definition: fra.h:157
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Aig_Man_t * pAig
Definition: fra.h:152
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t* Fra_ObjChild0Equ ( Aig_Obj_t **  ppEquivs,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 746 of file fraClass.c.

746 { return Aig_NotCond(Fra_ObjEqu(ppEquivs,Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)); }
static Aig_Obj_t * Fra_ObjEqu(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:743
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Aig_Obj_t* Fra_ObjChild1Equ ( Aig_Obj_t **  ppEquivs,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 747 of file fraClass.c.

747 { return Aig_NotCond(Fra_ObjEqu(ppEquivs,Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)); }
static Aig_Obj_t * Fra_ObjEqu(Aig_Obj_t **ppEquivs, Aig_Obj_t *pObj)
Definition: fraClass.c:743
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Aig_Obj_t* Fra_ObjEqu ( Aig_Obj_t **  ppEquivs,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 743 of file fraClass.c.

743 { return ppEquivs[pObj->Id]; }
int Id
Definition: aig.h:85
static ABC_NAMESPACE_IMPL_START Aig_Obj_t* Fra_ObjNext ( Aig_Obj_t **  ppNexts,
Aig_Obj_t pObj 
)
inlinestatic

DECLARATIONS ///.

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

FileName [fraClass.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraClass.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

]

Definition at line 42 of file fraClass.c.

42 { return ppNexts[pObj->Id]; }
int Id
Definition: aig.h:85
static void Fra_ObjSetEqu ( Aig_Obj_t **  ppEquivs,
Aig_Obj_t pObj,
Aig_Obj_t pNode 
)
inlinestatic

Definition at line 744 of file fraClass.c.

744 { ppEquivs[pObj->Id] = pNode; }
int Id
Definition: aig.h:85
static void Fra_ObjSetNext ( Aig_Obj_t **  ppNexts,
Aig_Obj_t pObj,
Aig_Obj_t pNext 
)
inlinestatic

Definition at line 43 of file fraClass.c.

43 { ppNexts[pObj->Id] = pNext; }
int Id
Definition: aig.h:85
void Fra_PrintClass ( Fra_Cla_t p,
Aig_Obj_t **  pClass 
)

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

Synopsis [Prints simulation classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file fraClass.c.

214 {
215  Aig_Obj_t * pTemp;
216  int i;
217  for ( i = 1; (pTemp = pClass[i]); i++ )
218  assert( Fra_ClassObjRepr(pTemp) == pClass[0] );
219  printf( "{ " );
220  for ( i = 0; (pTemp = pClass[i]); i++ )
221  printf( "%d(%d,%d) ", pTemp->Id, pTemp->Level, Aig_SupportSize(p->pAig,pTemp) );
222  printf( "}\n" );
223 }
unsigned Level
Definition: aig.h:82
int Aig_SupportSize(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigDfs.c:758
Definition: aig.h:69
Aig_Man_t * pAig
Definition: fra.h:152
static Aig_Obj_t * Fra_ClassObjRepr(Aig_Obj_t *pObj)
Definition: fra.h:269
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
int Fra_RefineClassLastIter ( Fra_Cla_t p,
Vec_Ptr_t vClasses 
)

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

Synopsis [Iteratively refines the classes after simulation.]

Description [Returns the number of refinements performed.]

SideEffects []

SeeAlso []

Definition at line 457 of file fraClass.c.

458 {
459  Aig_Obj_t ** pClass, ** pClass2;
460  int nRefis;
461  pClass = (Aig_Obj_t **)Vec_PtrEntryLast( vClasses );
462  for ( nRefis = 0; (pClass2 = Fra_RefineClassOne( p, pClass )); nRefis++ )
463  {
464  // if the original class is trivial, remove it
465  if ( pClass[1] == NULL )
466  Vec_PtrPop( vClasses );
467  // if the new class is trivial, stop
468  if ( pClass2[1] == NULL )
469  {
470  nRefis++;
471  break;
472  }
473  // othewise, add the class and continue
474  assert( pClass2[0] != NULL );
475  Vec_PtrPush( vClasses, pClass2 );
476  pClass = pClass2;
477  }
478  return nRefis;
479 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
Aig_Obj_t ** Fra_RefineClassOne(Fra_Cla_t *p, Aig_Obj_t **ppClass)
Definition: fraClass.c:398
Definition: aig.h:69
#define assert(ex)
Definition: util_old.h:213
Aig_Obj_t** Fra_RefineClassOne ( Fra_Cla_t p,
Aig_Obj_t **  ppClass 
)

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

Synopsis [Refines one class using simulation info.]

Description [Returns the new class if refinement happened.]

SideEffects []

SeeAlso []

Definition at line 398 of file fraClass.c.

399 {
400  Aig_Obj_t * pObj, ** ppThis;
401  int i;
402  assert( ppClass[0] != NULL && ppClass[1] != NULL );
403 
404  // check if the class is going to be refined
405  for ( ppThis = ppClass + 1; (pObj = *ppThis); ppThis++ )
406  if ( !p->pFuncNodesAreEqual(ppClass[0], pObj) )
407  break;
408  if ( pObj == NULL )
409  return NULL;
410  // split the class
411  Vec_PtrClear( p->vClassOld );
412  Vec_PtrClear( p->vClassNew );
413  Vec_PtrPush( p->vClassOld, ppClass[0] );
414  for ( ppThis = ppClass + 1; (pObj = *ppThis); ppThis++ )
415  if ( p->pFuncNodesAreEqual(ppClass[0], pObj) )
416  Vec_PtrPush( p->vClassOld, pObj );
417  else
418  Vec_PtrPush( p->vClassNew, pObj );
419 /*
420  printf( "Refining class (" );
421  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
422  printf( "%d,", pObj->Id );
423  printf( ") + (" );
424  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
425  printf( "%d,", pObj->Id );
426  printf( ")\n" );
427 */
428  // put the nodes back into the class memory
429  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
430  {
431  ppClass[i] = pObj;
432  ppClass[Vec_PtrSize(p->vClassOld)+i] = NULL;
433  Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
434  }
435  ppClass += 2*Vec_PtrSize(p->vClassOld);
436  // put the new nodes into the class memory
437  Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
438  {
439  ppClass[i] = pObj;
440  ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
441  Fra_ClassObjSetRepr( pObj, i? ppClass[0] : NULL );
442  }
443  return ppClass;
444 }
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int(* pFuncNodesAreEqual)(Aig_Obj_t *, Aig_Obj_t *)
Definition: fra.h:167
Vec_Ptr_t * vClassOld
Definition: fra.h:159
Definition: aig.h:69
static void Fra_ClassObjSetRepr(Aig_Obj_t *pObj, Aig_Obj_t *pNode)
Definition: fra.h:270
Vec_Ptr_t * vClassNew
Definition: fra.h:160
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55