102 #define Cof_ManForEachObj( p, pObj, i ) \
103 for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) )
104 #define Cof_ManForEachNode( p, pObj, i ) \
105 for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) if ( Cof_ObjIsTerm(pObj) ) {} else
106 #define Cof_ObjForEachFanin( pObj, pNext, i ) \
107 for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Cof_ObjFanin(pObj,i)); i++ )
108 #define Cof_ObjForEachFanout( pObj, pNext, i ) \
109 for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Cof_ObjFanout(pObj,i)); i++ )
143 pObj->
Value = iHandle;
254 for ( i = 0; i < nObjs; i++ )
300 for ( i = 0; i < nObjs; i++ )
349 for ( i = 0; i < nObjs; i++ )
448 Cof_Obj_t * pTemp, * pNext, * pFanin0, * pFanin1;
449 int Counter = 0, LevelStart, LevelNext;
450 int i, k, iHandle, iLit0, iLit1, iNextNew;
462 for ( i = LevelStart; i < p->
nLevels; i++ )
466 iHandle = pTemp->
iNext )
477 assert( pFanin0 == pTemp || pFanin1 == pTemp );
488 if ( iNextNew == -1 )
492 pNext->
iLit = iNextNew;
495 assert( LevelNext > i && LevelNext < p->nLevels );
519 printf(
"%7d : ", pObj->
Id );
584 int Count1, Count2, nFanout;
590 assert( Count1 == Count2 );
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;
614 nFaninsMax = nFanoutsMax = nMffcsMax = 0;
615 nFaninsAll = nFanoutsAll = nMffcsAll = 0;
618 if ( i == 0 )
continue;
622 nFaninsAll += nFanins;
623 nFanoutsAll += nFanouts;
625 nFaninsMax =
Abc_MaxInt( nFaninsMax, nFanins );
626 nFanoutsMax =
Abc_MaxInt( nFanoutsMax, nFanouts );
640 if ( i == 0 )
continue;
647 else if ( nFanins < 100 )
649 else if ( nFanins < 1000 )
651 else if ( nFanins < 10000 )
653 else if ( nFanins < 100000 )
655 else if ( nFanins < 1000000 )
657 else if ( nFanins < 10000000 )
662 else if ( nFanouts < 100 )
664 else if ( nFanouts < 1000 )
666 else if ( nFanouts < 10000 )
668 else if ( nFanouts < 100000 )
670 else if ( nFanouts < 1000000 )
672 else if ( nFanouts < 10000000 )
681 else if ( nMffcs < 100 )
683 else if ( nMffcs < 1000 )
685 else if ( nMffcs < 10000 )
687 else if ( nMffcs < 100000 )
689 else if ( nMffcs < 1000000 )
691 else if ( nMffcs < 10000000 )
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" );
698 for ( k = 0; k < nSizeMax; k++ )
700 if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 && vMffcs->pArray[k] == 0 )
703 printf(
"%15d : ", k );
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 );
709 if ( vFanins->pArray[k] == 0 )
712 printf(
"%11d ", vFanins->pArray[k] );
714 if ( vFanouts->pArray[k] == 0 )
717 printf(
"%12d ", vFanouts->pArray[k] );
719 if ( vMffcs->pArray[k] == 0 )
722 printf(
" %12d ", vMffcs->pArray[k] );
729 printf(
"Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f. MFFCs: Max = %d. Ave = %.2f.\n",
732 nMffcsMax, 1.0*nMffcsAll /nMffcNodes );
787 printf(
"Gia_ManDupCof(): Variable %d is out of range (%d; %d).\n", iVar, 0,
Gia_ManObjNum(p) );
794 printf(
"Gia_ManDupCof(): Variable %d should be a CI or an AND node.\n", iVar );
807 if ( pObj == pPivot )
809 iCofVar = pObj->
Value;
816 if ( pObj == pPivot )
818 iCofVar = pObj->
Value;
828 if ( pObj == pPivot )
834 if ( pObj == pPivot )
943 printf(
"Cofactoring %d signals.\n",
Vec_IntSize(vSigs) );
948 printf(
"Too many signals to cofactor.\n" );
968 printf(
"Cofactored variable %d.\n", iVar );
void Gia_ManCreateRefs(Gia_Man_t *p)
static int Cof_ObjIsCi(Cof_Obj_t *pObj)
static int Gia_ObjFaninLit0(Gia_Obj_t *pObj, int ObjId)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int Cof_ObjIsCo(Cof_Obj_t *pObj)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
int Cof_NodeDeref_rec(Cof_Obj_t *pNode)
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static Cof_Obj_t * Cof_ObjFanin(Cof_Obj_t *pObj, int i)
void Cof_ManInsertEntry_rec(Vec_Ptr_t *vNodes, Cof_Obj_t *pNode, int nNodeMax)
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
int Cof_ManTfiSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
int Cof_ManTfoSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
static int Gia_ManAppendCi(Gia_Man_t *p)
void Cof_ManStop(Cof_Man_t *p)
static int Cof_ObjIsTerm(Cof_Obj_t *pObj)
static int Abc_Var2Lit(int Var, int fCompl)
void Cof_ManPrintFanio(Cof_Man_t *p)
struct Cof_Obj_t_ Cof_Obj_t
static void Cof_ManIncrementTravId(Cof_Man_t *p)
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Gia_Man_t * Gia_ManDupCofAllInt(Gia_Man_t *p, Vec_Int_t *vSigs, int fVerbose)
void Cof_ManPrintHighFanout(Cof_Man_t *p, int nNodes)
static int Cof_ObjFanoutNum(Cof_Obj_t *pObj)
int Gia_ManHashAndTry(Gia_Man_t *p, int iLit0, int iLit1)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void * Vec_PtrPop(Vec_Ptr_t *p)
void Cof_ManPrintHighFanoutOne(Cof_Man_t *p, Cof_Obj_t *pObj)
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static int Abc_LitNotCond(int Lit, int c)
static int Cof_ObjFaninNum(Cof_Obj_t *pObj)
#define Gia_ManForEachCi(p, pObj, i)
int * Gia_ManCreateMuxRefs(Gia_Man_t *p)
static void Cof_ObjSetTravId(Cof_Obj_t *pObj, int TravId)
int Cof_ManSuppSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
static unsigned Cof_ObjHandleDiff(Cof_Obj_t *pObj, Cof_Obj_t *pFanin)
static int Gia_ManAndNum(Gia_Man_t *p)
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Cof_ObjIsTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
static Vec_Int_t * Vec_IntStart(int nSize)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Vec_Int_t * Gia_ManCofVars(Gia_Man_t *p, int nFanLim)
static int Gia_ObjFaninLit1(Gia_Obj_t *pObj, int ObjId)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Cof_ManCleanValue(Cof_Man_t *p)
static int Cof_ObjIsNode(Cof_Obj_t *pObj)
static int Cof_ObjMffcSize(Cof_Obj_t *pNode)
Gia_Man_t * Gia_ManDupCof(Gia_Man_t *p, int iVar)
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
int Cof_ManCountRemoved(Cof_Man_t *p, Cof_Obj_t *pRoot, int fConst1)
static Cof_Obj_t * Cof_ObjFanout(Cof_Obj_t *pObj, int i)
Vec_Ptr_t * Cof_ManCollectHighFanout(Cof_Man_t *p, int nNodes)
void Gia_ManPrintFanio(Gia_Man_t *pGia, int nNodes)
static void Cof_ManResetTravId(Cof_Man_t *p)
static unsigned Cof_ObjHandle(Cof_Man_t *p, Cof_Obj_t *pObj)
Gia_Man_t * Gia_ManDupCofAll(Gia_Man_t *p, int nFanLim, int fVerbose)
static int Abc_Base10Log(unsigned n)
#define ABC_NAMESPACE_IMPL_END
static int Cof_ObjIsConst0(Cof_Obj_t *pObj)
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
void Gia_ManHashStart(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
#define Gia_ManForEachAnd(p, pObj, i)
static void Cof_ObjSetTravIdCurrent(Cof_Man_t *p, Cof_Obj_t *pObj)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Cof_Man_t * Cof_ManCreateLogicSimple(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
void Gia_ManFillValue(Gia_Man_t *p)
#define Cof_ObjForEachFanout(pObj, pNext, i)
typedefABC_NAMESPACE_IMPL_START struct Cof_Fan_t_ Cof_Fan_t
DECLARATIONS ///.
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
Vec_Int_t * Gia_ManTransfer(Gia_Man_t *pAig, Gia_Man_t *pCof, Gia_Man_t *pNew, Vec_Int_t *vSigs)
static void Cof_ObjSetTravIdPrevious(Cof_Man_t *p, Cof_Obj_t *pObj)
static int Gia_ManCiNum(Gia_Man_t *p)
int Cof_ManTfoSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
static int Vec_IntSize(Vec_Int_t *p)
static int Cof_ManNodeNum(Cof_Man_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Cof_ObjIsTravIdPrevious(Cof_Man_t *p, Cof_Obj_t *pObj)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
int Cof_ManTfiSize_rec(Cof_Man_t *p, Cof_Obj_t *pObj)
static int Abc_Lit2Var(int Lit)
#define ABC_CALLOC(type, num)
static unsigned Gia_ObjHandle(Gia_Obj_t *pObj)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
static int Cof_ManObjNum(Cof_Man_t *p)
#define Cof_ManForEachObj(p, pObj, i)
#define Cof_ObjForEachFanin(pObj, pNext, i)
static int Cof_ObjLevel(Cof_Man_t *p, Cof_Obj_t *pObj)
static int Cof_ObjSize(Cof_Obj_t *pObj)
int Gia_ManLevelNum(Gia_Man_t *p)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManDupCofInt(Gia_Man_t *p, int iVar)
int Cof_ManSuppSize(Cof_Man_t *p, Cof_Obj_t **ppObjs, int nObjs)
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Cof_NodeRef_rec(Cof_Obj_t *pNode)
char * Abc_UtilStrsav(char *s)
#define Cof_ManForEachNode(p, pObj, i)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
static int Gia_ManObjNum(Gia_Man_t *p)
static Cof_Obj_t * Cof_ManObj(Cof_Man_t *p, unsigned iHandle)
static void Vec_PtrFree(Vec_Ptr_t *p)
void Gia_ManHashStop(Gia_Man_t *p)
static int Gia_ManCoNum(Gia_Man_t *p)
static int Gia_ManRegNum(Gia_Man_t *p)