@@ -470,6 +470,65 @@ int Gia_ManCountDupLut( Gia_Man_t * p )
470470 return nCountDup + nCountPis ;
471471}
472472
473+ void Gia_ManCollectLuts_rec ( Gia_Man_t * p , int iObj , Vec_Int_t * vLuts )
474+ {
475+ if ( Gia_ObjIsTravIdCurrentId ( p , iObj ) || !Gia_ObjIsAnd (Gia_ManObj (p , iObj )) )
476+ return ;
477+ Gia_ObjSetTravIdCurrentId ( p , iObj );
478+ int k , iFan ;
479+ Gia_LutForEachFanin ( p , iObj , iFan , k )
480+ Gia_ManCollectLuts_rec ( p , iFan , vLuts );
481+ Vec_IntPush ( vLuts , iObj );
482+ }
483+ int Gia_ManCountLutLevels ( Gia_Man_t * p , Vec_Int_t * vLuts , Vec_Int_t * vLevel )
484+ {
485+ int i , iObj , k , iFan , LevelMax = 0 ;
486+ Vec_IntForEachEntry ( vLuts , iObj , i ) {
487+ int Level = 0 ;
488+ Gia_LutForEachFanin ( p , iObj , iFan , k )
489+ Level = Abc_MaxInt ( Level , Vec_IntEntry (vLevel , iFan ) );
490+ Vec_IntWriteEntry ( vLevel , iObj , Level + 1 );
491+ LevelMax = Abc_MaxInt ( LevelMax , Level + 1 );
492+ }
493+ Vec_IntForEachEntry ( vLuts , iObj , i )
494+ Vec_IntWriteEntry ( vLevel , iObj , 0 );
495+ return LevelMax ;
496+ }
497+ void Gia_ManPrintOutputLutStats ( Gia_Man_t * p )
498+ {
499+ int Limit = 100000 ;
500+ int nLutSize = Gia_ManLutSizeMax (p );
501+ Vec_Int_t * vLuts = Vec_IntAlloc ( 1000 );
502+ Vec_Int_t * vNodes = Vec_IntStart ( Limit );
503+ Vec_Int_t * vLevels = Vec_IntStart ( Limit );
504+ Vec_Int_t * vLevel = Vec_IntStart ( Gia_ManObjNum (p ) );
505+ int i , DriverId , Value , nTotalLuts = 0 ;
506+ Gia_ManForEachCoDriverId ( p , DriverId , i ) {
507+ Vec_IntClear ( vLuts );
508+ Gia_ManIncrementTravId (p );
509+ Gia_ManCollectLuts_rec ( p , DriverId , vLuts );
510+ if ( Vec_IntSize (vLuts ) < Limit )
511+ Vec_IntAddToEntry ( vNodes , Vec_IntSize (vLuts ), 1 );
512+ int Level = Gia_ManCountLutLevels ( p , vLuts , vLevel );
513+ if ( Level < Limit )
514+ Vec_IntAddToEntry ( vLevels , Level , 1 );
515+ nTotalLuts += Vec_IntSize (vLuts );
516+ }
517+ printf ( "Level count statistics for %d AIG outputs:\n" , Gia_ManCoNum (p ) );
518+ Vec_IntForEachEntry ( vLevels , Value , i )
519+ if ( Value )
520+ printf ( " %2d level : Function count = %8d (%6.2f %%)\n" , i , Value , 100.0 * Value /Gia_ManCoNum (p ) );
521+ printf ( "LUT count statistics for %d AIG outputs:\n" , Gia_ManCoNum (p ) );
522+ Vec_IntForEachEntry ( vNodes , Value , i )
523+ if ( Value )
524+ printf ( " %2d LUT%d : Function count = %8d (%6.2f %%)\n" , i , nLutSize , Value , 100.0 * Value /Gia_ManCoNum (p ) );
525+ printf ( "Sum total of LUT counts for all outputs = %d. Shared LUT count = %d.\n" , nTotalLuts , Gia_ManLutNum (p ) );
526+ Vec_IntFree ( vLuts );
527+ Vec_IntFree ( vNodes );
528+ Vec_IntFree ( vLevels );
529+ Vec_IntFree ( vLevel );
530+ }
531+
473532void Gia_ManPrintMappingStats ( Gia_Man_t * p , char * pDumpFile )
474533{
475534 int fDisable2Lut = 1 ;
0 commit comments