abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaCof.c File Reference
#include <math.h>
#include "gia.h"

Go to the source code of this file.

Data Structures

struct  Cof_Fan_t_
 
struct  Cof_Obj_t_
 
struct  Cof_Man_t_
 

Macros

#define Cof_ManForEachObj(p, pObj, i)   for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) )
 
#define Cof_ManForEachNode(p, pObj, i)   for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) if ( Cof_ObjIsTerm(pObj) ) {} else
 
#define Cof_ObjForEachFanin(pObj, pNext, i)   for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Cof_ObjFanin(pObj,i)); i++ )
 
#define Cof_ObjForEachFanout(pObj, pNext, i)   for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Cof_ObjFanout(pObj,i)); i++ )
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Cof_Fan_t_ 
Cof_Fan_t
 DECLARATIONS ///. More...
 
typedef struct Cof_Obj_t_ Cof_Obj_t
 
typedef struct Cof_Man_t_ Cof_Man_t
 

Functions

static unsigned Gia_ObjHandle (Gia_Obj_t *pObj)
 
static int Cof_ObjLevel (Cof_Man_t *p, Cof_Obj_t *pObj)
 
static unsigned Cof_ObjHandle (Cof_Man_t *p, Cof_Obj_t *pObj)
 
static unsigned Cof_ObjHandleDiff (Cof_Obj_t *pObj, Cof_Obj_t *pFanin)
 
static int Cof_ObjIsTerm (Cof_Obj_t *pObj)
 
static int Cof_ObjIsCi (Cof_Obj_t *pObj)
 
static int Cof_ObjIsCo (Cof_Obj_t *pObj)
 
static int Cof_ObjIsNode (Cof_Obj_t *pObj)
 
static int Cof_ObjIsConst0 (Cof_Obj_t *pObj)
 
static int Cof_ObjFaninNum (Cof_Obj_t *pObj)
 
static int Cof_ObjFanoutNum (Cof_Obj_t *pObj)
 
static int Cof_ObjSize (Cof_Obj_t *pObj)
 
static Cof_Obj_tCof_ManObj (Cof_Man_t *p, unsigned iHandle)
 
static Cof_Obj_tCof_ObjFanin (Cof_Obj_t *pObj, int i)
 
static Cof_Obj_tCof_ObjFanout (Cof_Obj_t *pObj, int i)
 
static int Cof_ManObjNum (Cof_Man_t *p)
 
static int Cof_ManNodeNum (Cof_Man_t *p)
 
static void Cof_ManResetTravId (Cof_Man_t *p)
 
static void Cof_ManIncrementTravId (Cof_Man_t *p)
 
static void Cof_ObjSetTravId (Cof_Obj_t *pObj, int TravId)
 
static void Cof_ObjSetTravIdCurrent (Cof_Man_t *p, Cof_Obj_t *pObj)
 
static void Cof_ObjSetTravIdPrevious (Cof_Man_t *p, Cof_Obj_t *pObj)
 
static int Cof_ObjIsTravIdCurrent (Cof_Man_t *p, Cof_Obj_t *pObj)
 
static int Cof_ObjIsTravIdPrevious (Cof_Man_t *p, Cof_Obj_t *pObj)
 
Cof_Man_tCof_ManCreateLogicSimple (Gia_Man_t *pGia)
 FUNCTION DEFINITIONS ///. More...
 
void Cof_ManStop (Cof_Man_t *p)
 
int Cof_ManTfoSize_rec (Cof_Man_t *p, Cof_Obj_t *pObj)
 
int Cof_ManTfoSize (Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
 
int Cof_ManTfiSize_rec (Cof_Man_t *p, Cof_Obj_t *pObj)
 
int Cof_ManTfiSize (Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
 
int Cof_ManSuppSize_rec (Cof_Man_t *p, Cof_Obj_t *pObj)
 
int Cof_ManSuppSize (Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
 
void Cof_ManCleanValue (Cof_Man_t *p)
 
void Cof_ManInsertEntry_rec (Vec_Ptr_t *vNodes, Cof_Obj_t *pNode, int nNodeMax)
 
Vec_Ptr_tCof_ManCollectHighFanout (Cof_Man_t *p, int nNodes)
 
int Cof_ManCountRemoved (Cof_Man_t *p, Cof_Obj_t *pRoot, int fConst1)
 
void Cof_ManPrintHighFanoutOne (Cof_Man_t *p, Cof_Obj_t *pObj)
 
void Cof_ManPrintHighFanout (Cof_Man_t *p, int nNodes)
 
int Cof_NodeDeref_rec (Cof_Obj_t *pNode)
 
int Cof_NodeRef_rec (Cof_Obj_t *pNode)
 
static int Cof_ObjMffcSize (Cof_Obj_t *pNode)
 
void Cof_ManPrintFanio (Cof_Man_t *p)
 
void Gia_ManPrintFanio (Gia_Man_t *pGia, int nNodes)
 
Gia_Man_tGia_ManDupCofInt (Gia_Man_t *p, int iVar)
 
Gia_Man_tGia_ManDupCof (Gia_Man_t *p, int iVar)
 
Vec_Int_tGia_ManCofVars (Gia_Man_t *p, int nFanLim)
 
Vec_Int_tGia_ManTransfer (Gia_Man_t *pAig, Gia_Man_t *pCof, Gia_Man_t *pNew, Vec_Int_t *vSigs)
 
Gia_Man_tGia_ManDupCofAllInt (Gia_Man_t *p, Vec_Int_t *vSigs, int fVerbose)
 
Gia_Man_tGia_ManDupCofAll (Gia_Man_t *p, int nFanLim, int fVerbose)
 

Macro Definition Documentation

#define Cof_ManForEachNode (   p,
  pObj,
 
)    for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) if ( Cof_ObjIsTerm(pObj) ) {} else

Definition at line 104 of file giaCof.c.

#define Cof_ManForEachObj (   p,
  pObj,
 
)    for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) )

Definition at line 102 of file giaCof.c.

#define Cof_ObjForEachFanin (   pObj,
  pNext,
 
)    for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Cof_ObjFanin(pObj,i)); i++ )

Definition at line 106 of file giaCof.c.

#define Cof_ObjForEachFanout (   pObj,
  pNext,
 
)    for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Cof_ObjFanout(pObj,i)); i++ )

Definition at line 108 of file giaCof.c.

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Cof_Fan_t_ Cof_Fan_t

DECLARATIONS ///.

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

FileName [giaCof.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Cofactor estimation procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaCof.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 31 of file giaCof.c.

typedef struct Cof_Man_t_ Cof_Man_t

Definition at line 55 of file giaCof.c.

typedef struct Cof_Obj_t_ Cof_Obj_t

Definition at line 38 of file giaCof.c.

Function Documentation

void Cof_ManCleanValue ( Cof_Man_t p)

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

Synopsis [Cleans the value.]

Description []

SideEffects []

SeeAlso []

Definition at line 369 of file giaCof.c.

370 {
371  Cof_Obj_t * pObj;
372  int i;
373  Cof_ManForEachObj( p, pObj, i )
374  pObj->Value = 0;
375 }
#define Cof_ManForEachObj(p, pObj, i)
Definition: giaCof.c:102
Vec_Ptr_t* Cof_ManCollectHighFanout ( Cof_Man_t p,
int  nNodes 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 422 of file giaCof.c.

423 {
424  Vec_Ptr_t * vNodes;
425  Cof_Obj_t * pObj;
426  int i;
427  vNodes = Vec_PtrAlloc( nNodes );
428  Cof_ManForEachObj( p, pObj, i )
429  if ( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) )
430  Cof_ManInsertEntry_rec( vNodes, pObj, nNodes );
431  return vNodes;
432 }
static int Cof_ObjIsCi(Cof_Obj_t *pObj)
Definition: giaCof.c:78
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Cof_ManInsertEntry_rec(Vec_Ptr_t *vNodes, Cof_Obj_t *pNode, int nNodeMax)
Definition: giaCof.c:388
static int Cof_ObjIsNode(Cof_Obj_t *pObj)
Definition: giaCof.c:80
if(last==0)
Definition: sparse_int.h:34
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Cof_ManForEachObj(p, pObj, i)
Definition: giaCof.c:102
int Cof_ManCountRemoved ( Cof_Man_t p,
Cof_Obj_t pRoot,
int  fConst1 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 445 of file giaCof.c.

446 {
447  Gia_Obj_t * pNextGia;
448  Cof_Obj_t * pTemp, * pNext, * pFanin0, * pFanin1;
449  int Counter = 0, LevelStart, LevelNext;
450  int i, k, iHandle, iLit0, iLit1, iNextNew;
451  // restart the trav ids
453  Cof_ObjSetTravIdCurrent( p, pRoot );
454  // add the node to the queue
455  LevelStart = Cof_ObjLevel(p, pRoot);
456  assert( p->pLevels[LevelStart] == 0 );
457  pRoot->iNext = 0;
458  p->pLevels[LevelStart] = Cof_ObjHandle( p, pRoot );
459  // set the new literal
460  pRoot->iLit = Abc_Var2Lit( 0, fConst1 );
461  // process nodes in the levelized order
462  for ( i = LevelStart; i < p->nLevels; i++ )
463  {
464  for ( iHandle = p->pLevels[i];
465  iHandle && (pTemp = Cof_ManObj(p, iHandle));
466  iHandle = pTemp->iNext )
467  {
468  assert( pTemp->Id != Abc_Lit2Var(pTemp->iLit) );
469  Cof_ObjForEachFanout( pTemp, pNext, k )
470  {
471  if ( Cof_ObjIsCo(pNext) )
472  continue;
473  if ( Cof_ObjIsTravIdCurrent(p, pNext) )
474  continue;
475  pFanin0 = Cof_ObjFanin( pNext, 0 );
476  pFanin1 = Cof_ObjFanin( pNext, 1 );
477  assert( pFanin0 == pTemp || pFanin1 == pTemp );
478  pNextGia = Gia_ManObj( p->pGia, pNext->Id );
479  if ( Cof_ObjIsTravIdCurrent(p, pFanin0) )
480  iLit0 = Abc_LitNotCond( pFanin0->iLit, Gia_ObjFaninC0(pNextGia) );
481  else
482  iLit0 = Gia_ObjFaninLit0( pNextGia, pNext->Id );
483  if ( Cof_ObjIsTravIdCurrent(p, pFanin1) )
484  iLit1 = Abc_LitNotCond( pFanin1->iLit, Gia_ObjFaninC1(pNextGia) );
485  else
486  iLit1 = Gia_ObjFaninLit1( pNextGia, pNext->Id );
487  iNextNew = Gia_ManHashAndTry( p->pGia, iLit0, iLit1 );
488  if ( iNextNew == -1 )
489  continue;
490  Cof_ObjSetTravIdCurrent(p, pNext);
491  // set the new literal
492  pNext->iLit = iNextNew;
493  // add it to be processed
494  LevelNext = Cof_ObjLevel( p, pNext );
495  assert( LevelNext > i && LevelNext < p->nLevels );
496  pNext->iNext = p->pLevels[LevelNext];
497  p->pLevels[LevelNext] = Cof_ObjHandle( p, pNext );
498  Counter++;
499  }
500  }
501  p->pLevels[i] = 0;
502  }
503  return Counter;
504 }
static int Gia_ObjFaninLit0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:466
static int Cof_ObjIsCo(Cof_Obj_t *pObj)
Definition: giaCof.c:79
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
Definition: giaCof.c:88
int nLevels
Definition: giaCof.c:67
int iLit
Definition: giaCof.c:51
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static void Cof_ManIncrementTravId(Cof_Man_t *p)
Definition: giaCof.c:95
int Gia_ManHashAndTry(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:627
Gia_Man_t * pGia
Definition: giaCof.c:58
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
int Id
Definition: giaCof.c:49
static int Cof_ObjIsTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:99
static int Gia_ObjFaninLit1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:467
static unsigned Cof_ObjHandle(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:74
static void Cof_ObjSetTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:97
static int Counter
#define Cof_ObjForEachFanout(pObj, pNext, i)
Definition: giaCof.c:108
int iNext
Definition: giaCof.c:50
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Cof_ObjLevel(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:72
#define assert(ex)
Definition: util_old.h:213
int * pLevels
Definition: giaCof.c:66
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static Cof_Obj_t * Cof_ManObj(Cof_Man_t *p, unsigned iHandle)
Definition: giaCof.c:87
Cof_Man_t* Cof_ManCreateLogicSimple ( Gia_Man_t pGia)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates logic network isomorphic to the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file giaCof.c.

127 {
128  Cof_Man_t * p;
129  Cof_Obj_t * pObjLog, * pFanLog;
130  Gia_Obj_t * pObj;
131  int * pMuxRefs;
132  int i, iHandle = 0;
133  p = ABC_CALLOC( Cof_Man_t, 1 );
134  p->pGia = pGia;
135  p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) );
136  p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) );
137  p->nObjData = (sizeof(Cof_Obj_t) / 4) * Gia_ManObjNum(pGia) + 4 * Gia_ManAndNum(pGia) + 2 * Gia_ManCoNum(pGia);
138  p->pObjData = ABC_CALLOC( int, p->nObjData );
139  ABC_FREE( pGia->pRefs );
140  Gia_ManCreateRefs( pGia );
141  Gia_ManForEachObj( pGia, pObj, i )
142  {
143  pObj->Value = iHandle;
144  pObjLog = Cof_ManObj( p, iHandle );
145  pObjLog->nFanins = 0;
146  pObjLog->nFanouts = Gia_ObjRefNum( pGia, pObj );
147  pObjLog->Id = i;
148  pObjLog->Value = 0;
149  if ( Gia_ObjIsAnd(pObj) )
150  {
151  pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) );
152  pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
153  pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
154  pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj);
155 
156  pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin1(pObj)) );
157  pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
158  pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
159  pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC1(pObj);
160  p->nNodes++;
161  }
162  else if ( Gia_ObjIsCo(pObj) )
163  {
164  pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) );
165  pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan =
166  pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog );
167  pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj);
168 
169  pObjLog->fTerm = 1;
170  Vec_IntPush( p->vCos, iHandle );
171  }
172  else if ( Gia_ObjIsCi(pObj) )
173  {
174  pObjLog->fTerm = 1;
175  Vec_IntPush( p->vCis, iHandle );
176  }
177  iHandle += Cof_ObjSize( pObjLog );
178  p->nObjs++;
179  }
180  assert( iHandle == p->nObjData );
181  pMuxRefs = Gia_ManCreateMuxRefs( pGia );
182  Gia_ManForEachObj( pGia, pObj, i )
183  {
184  pObjLog = Cof_ManObj( p, Gia_ObjHandle(pObj) );
185  assert( pObjLog->nFanouts == pObjLog->Value );
186  pObjLog->nFanoutsM = pMuxRefs[i];
187  }
188  ABC_FREE( pMuxRefs );
189  return p;
190 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
unsigned nFanouts
Definition: giaCof.c:46
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Int_t * vCis
Definition: giaCof.c:59
struct Cof_Obj_t_ Cof_Obj_t
Definition: giaCof.c:38
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
Gia_Man_t * pGia
Definition: giaCof.c:58
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
int nNodes
Definition: giaCof.c:62
unsigned nFanoutsM
Definition: giaCof.c:47
int Id
Definition: giaCof.c:49
int * Gia_ManCreateMuxRefs(Gia_Man_t *p)
Definition: giaUtil.c:746
static unsigned Cof_ObjHandleDiff(Cof_Obj_t *pObj, Cof_Obj_t *pFanin)
Definition: giaCof.c:75
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
int * pObjData
Definition: giaCof.c:64
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int nObjData
Definition: giaCof.c:65
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned nFanins
Definition: giaCof.c:45
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
unsigned Value
Definition: giaCof.c:48
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static unsigned Gia_ObjHandle(Gia_Obj_t *pObj)
Definition: giaCof.c:70
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
unsigned fTerm
Definition: giaCof.c:41
int nObjs
Definition: giaCof.c:61
static int Cof_ObjSize(Cof_Obj_t *pObj)
Definition: giaCof.c:85
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Vec_Int_t * vCos
Definition: giaCof.c:60
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
Cof_Fan_t Fanios[0]
Definition: giaCof.c:52
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static Cof_Obj_t * Cof_ManObj(Cof_Man_t *p, unsigned iHandle)
Definition: giaCof.c:87
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
static void Cof_ManIncrementTravId ( Cof_Man_t p)
inlinestatic

Definition at line 95 of file giaCof.c.

95 { p->nTravIds++; }
int nTravIds
Definition: giaCof.c:63
void Cof_ManInsertEntry_rec ( Vec_Ptr_t vNodes,
Cof_Obj_t pNode,
int  nNodeMax 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 388 of file giaCof.c.

389 {
390  Cof_Obj_t * pLast;
391  if ( Vec_PtrSize(vNodes) == 0 )
392  {
393  Vec_PtrPush(vNodes, pNode);
394  return;
395  }
396  pLast = (Cof_Obj_t *)Vec_PtrPop(vNodes);
397  if ( Cof_ObjFanoutNum(pLast) < Cof_ObjFanoutNum(pNode) )
398  {
399  Cof_ManInsertEntry_rec( vNodes, pNode, nNodeMax );
400  if ( Vec_PtrSize(vNodes) < nNodeMax )
401  Vec_PtrPush( vNodes, pLast );
402  }
403  else
404  {
405  Vec_PtrPush( vNodes, pLast );
406  if ( Vec_PtrSize(vNodes) < nNodeMax )
407  Vec_PtrPush( vNodes, pNode );
408  }
409 }
void Cof_ManInsertEntry_rec(Vec_Ptr_t *vNodes, Cof_Obj_t *pNode, int nNodeMax)
Definition: giaCof.c:388
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Cof_ObjFanoutNum(Cof_Obj_t *pObj)
Definition: giaCof.c:84
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
static int Cof_ManNodeNum ( Cof_Man_t p)
inlinestatic

Definition at line 92 of file giaCof.c.

92 { return p->nNodes; }
int nNodes
Definition: giaCof.c:62
static Cof_Obj_t* Cof_ManObj ( Cof_Man_t p,
unsigned  iHandle 
)
inlinestatic

Definition at line 87 of file giaCof.c.

87 { return (Cof_Obj_t *)(p->pObjData + iHandle); }
int * pObjData
Definition: giaCof.c:64
static int Cof_ManObjNum ( Cof_Man_t p)
inlinestatic

Definition at line 91 of file giaCof.c.

91 { return p->nObjs; }
int nObjs
Definition: giaCof.c:61
void Cof_ManPrintFanio ( Cof_Man_t p)

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

Synopsis [Prints the distribution of fanins/fanouts in the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 605 of file giaCof.c.

606 {
607  char Buffer[100];
608  Cof_Obj_t * pNode;
609  Vec_Int_t * vFanins, * vFanouts, * vMffcs;
610  int nFanins, nFanouts, nMffcs, nFaninsMax, nFanoutsMax, nMffcsMax, nFaninsAll, nFanoutsAll, nMffcsAll;
611  int i, k, nSizeMax, nMffcNodes = 0;
612 
613  // determine the largest fanin and fanout
614  nFaninsMax = nFanoutsMax = nMffcsMax = 0;
615  nFaninsAll = nFanoutsAll = nMffcsAll = 0;
616  Cof_ManForEachNode( p, pNode, i )
617  {
618  if ( i == 0 ) continue;
619  nFanins = Cof_ObjFaninNum(pNode);
620  nFanouts = Cof_ObjFanoutNum(pNode);
621  nMffcs = pNode->nFanouts > 1 ? Cof_ObjMffcSize(pNode) : 0;
622  nFaninsAll += nFanins;
623  nFanoutsAll += nFanouts;
624  nMffcsAll += nMffcs;
625  nFaninsMax = Abc_MaxInt( nFaninsMax, nFanins );
626  nFanoutsMax = Abc_MaxInt( nFanoutsMax, nFanouts );
627  nMffcsMax = Abc_MaxInt( nMffcsMax, nMffcs );
628  }
629 
630  // allocate storage for fanin/fanout numbers
631  nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nFaninsMax) + 1), 10 * (Abc_Base10Log(nFanoutsMax) + 1) );
632  nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nMffcsMax) + 1), nSizeMax );
633  vFanins = Vec_IntStart( nSizeMax );
634  vFanouts = Vec_IntStart( nSizeMax );
635  vMffcs = Vec_IntStart( nSizeMax );
636 
637  // count the number of fanins and fanouts
638  Cof_ManForEachNode( p, pNode, i )
639  {
640  if ( i == 0 ) continue;
641  nFanins = Cof_ObjFaninNum(pNode);
642  nFanouts = Cof_ObjFanoutNum(pNode);
643  nMffcs = pNode->nFanouts > 1 ? Cof_ObjMffcSize(pNode) : 0;
644 
645  if ( nFanins < 10 )
646  Vec_IntAddToEntry( vFanins, nFanins, 1 );
647  else if ( nFanins < 100 )
648  Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
649  else if ( nFanins < 1000 )
650  Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
651  else if ( nFanins < 10000 )
652  Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
653  else if ( nFanins < 100000 )
654  Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
655  else if ( nFanins < 1000000 )
656  Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
657  else if ( nFanins < 10000000 )
658  Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
659 
660  if ( nFanouts < 10 )
661  Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
662  else if ( nFanouts < 100 )
663  Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
664  else if ( nFanouts < 1000 )
665  Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
666  else if ( nFanouts < 10000 )
667  Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
668  else if ( nFanouts < 100000 )
669  Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
670  else if ( nFanouts < 1000000 )
671  Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
672  else if ( nFanouts < 10000000 )
673  Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
674 
675  if ( nMffcs == 0 )
676  continue;
677  nMffcNodes++;
678 
679  if ( nMffcs < 10 )
680  Vec_IntAddToEntry( vMffcs, nMffcs, 1 );
681  else if ( nMffcs < 100 )
682  Vec_IntAddToEntry( vMffcs, 10 + nMffcs/10, 1 );
683  else if ( nMffcs < 1000 )
684  Vec_IntAddToEntry( vMffcs, 20 + nMffcs/100, 1 );
685  else if ( nMffcs < 10000 )
686  Vec_IntAddToEntry( vMffcs, 30 + nMffcs/1000, 1 );
687  else if ( nMffcs < 100000 )
688  Vec_IntAddToEntry( vMffcs, 40 + nMffcs/10000, 1 );
689  else if ( nMffcs < 1000000 )
690  Vec_IntAddToEntry( vMffcs, 50 + nMffcs/100000, 1 );
691  else if ( nMffcs < 10000000 )
692  Vec_IntAddToEntry( vMffcs, 60 + nMffcs/1000000, 1 );
693  }
694 
695  printf( "The distribution of fanins, fanouts. and MFFCs in the network:\n" );
696  printf( " Number Nodes with fanin Nodes with fanout Nodes with MFFC\n" );
697 
698  for ( k = 0; k < nSizeMax; k++ )
699  {
700  if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 && vMffcs->pArray[k] == 0 )
701  continue;
702  if ( k < 10 )
703  printf( "%15d : ", k );
704  else
705  {
706  sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
707  printf( "%15s : ", Buffer );
708  }
709  if ( vFanins->pArray[k] == 0 )
710  printf( " " );
711  else
712  printf( "%11d ", vFanins->pArray[k] );
713  printf( " " );
714  if ( vFanouts->pArray[k] == 0 )
715  printf( " " );
716  else
717  printf( "%12d ", vFanouts->pArray[k] );
718  printf( " " );
719  if ( vMffcs->pArray[k] == 0 )
720  printf( " " );
721  else
722  printf( " %12d ", vMffcs->pArray[k] );
723  printf( "\n" );
724  }
725  Vec_IntFree( vFanins );
726  Vec_IntFree( vFanouts );
727  Vec_IntFree( vMffcs );
728 
729  printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f. MFFCs: Max = %d. Ave = %.2f.\n",
730  nFaninsMax, 1.0*nFaninsAll /Cof_ManNodeNum(p),
731  nFanoutsMax, 1.0*nFanoutsAll/Cof_ManNodeNum(p),
732  nMffcsMax, 1.0*nMffcsAll /nMffcNodes );
733 }
unsigned nFanouts
Definition: giaCof.c:46
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Cof_ObjFanoutNum(Cof_Obj_t *pObj)
Definition: giaCof.c:84
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Cof_ObjFaninNum(Cof_Obj_t *pObj)
Definition: giaCof.c:83
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Cof_ObjMffcSize(Cof_Obj_t *pNode)
Definition: giaCof.c:582
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
char * sprintf()
static int Cof_ManNodeNum(Cof_Man_t *p)
Definition: giaCof.c:92
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Cof_ManForEachNode(p, pObj, i)
Definition: giaCof.c:104
void Cof_ManPrintHighFanout ( Cof_Man_t p,
int  nNodes 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 541 of file giaCof.c.

542 {
543  Vec_Ptr_t * vNodes;
544  Cof_Obj_t * pObj;
545  int i;
546  vNodes = Cof_ManCollectHighFanout( p, nNodes );
547  Vec_PtrForEachEntry( Cof_Obj_t *, vNodes, pObj, i )
548  Cof_ManPrintHighFanoutOne( p, pObj );
549  Vec_PtrFree( vNodes );
550 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Cof_ManPrintHighFanoutOne(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:517
Vec_Ptr_t * Cof_ManCollectHighFanout(Cof_Man_t *p, int nNodes)
Definition: giaCof.c:422
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Cof_ManPrintHighFanoutOne ( Cof_Man_t p,
Cof_Obj_t pObj 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 517 of file giaCof.c.

518 {
519  printf( "%7d : ", pObj->Id );
520  printf( "i/o/c =%2d %5d %5d ", Cof_ObjFaninNum(pObj), Cof_ObjFanoutNum(pObj), 2*pObj->nFanoutsM );
521  printf( "l =%4d ", Cof_ObjLevel(p, pObj) );
522  printf( "s =%5d ", Cof_ManSuppSize(p, &pObj, 1) );
523  printf( "TFI =%7d ", Cof_ManTfiSize(p, &pObj, 1) );
524  printf( "TFO =%7d ", Cof_ManTfoSize(p, &pObj, 1) );
525  printf( "C0 =%6d ", Cof_ManCountRemoved(p, pObj, 0) );
526  printf( "C1 =%6d", Cof_ManCountRemoved(p, pObj, 1) );
527  printf( "\n" );
528 }
int Cof_ManTfiSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
Definition: giaCof.c:296
int Cof_ManTfoSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
Definition: giaCof.c:250
static int Cof_ObjFanoutNum(Cof_Obj_t *pObj)
Definition: giaCof.c:84
static int Cof_ObjFaninNum(Cof_Obj_t *pObj)
Definition: giaCof.c:83
unsigned nFanoutsM
Definition: giaCof.c:47
int Id
Definition: giaCof.c:49
int Cof_ManCountRemoved(Cof_Man_t *p, Cof_Obj_t *pRoot, int fConst1)
Definition: giaCof.c:445
static int Cof_ObjLevel(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:72
int Cof_ManSuppSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
Definition: giaCof.c:345
static void Cof_ManResetTravId ( Cof_Man_t p)
inlinestatic

Definition at line 94 of file giaCof.c.

94 { extern void Cof_ManCleanValue( Cof_Man_t * p ); Cof_ManCleanValue( p ); p->nTravIds = 1; }
int nTravIds
Definition: giaCof.c:63
void Cof_ManCleanValue(Cof_Man_t *p)
Definition: giaCof.c:369
void Cof_ManStop ( Cof_Man_t p)

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

Synopsis [Creates logic network isomorphic to the given AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 203 of file giaCof.c.

204 {
205  Vec_IntFree( p->vCis );
206  Vec_IntFree( p->vCos );
207  ABC_FREE( p->pObjData );
208  ABC_FREE( p->pLevels );
209  ABC_FREE( p );
210 }
Vec_Int_t * vCis
Definition: giaCof.c:59
int * pObjData
Definition: giaCof.c:64
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * pLevels
Definition: giaCof.c:66
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Int_t * vCos
Definition: giaCof.c:60
int Cof_ManSuppSize ( Cof_Man_t p,
Cof_Obj_t **  ppObjs,
int  nObjs 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 345 of file giaCof.c.

346 {
347  int i, Counter = 0;
349  for ( i = 0; i < nObjs; i++ )
350  if ( Cof_ObjIsCo(ppObjs[i]) )
351  Counter += Cof_ManSuppSize_rec( p, Cof_ObjFanin(ppObjs[i],0) );
352  else
353  Counter += Cof_ManSuppSize_rec( p, ppObjs[i] );
354  return Counter;
355 }
static int Cof_ObjIsCo(Cof_Obj_t *pObj)
Definition: giaCof.c:79
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
Definition: giaCof.c:88
static void Cof_ManIncrementTravId(Cof_Man_t *p)
Definition: giaCof.c:95
int Cof_ManSuppSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:319
static int Counter
int Cof_ManSuppSize_rec ( Cof_Man_t p,
Cof_Obj_t pObj 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file giaCof.c.

320 {
321  Cof_Obj_t * pNext;
322  unsigned i, Counter = 0;
323  if ( Cof_ObjIsTravIdCurrent(p, pObj) )
324  return 0;
325  Cof_ObjSetTravIdCurrent(p, pObj);
326  if ( Cof_ObjIsCi(pObj) )
327  return 1;
328  assert( Cof_ObjIsNode(pObj) );
329  Cof_ObjForEachFanin( pObj, pNext, i )
330  Counter += Cof_ManSuppSize_rec( p, pNext );
331  return Counter;
332 }
static int Cof_ObjIsCi(Cof_Obj_t *pObj)
Definition: giaCof.c:78
int Cof_ManSuppSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:319
static int Cof_ObjIsTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:99
static int Cof_ObjIsNode(Cof_Obj_t *pObj)
Definition: giaCof.c:80
static void Cof_ObjSetTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:97
static int Counter
#define Cof_ObjForEachFanin(pObj, pNext, i)
Definition: giaCof.c:106
#define assert(ex)
Definition: util_old.h:213
int Cof_ManTfiSize ( Cof_Man_t p,
Cof_Obj_t **  ppObjs,
int  nObjs 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 296 of file giaCof.c.

297 {
298  int i, Counter = 0;
300  for ( i = 0; i < nObjs; i++ )
301  if ( Cof_ObjIsCo(ppObjs[i]) )
302  Counter += Cof_ManTfiSize_rec( p, Cof_ObjFanin(ppObjs[i],0) );
303  else
304  Counter += Cof_ManTfiSize_rec( p, ppObjs[i] );
305  return Counter;
306 }
static int Cof_ObjIsCo(Cof_Obj_t *pObj)
Definition: giaCof.c:79
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
Definition: giaCof.c:88
static void Cof_ManIncrementTravId(Cof_Man_t *p)
Definition: giaCof.c:95
static int Counter
int Cof_ManTfiSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:270
int Cof_ManTfiSize_rec ( Cof_Man_t p,
Cof_Obj_t pObj 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file giaCof.c.

271 {
272  Cof_Obj_t * pNext;
273  unsigned i, Counter = 0;
274  if ( Cof_ObjIsTravIdCurrent(p, pObj) )
275  return 0;
276  Cof_ObjSetTravIdCurrent(p, pObj);
277  if ( Cof_ObjIsCi(pObj) )
278  return 0;
279  assert( Cof_ObjIsNode(pObj) );
280  Cof_ObjForEachFanin( pObj, pNext, i )
281  Counter += Cof_ManTfiSize_rec( p, pNext );
282  return 1 + Counter;
283 }
static int Cof_ObjIsCi(Cof_Obj_t *pObj)
Definition: giaCof.c:78
static int Cof_ObjIsTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:99
static int Cof_ObjIsNode(Cof_Obj_t *pObj)
Definition: giaCof.c:80
static void Cof_ObjSetTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:97
static int Counter
int Cof_ManTfiSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:270
#define Cof_ObjForEachFanin(pObj, pNext, i)
Definition: giaCof.c:106
#define assert(ex)
Definition: util_old.h:213
int Cof_ManTfoSize ( Cof_Man_t p,
Cof_Obj_t **  ppObjs,
int  nObjs 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file giaCof.c.

251 {
252  int i, Counter = 0;
254  for ( i = 0; i < nObjs; i++ )
255  Counter += Cof_ManTfoSize_rec( p, ppObjs[i] ) - 1;
256  return Counter;
257 }
static void Cof_ManIncrementTravId(Cof_Man_t *p)
Definition: giaCof.c:95
static int Counter
int Cof_ManTfoSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:224
int Cof_ManTfoSize_rec ( Cof_Man_t p,
Cof_Obj_t pObj 
)

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

Synopsis [Collects support nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file giaCof.c.

225 {
226  Cof_Obj_t * pNext;
227  unsigned i, Counter = 0;
228  if ( Cof_ObjIsTravIdCurrent(p, pObj) )
229  return 0;
230  Cof_ObjSetTravIdCurrent(p, pObj);
231  if ( Cof_ObjIsCo(pObj) )
232  return 0;
233  assert( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) );
234  Cof_ObjForEachFanout( pObj, pNext, i )
235  Counter += Cof_ManTfoSize_rec( p, pNext );
236  return 1 + Counter;
237 }
static int Cof_ObjIsCi(Cof_Obj_t *pObj)
Definition: giaCof.c:78
static int Cof_ObjIsCo(Cof_Obj_t *pObj)
Definition: giaCof.c:79
static int Cof_ObjIsTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:99
static int Cof_ObjIsNode(Cof_Obj_t *pObj)
Definition: giaCof.c:80
static void Cof_ObjSetTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:97
static int Counter
#define Cof_ObjForEachFanout(pObj, pNext, i)
Definition: giaCof.c:108
int Cof_ManTfoSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
Definition: giaCof.c:224
#define assert(ex)
Definition: util_old.h:213
int Cof_NodeDeref_rec ( Cof_Obj_t pNode)

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

Synopsis [Compute MFFC size of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 564 of file giaCof.c.

565 {
566  if ( pNode->nFanins == 0 )
567  return 0;
568  if ( --pNode->nFanouts > 0 )
569  return 0;
570  return 1 + Cof_NodeDeref_rec( Cof_ObjFanin(pNode, 0) )
571  + Cof_NodeDeref_rec( Cof_ObjFanin(pNode, 1) );
572 }
unsigned nFanouts
Definition: giaCof.c:46
int Cof_NodeDeref_rec(Cof_Obj_t *pNode)
Definition: giaCof.c:564
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
Definition: giaCof.c:88
unsigned nFanins
Definition: giaCof.c:45
int Cof_NodeRef_rec ( Cof_Obj_t pNode)

Definition at line 573 of file giaCof.c.

574 {
575  if ( pNode->nFanins == 0 )
576  return 0;
577  if ( pNode->nFanouts++ > 0 )
578  return 0;
579  return 1 + Cof_NodeRef_rec( Cof_ObjFanin(pNode, 0) )
580  + Cof_NodeRef_rec( Cof_ObjFanin(pNode, 1) );
581 }
unsigned nFanouts
Definition: giaCof.c:46
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
Definition: giaCof.c:88
unsigned nFanins
Definition: giaCof.c:45
int Cof_NodeRef_rec(Cof_Obj_t *pNode)
Definition: giaCof.c:573
static Cof_Obj_t* Cof_ObjFanin ( Cof_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 88 of file giaCof.c.

88 { return (Cof_Obj_t *)(((int *)pObj) - pObj->Fanios[i].iFan); }
Cof_Fan_t Fanios[0]
Definition: giaCof.c:52
static int Cof_ObjFaninNum ( Cof_Obj_t pObj)
inlinestatic

Definition at line 83 of file giaCof.c.

83 { return pObj->nFanins; }
unsigned nFanins
Definition: giaCof.c:45
static Cof_Obj_t* Cof_ObjFanout ( Cof_Obj_t pObj,
int  i 
)
inlinestatic

Definition at line 89 of file giaCof.c.

89 { return (Cof_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i].iFan); }
unsigned nFanins
Definition: giaCof.c:45
Cof_Fan_t Fanios[0]
Definition: giaCof.c:52
static int Cof_ObjFanoutNum ( Cof_Obj_t pObj)
inlinestatic

Definition at line 84 of file giaCof.c.

84 { return pObj->nFanouts; }
unsigned nFanouts
Definition: giaCof.c:46
static unsigned Cof_ObjHandle ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 74 of file giaCof.c.

74 { return (unsigned)(((int *)pObj) - p->pObjData); }
int * pObjData
Definition: giaCof.c:64
static unsigned Cof_ObjHandleDiff ( Cof_Obj_t pObj,
Cof_Obj_t pFanin 
)
inlinestatic

Definition at line 75 of file giaCof.c.

75 { return (unsigned)(((int *)pObj) - ((int *)pFanin)); }
static int Cof_ObjIsCi ( Cof_Obj_t pObj)
inlinestatic

Definition at line 78 of file giaCof.c.

78 { return pObj->fTerm && pObj->nFanins == 0; }
unsigned nFanins
Definition: giaCof.c:45
unsigned fTerm
Definition: giaCof.c:41
static int Cof_ObjIsCo ( Cof_Obj_t pObj)
inlinestatic

Definition at line 79 of file giaCof.c.

79 { return pObj->fTerm && pObj->nFanins == 1; }
unsigned nFanins
Definition: giaCof.c:45
unsigned fTerm
Definition: giaCof.c:41
static int Cof_ObjIsConst0 ( Cof_Obj_t pObj)
inlinestatic

Definition at line 81 of file giaCof.c.

81 { return!pObj->fTerm && pObj->nFanins == 0; }
unsigned nFanins
Definition: giaCof.c:45
unsigned fTerm
Definition: giaCof.c:41
static int Cof_ObjIsNode ( Cof_Obj_t pObj)
inlinestatic

Definition at line 80 of file giaCof.c.

80 { return!pObj->fTerm && pObj->nFanins > 0; }
unsigned nFanins
Definition: giaCof.c:45
unsigned fTerm
Definition: giaCof.c:41
static int Cof_ObjIsTerm ( Cof_Obj_t pObj)
inlinestatic

Definition at line 77 of file giaCof.c.

77 { return pObj->fTerm; }
unsigned fTerm
Definition: giaCof.c:41
static int Cof_ObjIsTravIdCurrent ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 99 of file giaCof.c.

99 { return ((int)pObj->Value == p->nTravIds); }
int nTravIds
Definition: giaCof.c:63
unsigned Value
Definition: giaCof.c:48
static int Cof_ObjIsTravIdPrevious ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 100 of file giaCof.c.

100 { return ((int)pObj->Value == p->nTravIds - 1); }
int nTravIds
Definition: giaCof.c:63
unsigned Value
Definition: giaCof.c:48
static int Cof_ObjLevel ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 72 of file giaCof.c.

72 { return Gia_ObjLevel(p->pGia, Gia_ManObj(p->pGia,pObj->Id)); }
Gia_Man_t * pGia
Definition: giaCof.c:58
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
int Id
Definition: giaCof.c:49
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:501
static int Cof_ObjMffcSize ( Cof_Obj_t pNode)
inlinestatic

Definition at line 582 of file giaCof.c.

583 {
584  int Count1, Count2, nFanout;
585  nFanout = pNode->nFanouts;
586  pNode->nFanouts = 1;
587  Count1 = Cof_NodeDeref_rec( pNode );
588  Count2 = Cof_NodeRef_rec( pNode );
589  pNode->nFanouts = nFanout;
590  assert( Count1 == Count2 );
591  return Count1;
592 }
unsigned nFanouts
Definition: giaCof.c:46
int Cof_NodeDeref_rec(Cof_Obj_t *pNode)
Definition: giaCof.c:564
#define assert(ex)
Definition: util_old.h:213
int Cof_NodeRef_rec(Cof_Obj_t *pNode)
Definition: giaCof.c:573
static void Cof_ObjSetTravId ( Cof_Obj_t pObj,
int  TravId 
)
inlinestatic

Definition at line 96 of file giaCof.c.

96 { pObj->Value = TravId; }
unsigned Value
Definition: giaCof.c:48
static void Cof_ObjSetTravIdCurrent ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 97 of file giaCof.c.

97 { pObj->Value = p->nTravIds; }
int nTravIds
Definition: giaCof.c:63
unsigned Value
Definition: giaCof.c:48
static void Cof_ObjSetTravIdPrevious ( Cof_Man_t p,
Cof_Obj_t pObj 
)
inlinestatic

Definition at line 98 of file giaCof.c.

98 { pObj->Value = p->nTravIds - 1; }
int nTravIds
Definition: giaCof.c:63
unsigned Value
Definition: giaCof.c:48
static int Cof_ObjSize ( Cof_Obj_t pObj)
inlinestatic

Definition at line 85 of file giaCof.c.

85 { return sizeof(Cof_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; }
unsigned nFanouts
Definition: giaCof.c:46
struct Cof_Obj_t_ Cof_Obj_t
Definition: giaCof.c:38
unsigned nFanins
Definition: giaCof.c:45
Vec_Int_t* Gia_ManCofVars ( Gia_Man_t p,
int  nFanLim 
)

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

Synopsis [Determines variables whose fanout count is higher than this.]

Description [Variables are returned in a reverse topological order.]

SideEffects []

SeeAlso []

Definition at line 883 of file giaCof.c.

884 {
885  Vec_Int_t * vVars;
886  Gia_Obj_t * pObj;
887  int i;
888  ABC_FREE( p->pRefs );
889  Gia_ManCreateRefs( p );
890  vVars = Vec_IntAlloc( 100 );
891  Gia_ManForEachObj( p, pObj, i )
892  if ( Gia_ObjIsCand(pObj) && Gia_ObjRefNum(p, pObj) >= nFanLim )
893  Vec_IntPush( vVars, i );
894  ABC_FREE( p->pRefs );
895  return vVars;
896 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:521
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
Gia_Man_t* Gia_ManDupCof ( Gia_Man_t p,
int  iVar 
)

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

Synopsis [Duplicates AIG in the DFS order while putting CIs first.]

Description []

SideEffects []

SeeAlso []

Definition at line 862 of file giaCof.c.

863 {
864  Gia_Man_t * pNew, * pTemp;
865  pNew = Gia_ManDupCofInt( p, iVar );
866  pNew = Gia_ManCleanup( pTemp = pNew );
867  Gia_ManStop( pTemp );
868  return pNew;
869 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Definition: gia.h:95
Gia_Man_t * Gia_ManDupCofInt(Gia_Man_t *p, int iVar)
Definition: giaCof.c:780
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Gia_Man_t* Gia_ManDupCofAll ( Gia_Man_t p,
int  nFanLim,
int  fVerbose 
)

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

Synopsis [Cofactors all variables whose fanout is higher than this.]

Description []

SideEffects []

SeeAlso []

Definition at line 987 of file giaCof.c.

988 {
989  Gia_Man_t * pNew;
990  Vec_Int_t * vSigs = Gia_ManCofVars( p, nFanLim );
991  pNew = Gia_ManDupCofAllInt( p, vSigs, fVerbose );
992  Vec_IntFree( vSigs );
993  return pNew;
994 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * Gia_ManDupCofAllInt(Gia_Man_t *p, Vec_Int_t *vSigs, int fVerbose)
Definition: giaCof.c:936
Vec_Int_t * Gia_ManCofVars(Gia_Man_t *p, int nFanLim)
Definition: giaCof.c:883
Definition: gia.h:95
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t* Gia_ManDupCofAllInt ( Gia_Man_t p,
Vec_Int_t vSigs,
int  fVerbose 
)

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

Synopsis [Cofactors selected variables (should be in reverse topo order).]

Description []

SideEffects []

SeeAlso []

Definition at line 936 of file giaCof.c.

937 {
938  Vec_Int_t * vSigsNew, * vTemp;
939  Gia_Man_t * pAig, * pCof, * pNew;
940  int iVar;
941  if ( fVerbose )
942  {
943  printf( "Cofactoring %d signals.\n", Vec_IntSize(vSigs) );
944  Gia_ManPrintStats( p, NULL );
945  }
946  if ( Vec_IntSize( vSigs ) > 200 )
947  {
948  printf( "Too many signals to cofactor.\n" );
949  return NULL;
950  }
951  pAig = Gia_ManDup( p );
952  vSigsNew = Vec_IntDup( vSigs );
953  while ( Vec_IntSize(vSigsNew) > 0 )
954  {
955  Vec_IntSort( vSigsNew, 0 );
956  iVar = Vec_IntPop( vSigsNew );
957 // Gia_ManCreateRefs( pAig );
958 // printf( "ref count = %d\n", Gia_ObjRefNum( pAig, Gia_ManObj(pAig, iVar) ) );
959 // ABC_FREE( pAig->pRefs );
960  pCof = Gia_ManDupCofInt( pAig, iVar );
961  pNew = Gia_ManCleanup( pCof );
962  vSigsNew = Gia_ManTransfer( pAig, pCof, pNew, vTemp = vSigsNew );
963  Vec_IntFree( vTemp );
964  Gia_ManStop( pAig );
965  Gia_ManStop( pCof );
966  pAig = pNew;
967  if ( fVerbose )
968  printf( "Cofactored variable %d.\n", iVar );
969  if ( fVerbose )
970  Gia_ManPrintStats( pAig, NULL );
971  }
972  Vec_IntFree( vSigsNew );
973  return pAig;
974 }
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
Definition: vecInt.h:1293
static int Vec_IntPop(Vec_Int_t *p)
Vec_Int_t * Gia_ManTransfer(Gia_Man_t *pAig, Gia_Man_t *pCof, Gia_Man_t *pNew, Vec_Int_t *vSigs)
Definition: giaCof.c:909
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
Gia_Man_t * Gia_ManDupCofInt(Gia_Man_t *p, int iVar)
Definition: giaCof.c:780
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
Gia_Man_t* Gia_ManDupCofInt ( Gia_Man_t p,
int  iVar 
)

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

Synopsis [Duplicates AIG in the DFS order while putting CIs first.]

Description []

SideEffects []

SeeAlso []

Definition at line 780 of file giaCof.c.

781 {
782  Gia_Man_t * pNew;
783  Gia_Obj_t * pObj, * pPivot;
784  int i, iCofVar = -1;
785  if ( !(iVar > 0 && iVar < Gia_ManObjNum(p)) )
786  {
787  printf( "Gia_ManDupCof(): Variable %d is out of range (%d; %d).\n", iVar, 0, Gia_ManObjNum(p) );
788  return NULL;
789  }
790  // find the cofactoring variable
791  pPivot = Gia_ManObj( p, iVar );
792  if ( !Gia_ObjIsCand(pPivot) )
793  {
794  printf( "Gia_ManDupCof(): Variable %d should be a CI or an AND node.\n", iVar );
795  return NULL;
796  }
797  pNew = Gia_ManStart( Gia_ManObjNum(p) );
798  pNew->pName = Abc_UtilStrsav( p->pName );
799  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
800  Gia_ManHashAlloc( pNew );
801  Gia_ManFillValue( p );
802  Gia_ManConst0(p)->Value = 0;
803  // compute negative cofactor
804  Gia_ManForEachCi( p, pObj, i )
805  {
806  pObj->Value = Gia_ManAppendCi(pNew);
807  if ( pObj == pPivot )
808  {
809  iCofVar = pObj->Value;
810  pObj->Value = Abc_Var2Lit( 0, 0 );
811  }
812  }
813  Gia_ManForEachAnd( p, pObj, i )
814  {
815  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
816  if ( pObj == pPivot )
817  {
818  iCofVar = pObj->Value;
819  pObj->Value = Abc_Var2Lit( 0, 0 );
820  }
821  }
822  Gia_ManForEachCo( p, pObj, i )
823  pObj->Value = Gia_ObjFanin0Copy(pObj);
824  // compute the positive cofactor
825  Gia_ManForEachCi( p, pObj, i )
826  {
827  pObj->Value = Abc_Var2Lit( Gia_ObjId(pNew, Gia_ManCi(pNew, i)), 0 );
828  if ( pObj == pPivot )
829  pObj->Value = Abc_Var2Lit( 0, 1 );
830  }
831  Gia_ManForEachAnd( p, pObj, i )
832  {
833  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
834  if ( pObj == pPivot )
835  pObj->Value = Abc_Var2Lit( 0, 1 );
836  }
837  // create MUXes
838  assert( iCofVar > 0 );
839  Gia_ManForEachCo( p, pObj, i )
840  {
841  if ( pObj->Value == (unsigned)Gia_ObjFanin0Copy(pObj) )
842  pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
843  else
844  pObj->Value = Gia_ManAppendCo( pNew, Gia_ManHashMux(pNew, iCofVar, Gia_ObjFanin0Copy(pObj), pObj->Value) );
845  }
846  Gia_ManHashStop( pNew );
847  Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
848  return pNew;
849 }
#define Gia_ManForEachCo(p, pObj, i)
Definition: gia.h:1022
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition: giaMan.c:628
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
char * pName
Definition: gia.h:97
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition: giaHash.c:677
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition: giaHash.c:99
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
void Gia_ManPrintFanio ( Gia_Man_t pGia,
int  nNodes 
)

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

Synopsis [Returns sorted array of node handles with largest fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 746 of file giaCof.c.

747 {
748  Cof_Man_t * p;
749  abctime clk = Abc_Clock();
750  p = Cof_ManCreateLogicSimple( pGia );
751  p->nLevels = 1 + Gia_ManLevelNum( pGia );
752  p->pLevels = ABC_CALLOC( int, p->nLevels );
753  Cof_ManPrintFanio( p );
754 
755  if ( nNodes > 0 )
756  {
757  Cof_ManResetTravId( p );
758  Gia_ManHashStart( pGia );
759  Cof_ManPrintHighFanout( p, nNodes );
760  Gia_ManHashStop( pGia );
761 ABC_PRMn( "Memory for logic network", 4*p->nObjData );
762 ABC_PRT( "Time", Abc_Clock() - clk );
763  }
764 
765  Cof_ManStop( p );
766 }
#define ABC_PRMn(a, f)
Definition: abc_global.h:226
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nLevels
Definition: giaCof.c:67
void Cof_ManStop(Cof_Man_t *p)
Definition: giaCof.c:203
void Cof_ManPrintFanio(Cof_Man_t *p)
Definition: giaCof.c:605
void Cof_ManPrintHighFanout(Cof_Man_t *p, int nNodes)
Definition: giaCof.c:541
static abctime Abc_Clock()
Definition: abc_global.h:279
int nObjData
Definition: giaCof.c:65
static void Cof_ManResetTravId(Cof_Man_t *p)
Definition: giaCof.c:94
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
Cof_Man_t * Cof_ManCreateLogicSimple(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
Definition: giaCof.c:126
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int Gia_ManLevelNum(Gia_Man_t *p)
Definition: giaUtil.c:505
int * pLevels
Definition: giaCof.c:66
ABC_INT64_T abctime
Definition: abc_global.h:278
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Vec_Int_t* Gia_ManTransfer ( Gia_Man_t pAig,
Gia_Man_t pCof,
Gia_Man_t pNew,
Vec_Int_t vSigs 
)

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

Synopsis [Transfers attributes from the original one to the final one.]

Description []

SideEffects []

SeeAlso []

Definition at line 909 of file giaCof.c.

910 {
911  Vec_Int_t * vSigsNew;
912  Gia_Obj_t * pObj, * pObjF;
913  int i;
914  vSigsNew = Vec_IntAlloc( 100 );
915  Gia_ManForEachObjVec( vSigs, pAig, pObj, i )
916  {
917  assert( Gia_ObjIsCand(pObj) );
918  pObjF = Gia_ManObj( pCof, Abc_Lit2Var(pObj->Value) );
919  if ( pObjF->Value && ~pObjF->Value )
920  Vec_IntPushUnique( vSigsNew, Abc_Lit2Var(pObjF->Value) );
921  }
922  return vSigsNew;
923 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static unsigned Gia_ObjHandle ( Gia_Obj_t pObj)
inlinestatic

Definition at line 70 of file giaCof.c.

70 { return pObj->Value; }
unsigned Value
Definition: gia.h:87