summaryrefslogtreecommitdiffstats
path: root/src/aig
diff options
context:
space:
mode:
Diffstat (limited to 'src/aig')
-rw-r--r--src/aig/aig/aig.h1
-rw-r--r--src/aig/aig/aigRepr.c22
-rw-r--r--src/aig/hop/hop.h10
-rw-r--r--src/aig/mfx/mfxCore.c1
-rw-r--r--src/aig/ntl/ntlExtract.c10
-rw-r--r--src/aig/ntl/ntlFraig.c6
-rw-r--r--src/aig/ntl/ntlWriteBlif.c8
-rw-r--r--src/aig/nwk/nwk.h3
-rw-r--r--src/aig/nwk/nwkCheck.c28
-rw-r--r--src/aig/nwk/nwkFanio.c8
-rw-r--r--src/aig/nwk/nwkMap.c22
-rw-r--r--src/aig/nwk/nwkObj.c6
-rw-r--r--src/aig/nwk/nwkTiming.c2
-rw-r--r--src/aig/nwk/nwkUtil.c109
14 files changed, 212 insertions, 24 deletions
diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h
index 88d7aa50..9d6bde98 100644
--- a/src/aig/aig/aig.h
+++ b/src/aig/aig/aig.h
@@ -548,6 +548,7 @@ extern void Aig_ManReprStop( Aig_Man_t * p );
extern void Aig_ObjCreateRepr( Aig_Man_t * p, Aig_Obj_t * pNode1, Aig_Obj_t * pNode2 );
extern void Aig_ManTransferRepr( Aig_Man_t * pNew, Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupRepr( Aig_Man_t * p, int fOrdered );
+extern int Aig_ManCountReprs( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManRehash( Aig_Man_t * p );
extern int Aig_ObjCheckTfi( Aig_Man_t * p, Aig_Obj_t * pNew, Aig_Obj_t * pOld );
extern void Aig_ManMarkValidChoices( Aig_Man_t * p );
diff --git a/src/aig/aig/aigRepr.c b/src/aig/aig/aigRepr.c
index 94a1c844..88cdbf17 100644
--- a/src/aig/aig/aigRepr.c
+++ b/src/aig/aig/aigRepr.c
@@ -329,6 +329,28 @@ int Aig_ManRemapRepr( Aig_Man_t * p )
/**Function*************************************************************
+ Synopsis [Transfer representatives and return the number of critical fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Aig_ManCountReprs( Aig_Man_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+ if ( p->pReprs == NULL )
+ return 0;
+ Aig_ManForEachObj( p, pObj, i )
+ Counter += (p->pReprs[i] != NULL);
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns 1 if pOld is in the TFI of pNew.]
Description []
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h
index d7f525a2..12374a49 100644
--- a/src/aig/hop/hop.h
+++ b/src/aig/hop/hop.h
@@ -166,11 +166,11 @@ static inline int Hop_ObjIsMarkA( Hop_Obj_t * pObj ) { return pObj-
static inline void Hop_ObjSetMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 1; }
static inline void Hop_ObjClearMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 0; }
-static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)TravId; }
-static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)p->nTravIds; }
-static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(p->nTravIds - 1); }
-static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds); }
-static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int )((int)pObj->pData == p->nTravIds - 1); }
+static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)(long)TravId; }
+static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(long)p->nTravIds; }
+static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(long)(p->nTravIds - 1); }
+static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(long)pObj->pData == p->nTravIds); }
+static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(long)pObj->pData == p->nTravIds - 1); }
static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)pObj->pData; }
static inline int Hop_ObjPhase( Hop_Obj_t * pObj ) { return pObj->fPhase; }
diff --git a/src/aig/mfx/mfxCore.c b/src/aig/mfx/mfxCore.c
index bea7c6b0..8867f7c1 100644
--- a/src/aig/mfx/mfxCore.c
+++ b/src/aig/mfx/mfxCore.c
@@ -206,6 +206,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib )
int nTotalNodesBeg = Nwk_ManNodeNum(pNtk);
int nTotalEdgesBeg = Nwk_ManGetTotalFanins(pNtk);
+// assert( Nwk_ManCheck( pNtk ) );
// check limits on the number of fanins
nFaninMax = Nwk_ManGetFaninMax(pNtk);
if ( pPars->fResub )
diff --git a/src/aig/ntl/ntlExtract.c b/src/aig/ntl/ntlExtract.c
index 9c3666ab..b3d099c9 100644
--- a/src/aig/ntl/ntlExtract.c
+++ b/src/aig/ntl/ntlExtract.c
@@ -364,7 +364,7 @@ Aig_Obj_t * Ntl_GraphToNetworkAig( Aig_Man_t * pMan, Dec_Graph_t * pGraph )
Aig_Obj_t * Ntl_ManBuildNodeAig( Ntl_Obj_t * pNode )
{
Aig_Man_t * pMan = pNode->pModel->pMan->pAig;
- int fUseFactor = 0;
+ int fUseFactor = 1;
// consider the constant node
if ( Ntl_SopGetVarNum(pNode->pSop) == 0 )
return Aig_NotCond( Aig_ManConst1(pMan), Ntl_SopIsConst0(pNode->pSop) );
@@ -957,8 +957,8 @@ Aig_Man_t * Ntl_ManCollapseForSec( Ntl_Man_t * p1, Ntl_Man_t * p2 )
***********************************************************************/
static inline void Ntl_NetIncrementRefs( Ntl_Net_t * pNet )
{
- int nRefs = (int)pNet->pCopy;
- pNet->pCopy = (void *)(nRefs + 1);
+ int nRefs = (int)(long)pNet->pCopy;
+ pNet->pCopy = (void *)(long)(nRefs + 1);
}
/**Function*************************************************************
@@ -981,7 +981,7 @@ Nwk_Obj_t * Ntl_ManExtractNwk_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, Nwk_Man_t *
if ( pNet->fMark )
return pNet->pCopy;
pNet->fMark = 1;
- pNode = Nwk_ManCreateNode( pNtk, Ntl_ObjFaninNum(pNet->pDriver), (int)pNet->pCopy );
+ pNode = Nwk_ManCreateNode( pNtk, Ntl_ObjFaninNum(pNet->pDriver), (int)(long)pNet->pCopy );
Ntl_ObjForEachFanin( pNet->pDriver, pFaninNet, i )
{
Ntl_ManExtractNwk_rec( p, pFaninNet, pNtk, vCover, vMemory );
@@ -1046,7 +1046,7 @@ Nwk_Man_t * Ntl_ManExtractNwk( Ntl_Man_t * p, Aig_Man_t * pAig )
pObj = Ntl_ModelPi( pRoot, Aig_ObjPioNum(pAnd) );
pNet = Ntl_ObjFanout0(pObj);
pNet->fMark = 1;
- pNet->pCopy = Nwk_ManCreateCi( pNtk, (int)pNet->pCopy );
+ pNet->pCopy = Nwk_ManCreateCi( pNtk, (int)(long)pNet->pCopy );
}
else if ( Aig_ObjIsPo(pAnd) )
{
diff --git a/src/aig/ntl/ntlFraig.c b/src/aig/ntl/ntlFraig.c
index 8a172e6c..98f14d3d 100644
--- a/src/aig/ntl/ntlFraig.c
+++ b/src/aig/ntl/ntlFraig.c
@@ -192,6 +192,8 @@ Aig_Man_t * Ntl_ManScl( Ntl_Man_t * p, Aig_Man_t * pAig, int fLatchConst, int fL
// derive the new AIG
pTemp = Aig_ManDupRepresDfs( pAig );
+printf( "Intermediate:\n" );
+Aig_ManPrintStats( pTemp );
// duplicate the timing manager
if ( pAig->pManTime )
pTemp->pManTime = Tim_ManDup( pAig->pManTime, 0 );
@@ -230,17 +232,21 @@ Aig_Man_t * Ntl_ManLcorr( Ntl_Man_t * p, Aig_Man_t * pAig, int nConfMax, int fVe
// perform fraiging for the given design
pAigCol->nRegs = Ntl_ModelLatchNum(Ntl_ManRootModel(p));
pTemp = Fra_FraigLatchCorrespondence( pAigCol, 0, nConfMax, 0, fVerbose, NULL );
+//printf( "Reprs = %d.\n", Aig_ManCountReprs(pAigCol) );
Aig_ManStop( pTemp );
// transfer equivalence classes to the original AIG
pAig->pReprs = Ntl_ManFraigDeriveClasses( pAig, pNew, pAigCol );
pAig->nReprsAlloc = Aig_ManObjNumMax(pAig);
+//printf( "Reprs = %d.\n", Aig_ManCountReprs(pAig) );
// cleanup
Aig_ManStop( pAigCol );
Ntl_ManFree( pNew );
// derive the new AIG
pTemp = Aig_ManDupRepresDfs( pAig );
+//printf( "Intermediate LCORR:\n" );
+//Aig_ManPrintStats( pTemp );
// duplicate the timing manager
if ( pAig->pManTime )
pTemp->pManTime = Tim_ManDup( pAig->pManTime, 0 );
diff --git a/src/aig/ntl/ntlWriteBlif.c b/src/aig/ntl/ntlWriteBlif.c
index fddd4167..cefa38d3 100644
--- a/src/aig/ntl/ntlWriteBlif.c
+++ b/src/aig/ntl/ntlWriteBlif.c
@@ -45,7 +45,7 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel )
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet;
float Delay;
- int i, k;
+ int i, k, fClockAdded = 0;
fprintf( pFile, ".model %s\n", pModel->pName );
fprintf( pFile, ".inputs" );
Ntl_ModelForEachPi( pModel, pObj, i )
@@ -117,8 +117,10 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel )
fprintf( pFile, " %s", Ntl_ObjFanout0(pObj)->pName );
if ( pObj->LatchId >> 2 )
fprintf( pFile, " %d", pObj->LatchId >> 2 );
- if ( pObj->pFanio[1] != NULL )
+ if ( Ntl_ObjFanin(pObj, 1) != NULL )
fprintf( pFile, " %s", Ntl_ObjFanin(pObj, 1)->pName );
+ else if ( pObj->LatchId >> 2 )
+ fprintf( pFile, " clock" ), fClockAdded = 1;
fprintf( pFile, " %d", pObj->LatchId & 3 );
fprintf( pFile, "\n" );
}
@@ -132,6 +134,8 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel )
fprintf( pFile, "\n" );
}
}
+ if ( fClockAdded )
+ fprintf( pFile, ".names clock\n 0\n" );
fprintf( pFile, ".end\n\n" );
}
diff --git a/src/aig/nwk/nwk.h b/src/aig/nwk/nwk.h
index 4c99c3a9..6fc84893 100644
--- a/src/aig/nwk/nwk.h
+++ b/src/aig/nwk/nwk.h
@@ -195,6 +195,8 @@ static inline int Nwk_ManTimeMore( float f1, float f2, float Eps ) { r
/*=== nwkBidec.c ==========================================================*/
extern void Nwk_ManBidecResyn( Nwk_Man_t * pNtk, int fVerbose );
extern Hop_Obj_t * Nwk_NodeIfNodeResyn( Bdc_Man_t * p, Hop_Man_t * pHop, Hop_Obj_t * pRoot, int nVars, Vec_Int_t * vTruth, unsigned * puCare );
+/*=== nwkCheck.c ==========================================================*/
+extern int Nwk_ManCheck( Nwk_Man_t * p );
/*=== nwkDfs.c ==========================================================*/
extern int Nwk_ManVerifyTopoOrder( Nwk_Man_t * pNtk );
extern int Nwk_ManLevelBackup( Nwk_Man_t * pNtk );
@@ -253,6 +255,7 @@ extern int Nwk_NodeCompareLevelsIncrease( Nwk_Obj_t ** pp1, Nwk_Obj_
extern int Nwk_NodeCompareLevelsDecrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 );
extern void Nwk_ObjPrint( Nwk_Obj_t * pObj );
extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vCiNames, Vec_Ptr_t * vCoNames );
+extern void Nwk_ManPrintFanioNew( Nwk_Man_t * pNtk );
#ifdef __cplusplus
}
diff --git a/src/aig/nwk/nwkCheck.c b/src/aig/nwk/nwkCheck.c
index 5c547dbe..6922e439 100644
--- a/src/aig/nwk/nwkCheck.c
+++ b/src/aig/nwk/nwkCheck.c
@@ -30,7 +30,7 @@
/**Function*************************************************************
- Synopsis []
+ Synopsis [Checking the logic network for consistency.]
Description []
@@ -39,6 +39,32 @@
SeeAlso []
***********************************************************************/
+int Nwk_ManCheck( Nwk_Man_t * p )
+{
+ Nwk_Obj_t * pObj;
+ int i, k, m;
+ // check if the nodes have duplicated fanins
+ Nwk_ManForEachNode( p, pObj, i )
+ {
+ for ( k = 0; k < pObj->nFanins; k++ )
+ for ( m = k + 1; m < pObj->nFanins; m++ )
+ if ( pObj->pFanio[k] == pObj->pFanio[m] )
+ printf( "Node %d has duplicated fanin %d.\n", pObj->Id, pObj->pFanio[k]->Id );
+ }
+/*
+ // check if all nodes are in the correct fanin/fanout relationship
+ Nwk_ManForEachObj( p, pObj, i )
+ {
+ Nwk_ObjForEachFanin( pObj, pNext, k )
+ if ( Nwk_ObjFindFanout( pNext, pObj ) == -1 )
+ printf( "Nwk_ManCheck(): Object %d has fanin %d which does not have a corresponding fanout.\n", pObj->Id, pNext->Id );
+ Nwk_ObjForEachFanout( pObj, pNext, k )
+ if ( Nwk_ObjFindFanin( pNext, pObj ) == -1 )
+ printf( "Nwk_ManCheck(): Object %d has fanout %d which does not have a corresponding fanin.\n", pObj->Id, pNext->Id );
+ }
+*/
+ return 1;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
diff --git a/src/aig/nwk/nwkFanio.c b/src/aig/nwk/nwkFanio.c
index f338d07d..1b701e9e 100644
--- a/src/aig/nwk/nwkFanio.c
+++ b/src/aig/nwk/nwkFanio.c
@@ -221,7 +221,7 @@ void Nwk_ObjAddFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
Nwk_ManReallocNode( pObj );
if ( Nwk_ObjReallocIsNeeded(pFanin) )
Nwk_ManReallocNode( pFanin );
- for ( i = pObj->nFanins + pObj->nFanouts; i > (int)pObj->nFanins; i-- )
+ for ( i = pObj->nFanins + pObj->nFanouts; i > pObj->nFanins; i-- )
pObj->pFanio[i] = pObj->pFanio[i-1];
pObj->pFanio[pObj->nFanins++] = pFanin;
pFanin->pFanio[pFanin->nFanins + pFanin->nFanouts++] = pObj;
@@ -247,15 +247,15 @@ void Nwk_ObjDeleteFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
for ( k = i = 0; i < Limit; i++ )
if ( pObj->pFanio[i] != pFanin )
pObj->pFanio[k++] = pObj->pFanio[i];
- assert( i == k + 1 );
+ assert( i == k + 1 ); // if it fails, likely because of duplicated fanin
pObj->nFanins--;
// remove pObj from the fanout list of pFanin
Limit = pFanin->nFanins + pFanin->nFanouts;
for ( k = i = pFanin->nFanins; i < Limit; i++ )
if ( pFanin->pFanio[i] != pObj )
pFanin->pFanio[k++] = pFanin->pFanio[i];
- assert( i == k + 1 );
- pFanin->nFanouts--;
+ assert( i == k + 1 ); // if it fails, likely because of duplicated fanout
+ pFanin->nFanouts--;
}
/**Function*************************************************************
diff --git a/src/aig/nwk/nwkMap.c b/src/aig/nwk/nwkMap.c
index 6c1e1330..f5b2b7f8 100644
--- a/src/aig/nwk/nwkMap.c
+++ b/src/aig/nwk/nwkMap.c
@@ -56,7 +56,7 @@ void Nwk_ManSetIfParsDefault( If_Par_t * pPars )
pPars->fPreprocess = 1;
pPars->fArea = 0;
pPars->fFancy = 0;
- pPars->fExpRed = 0;
+ pPars->fExpRed = 1; ////
pPars->fLatchPaths = 0;
pPars->fEdge = 1;
pPars->fCutMin = 0;
@@ -244,16 +244,25 @@ Hop_Obj_t * Nwk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t *
***********************************************************************/
Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToIf )
{
+ Vec_Ptr_t * vIfToAig;
Nwk_Man_t * pNtk;
Nwk_Obj_t * pObjNew;
- Aig_Obj_t * pObj;
+ Aig_Obj_t * pObj, * pObjRepr;
If_Obj_t * pIfObj;
If_Cut_t * pCutBest;
int i, k, nLeaves, * ppLeaves;
assert( Aig_ManPiNum(p) == If_ManCiNum(pIfMan) );
assert( Aig_ManPoNum(p) == If_ManCoNum(pIfMan) );
assert( Aig_ManNodeNum(p) == If_ManAndNum(pIfMan) );
+ Aig_ManCleanData( p );
If_ManCleanCutData( pIfMan );
+ // create mapping of IF to AIG
+ vIfToAig = Vec_PtrStart( If_ManObjNum(pIfMan) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ pIfObj = Vec_PtrEntry( vAigToIf, i );
+ Vec_PtrWriteEntry( vIfToAig, pIfObj->Id, pObj );
+ }
// construct the network
pNtk = Nwk_ManAlloc();
pNtk->pName = Aig_UtilStrsav( p->pName );
@@ -271,7 +280,10 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
// create node
pObjNew = Nwk_ManCreateNode( pNtk, nLeaves, pIfObj->nRefs );
for ( k = 0; k < nLeaves; k++ )
- Nwk_ObjAddFanin( pObjNew, Aig_ManObj(p, ppLeaves[k])->pData );
+ {
+ pObjRepr = Vec_PtrEntry( vIfToAig, ppLeaves[k] );
+ Nwk_ObjAddFanin( pObjNew, pObjRepr->pData );
+ }
// get the functionality
pObjNew->pFunc = Nwk_NodeIfToHop( pNtk->pManHop, pIfMan, pIfObj );
}
@@ -292,7 +304,9 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
assert( 0 );
pObj->pData = pObjNew;
}
+ Vec_PtrFree( vIfToAig );
pNtk->pManTime = Tim_ManDup( pIfMan->pManTim, 0 );
+ assert( Nwk_ManCheck( pNtk ) );
return pNtk;
}
@@ -328,6 +342,8 @@ Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars
}
// transform the result of mapping into the new network
pNtk = Nwk_ManFromIf( pIfMan, p, vAigToIf );
+ if ( pPars->fBidec && pPars->nLutSize <= 8 )
+ Nwk_ManBidecResyn( pNtk, 0 );
If_ManStop( pIfMan );
Vec_PtrFree( vAigToIf );
return pNtk;
diff --git a/src/aig/nwk/nwkObj.c b/src/aig/nwk/nwkObj.c
index 6d1f0428..58587f07 100644
--- a/src/aig/nwk/nwkObj.c
+++ b/src/aig/nwk/nwkObj.c
@@ -154,10 +154,8 @@ void Nwk_ManDeleteNode( Nwk_Obj_t * pObj )
Vec_Ptr_t * vNodes = pObj->pMan->vTemp;
Nwk_Obj_t * pTemp;
int i;
- // delete fanins and fanouts
- Nwk_ObjCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pTemp, i )
- Nwk_ObjDeleteFanin( pTemp, pObj );
+ assert( Nwk_ObjFanoutNum(pObj) == 0 );
+ // delete fanins
Nwk_ObjCollectFanins( pObj, vNodes );
Vec_PtrForEachEntry( vNodes, pTemp, i )
Nwk_ObjDeleteFanin( pObj, pTemp );
diff --git a/src/aig/nwk/nwkTiming.c b/src/aig/nwk/nwkTiming.c
index c27f9d61..9ab24467 100644
--- a/src/aig/nwk/nwkTiming.c
+++ b/src/aig/nwk/nwkTiming.c
@@ -427,6 +427,8 @@ int Nwk_ManVerifyTiming( Nwk_Man_t * pNtk )
int i;
Nwk_ManForEachObj( pNtk, pObj, i )
{
+ if ( Nwk_ObjIsPi(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
+ continue;
tArrival = Nwk_NodeComputeArrival( pObj, 1 );
tRequired = Nwk_NodeComputeRequired( pObj, 1 );
if ( !Nwk_ManTimeEqual( tArrival, Nwk_ObjArrival(pObj), (float)0.01 ) )
diff --git a/src/aig/nwk/nwkUtil.c b/src/aig/nwk/nwkUtil.c
index 5fb594ec..97c95d27 100644
--- a/src/aig/nwk/nwkUtil.c
+++ b/src/aig/nwk/nwkUtil.c
@@ -19,6 +19,7 @@
***********************************************************************/
#include "nwk.h"
+#include "math.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -254,6 +255,114 @@ void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vCiNames,
printf( "Dumping logic network is currently not supported.\n" );
}
+/**Function*************************************************************
+
+ Synopsis [Prints the distribution of fanins/fanouts in the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Nwk_ManPrintFanioNew( Nwk_Man_t * pNtk )
+{
+ char Buffer[100];
+ Nwk_Obj_t * pNode;
+ Vec_Int_t * vFanins, * vFanouts;
+ int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
+ int i, k, nSizeMax;
+
+ // determine the largest fanin and fanout
+ nFaninsMax = nFanoutsMax = 0;
+ nFaninsAll = nFanoutsAll = 0;
+ Nwk_ManForEachNode( pNtk, pNode, i )
+ {
+ nFanins = Nwk_ObjFaninNum(pNode);
+ nFanouts = Nwk_ObjFanoutNum(pNode);
+ nFaninsAll += nFanins;
+ nFanoutsAll += nFanouts;
+ nFaninsMax = AIG_MAX( nFaninsMax, nFanins );
+ nFanoutsMax = AIG_MAX( nFanoutsMax, nFanouts );
+ }
+
+ // allocate storage for fanin/fanout numbers
+ nSizeMax = AIG_MAX( 10 * (Aig_Base10Log(nFaninsMax) + 1), 10 * (Aig_Base10Log(nFanoutsMax) + 1) );
+ vFanins = Vec_IntStart( nSizeMax );
+ vFanouts = Vec_IntStart( nSizeMax );
+
+ // count the number of fanins and fanouts
+ Nwk_ManForEachNode( pNtk, pNode, i )
+ {
+ nFanins = Nwk_ObjFaninNum(pNode);
+ nFanouts = Nwk_ObjFanoutNum(pNode);
+// nFanouts = Nwk_NodeMffcSize(pNode);
+
+ if ( nFanins < 10 )
+ Vec_IntAddToEntry( vFanins, nFanins, 1 );
+ else if ( nFanins < 100 )
+ Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
+ else if ( nFanins < 1000 )
+ Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
+ else if ( nFanins < 10000 )
+ Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
+ else if ( nFanins < 100000 )
+ Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
+ else if ( nFanins < 1000000 )
+ Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
+ else if ( nFanins < 10000000 )
+ Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
+
+ if ( nFanouts < 10 )
+ Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
+ else if ( nFanouts < 100 )
+ Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
+ else if ( nFanouts < 1000 )
+ Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
+ else if ( nFanouts < 10000 )
+ Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
+ else if ( nFanouts < 100000 )
+ Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
+ else if ( nFanouts < 1000000 )
+ Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
+ else if ( nFanouts < 10000000 )
+ Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
+ }
+
+ printf( "The distribution of fanins and fanouts in the network:\n" );
+ printf( " Number Nodes with fanin Nodes with fanout\n" );
+ for ( k = 0; k < nSizeMax; k++ )
+ {
+ if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
+ continue;
+ if ( k < 10 )
+ printf( "%15d : ", k );
+ else
+ {
+ sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ printf( "%15s : ", Buffer );
+ }
+ if ( vFanins->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanins->pArray[k] );
+ printf( " " );
+ if ( vFanouts->pArray[k] == 0 )
+ printf( " " );
+ else
+ printf( "%12d ", vFanouts->pArray[k] );
+ printf( "\n" );
+ }
+ Vec_IntFree( vFanins );
+ Vec_IntFree( vFanouts );
+
+ printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
+ nFaninsMax, 1.0*nFaninsAll/Nwk_ManNodeNum(pNtk),
+ nFanoutsMax, 1.0*nFanoutsAll/Nwk_ManNodeNum(pNtk) );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////