74 int i, nFaninsMax = 0;
77 if ( nFaninsMax < Nwk_ObjFaninNum(pNode) )
78 nFaninsMax = Nwk_ObjFaninNum(pNode);
99 nFanins += Nwk_ObjFaninNum(pNode);
120 Counter += Nwk_ObjIsPi( pNode );
140 Counter += Nwk_ObjIsPo( pNode );
161 if ( pNode->pFunc == NULL )
163 printf(
"Nwk_ManGetAigNodeNum(): Local AIG of node %d is not assigned.\n", pNode->Id );
166 if ( Nwk_ObjFaninNum(pNode) < 2 )
186 int Diff = (*pp1)->Level - (*pp2)->Level;
207 int Diff = (*pp1)->Level - (*pp2)->Level;
230 printf(
"ObjId = %5d. ", pObj->Id );
231 if ( Nwk_ObjIsPi(pObj) )
233 if ( Nwk_ObjIsPo(pObj) )
235 if ( Nwk_ObjIsNode(pObj) )
237 printf(
" Fanins = " );
239 printf(
"%d ", pNext->Id );
240 printf(
" Fanouts = " );
242 printf(
"%d ", pNext->Id );
270 printf(
"Nwk_ManDumpBlif(): Network does not have POs.\n" );
274 nDigits = Abc_Base10Log( Nwk_ManObjNumMax(pNtk) );
276 pFile = fopen( pFileName,
"w" );
277 fprintf( pFile,
"# BLIF file written by procedure Nwk_ManDumpBlif()\n" );
279 fprintf( pFile,
".model %s\n", pNtk->
pName );
281 fprintf( pFile,
".inputs" );
284 fprintf( pFile,
" %s", (
char*)Vec_PtrEntry(vPiNames, i) );
286 fprintf( pFile,
" n%0*d", nDigits, pObj->Id );
287 fprintf( pFile,
"\n" );
289 fprintf( pFile,
".outputs" );
292 fprintf( pFile,
" %s", (
char*)Vec_PtrEntry(vPoNames, i) );
294 fprintf( pFile,
" n%0*d", nDigits, pObj->Id );
295 fprintf( pFile,
"\n" );
298 vTruth = Vec_IntAlloc( 1 << 16 );
299 vCover = Vec_IntAlloc( 1 << 16 );
303 if ( !Nwk_ObjIsNode(pObj) )
307 if ( Hop_IsComplement(pObj->pFunc) )
308 Kit_TruthNot( pTruth, pTruth, Nwk_ObjFaninNum(pObj) );
311 fprintf( pFile,
".names" );
312 if ( !Kit_TruthIsConst0(pTruth, Nwk_ObjFaninNum(pObj)) && !Kit_TruthIsConst1(pTruth, Nwk_ObjFaninNum(pObj)) )
315 if ( vPiNames && Nwk_ObjIsPi(pFanin) )
316 fprintf( pFile,
" %s", (
char*)Vec_PtrEntry(vPiNames, Nwk_ObjPioNum(pFanin)) );
318 fprintf( pFile,
" n%0*d", nDigits, pFanin->Id );
320 fprintf( pFile,
" n%0*d\n", nDigits, pObj->Id );
322 fprintf( pFile,
"%s", pSop );
324 Vec_IntFree( vCover );
325 Vec_IntFree( vTruth );
326 Vec_PtrFree( vNodes );
331 fprintf( pFile,
".names" );
332 if ( vPiNames && Nwk_ObjIsPi(Nwk_ObjFanin0(pObj)) )
333 fprintf( pFile,
" %s", (
char*)Vec_PtrEntry(vPiNames, Nwk_ObjPioNum(Nwk_ObjFanin0(pObj))) );
335 fprintf( pFile,
" n%0*d", nDigits, Nwk_ObjFanin0(pObj)->Id );
337 fprintf( pFile,
" %s\n", (
char*)Vec_PtrEntry(vPoNames, Nwk_ObjPioNum(pObj)) );
339 fprintf( pFile,
" n%0*d\n", nDigits, pObj->Id );
340 fprintf( pFile,
"%d 1\n", !pObj->fInvert );
342 fprintf( pFile,
".end\n\n" );
362 int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
366 nFaninsMax = nFanoutsMax = 0;
367 nFaninsAll = nFanoutsAll = 0;
370 nFanins = Nwk_ObjFaninNum(pNode);
371 nFanouts = Nwk_ObjFanoutNum(pNode);
372 nFaninsAll += nFanins;
373 nFanoutsAll += nFanouts;
374 nFaninsMax = Abc_MaxInt( nFaninsMax, nFanins );
375 nFanoutsMax = Abc_MaxInt( nFanoutsMax, nFanouts );
379 nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nFaninsMax) + 1), 10 * (Abc_Base10Log(nFanoutsMax) + 1) );
380 vFanins = Vec_IntStart( nSizeMax );
381 vFanouts = Vec_IntStart( nSizeMax );
386 nFanins = Nwk_ObjFaninNum(pNode);
387 nFanouts = Nwk_ObjFanoutNum(pNode);
391 Vec_IntAddToEntry( vFanins, nFanins, 1 );
392 else if ( nFanins < 100 )
393 Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
394 else if ( nFanins < 1000 )
395 Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
396 else if ( nFanins < 10000 )
397 Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
398 else if ( nFanins < 100000 )
399 Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
400 else if ( nFanins < 1000000 )
401 Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
402 else if ( nFanins < 10000000 )
403 Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
406 Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
407 else if ( nFanouts < 100 )
408 Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
409 else if ( nFanouts < 1000 )
410 Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
411 else if ( nFanouts < 10000 )
412 Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
413 else if ( nFanouts < 100000 )
414 Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
415 else if ( nFanouts < 1000000 )
416 Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
417 else if ( nFanouts < 10000000 )
418 Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
421 printf(
"The distribution of fanins and fanouts in the network:\n" );
422 printf(
" Number Nodes with fanin Nodes with fanout\n" );
423 for ( k = 0; k < nSizeMax; k++ )
425 if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
428 printf(
"%15d : ", k );
431 sprintf( Buffer,
"%d - %d", (
int)pow((
double)10, k/10) * (k%10), (
int)pow((
double)10, k/10) * (k%10+1) - 1 );
432 printf(
"%15s : ", Buffer );
434 if ( vFanins->pArray[k] == 0 )
437 printf(
"%12d ", vFanins->pArray[k] );
439 if ( vFanouts->pArray[k] == 0 )
442 printf(
"%12d ", vFanouts->pArray[k] );
445 Vec_IntFree( vFanins );
446 Vec_IntFree( vFanouts );
448 printf(
"Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
449 nFaninsMax, 1.0*nFaninsAll/Nwk_ManNodeNum(pNtk),
450 nFanoutsMax, 1.0*nFanoutsAll/Nwk_ManNodeNum(pNtk) );
469 pObj->MarkA = pObj->MarkB = 0;
488 int uSupp, nSuppSize, k, Counter = 0;
491 if ( nSuppSize == Nwk_ObjFaninNum(pObj) )
498 if ( uSupp & (1 << k) )
500 pObjNew->pFunc =
Hop_Remap( pNtk->
pManHop, pObj->pFunc, uSupp, Nwk_ObjFaninNum(pObj) );
502 printf(
"Reducing node %d fanins from %d to %d.\n",
503 pObj->Id, Nwk_ObjFaninNum(pObj), Nwk_ObjFaninNum(pObjNew) );
524 vTruth = Vec_IntAlloc( 1 << 16 );
527 if ( fVerbose && Counter )
528 printf(
"Support minimization reduced support of %d nodes.\n", Counter );
529 Vec_IntFree( vTruth );
549 ABC_PRT(
"Minbase", Abc_Clock() - clk );
568 vTruth = Vec_IntAlloc( 1 << 16 );
571 if ( fVerbose && Counter )
572 printf(
"Support minimization reduced support of %d nodes.\n", Counter );
573 Vec_IntFree( vTruth );
589 Hop_Man_t * pManHop = pObj->pMan->pManHop;
592 assert( pObj->pFanio[iFan0] == pObj->pFanio[iFan1] );
614 vTruth = Vec_IntAlloc( 1 << 16 );
618 for ( k = 0; k < pObj->nFanins; k++ )
620 for ( m = k + 1; m < pObj->nFanins; m++ )
621 if ( pObj->pFanio[k] == pObj->pFanio[m] )
624 printf(
"Removing duplicated fanins of node %d (fanins %d and %d).\n",
625 pObj->Id, pObj->pFanio[k]->Id, pObj->pFanio[m]->Id );
634 Vec_IntFree( vTruth );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
struct Aig_MmFlex_t_ Aig_MmFlex_t
Aig_MmFlex_t * Aig_MmFlexStart()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_Compose(Hop_Man_t *p, Hop_Obj_t *pRoot, Hop_Obj_t *pFunc, int iVar)
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Hop_Obj_t * Hop_Remap(Hop_Man_t *p, Hop_Obj_t *pRoot, unsigned uSupp, int nVars)
int Hop_DagSize(Hop_Obj_t *pObj)
unsigned * Hop_ManConvertAigToTruth(Hop_Man_t *p, Hop_Obj_t *pRoot, int nVars, Vec_Int_t *vTruth, int fMsbFirst)
char * Kit_PlaFromTruth(void *p, unsigned *pTruth, int nVars, Vec_Int_t *vCover)
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
struct Nwk_Man_t_ Nwk_Man_t
void Nwk_ManPrintFanioNew(Nwk_Man_t *pNtk)
int Nwk_ManPiNum(Nwk_Man_t *pNtk)
int Nwk_NodeCompareLevelsDecrease(Nwk_Obj_t **pp1, Nwk_Obj_t **pp2)
int Nwk_ManGetTotalFanins(Nwk_Man_t *pNtk)
int Nwk_ManGetAigNodeNum(Nwk_Man_t *pNtk)
void Nwk_ManRemoveDupFaninsNode(Nwk_Obj_t *pObj, int iFan0, int iFan1, Vec_Int_t *vTruth)
int Nwk_ManMinimumBaseNode(Nwk_Obj_t *pObj, Vec_Int_t *vTruth, int fVerbose)
int Nwk_ManGetFaninMax(Nwk_Man_t *pNtk)
ABC_NAMESPACE_IMPL_START void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
int Nwk_ManPoNum(Nwk_Man_t *pNtk)
void Nwk_ManDumpBlif(Nwk_Man_t *pNtk, char *pFileName, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vPoNames)
void Nwk_ManRemoveDupFanins(Nwk_Man_t *pNtk, int fVerbose)
void Nwk_ManCleanMarks(Nwk_Man_t *pMan)
void Nwk_ManMinimumBaseRec(Nwk_Man_t *pNtk, int fVerbose)
int Nwk_NodeCompareLevelsIncrease(Nwk_Obj_t **pp1, Nwk_Obj_t **pp2)
int Nwk_ManMinimumBaseInt(Nwk_Man_t *pNtk, int fVerbose)
void Nwk_ObjPrint(Nwk_Obj_t *pObj)
void Nwk_ManMinimumBase(Nwk_Man_t *pNtk, int fVerbose)
ABC_DLL Nwk_Obj_t * Nwk_ManCreateNode(Nwk_Man_t *pMan, int nFanins, int nFanouts)
#define Nwk_ManForEachNode(p, pObj, i)
#define Nwk_ManForEachCi(p, pObj, i)
ITERATORS ///.
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
#define Nwk_ManForEachObj(p, pObj, i)
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL void Nwk_ObjAddFanin(Nwk_Obj_t *pObj, Nwk_Obj_t *pFanin)
ABC_DLL void Nwk_ObjReplace(Nwk_Obj_t *pNodeOld, Nwk_Obj_t *pNodeNew)
#define Nwk_ManForEachCo(p, pObj, i)
ABC_DLL Vec_Ptr_t * Nwk_ManDfs(Nwk_Man_t *pNtk)
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.