diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index b2b499eae..981637ea4 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -270,6 +270,7 @@ struct Gps_Par_t_ int fSkipMap; int fSlacks; int fNoColor; + int fMapOutStats; char * pDumpFile; }; @@ -1508,6 +1509,7 @@ extern int Gia_ManHashAndMulti( Gia_Man_t * p, Vec_Int_t * vLits extern int Gia_ManHashAndMulti2( Gia_Man_t * p, Vec_Int_t * vLits ); extern int Gia_ManHashDualMiter( Gia_Man_t * p, Vec_Int_t * vOuts ); /*=== giaIf.c ===========================================================*/ +extern void Gia_ManPrintOutputLutStats( Gia_Man_t * p ); extern void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile ); extern void Gia_ManPrintPackingStats( Gia_Man_t * p ); extern void Gia_ManPrintLutStats( Gia_Man_t * p ); diff --git a/src/aig/gia/giaIf.c b/src/aig/gia/giaIf.c index c08a91ecd..d44a47102 100644 --- a/src/aig/gia/giaIf.c +++ b/src/aig/gia/giaIf.c @@ -470,6 +470,65 @@ int Gia_ManCountDupLut( Gia_Man_t * p ) return nCountDup + nCountPis; } +void Gia_ManCollectLuts_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vLuts ) +{ + if ( Gia_ObjIsTravIdCurrentId( p, iObj ) || !Gia_ObjIsAnd(Gia_ManObj(p, iObj)) ) + return; + Gia_ObjSetTravIdCurrentId( p, iObj ); + int k, iFan; + Gia_LutForEachFanin( p, iObj, iFan, k ) + Gia_ManCollectLuts_rec( p, iFan, vLuts ); + Vec_IntPush( vLuts, iObj ); +} +int Gia_ManCountLutLevels( Gia_Man_t * p, Vec_Int_t * vLuts, Vec_Int_t * vLevel ) +{ + int i, iObj, k, iFan, LevelMax = 0; + Vec_IntForEachEntry( vLuts, iObj, i ) { + int Level = 0; + Gia_LutForEachFanin( p, iObj, iFan, k ) + Level = Abc_MaxInt( Level, Vec_IntEntry(vLevel, iFan) ); + Vec_IntWriteEntry( vLevel, iObj, Level+1 ); + LevelMax = Abc_MaxInt( LevelMax, Level+1 ); + } + Vec_IntForEachEntry( vLuts, iObj, i ) + Vec_IntWriteEntry( vLevel, iObj, 0 ); + return LevelMax; +} +void Gia_ManPrintOutputLutStats( Gia_Man_t * p ) +{ + int Limit = 100000; + int nLutSize = Gia_ManLutSizeMax(p); + Vec_Int_t * vLuts = Vec_IntAlloc( 1000 ); + Vec_Int_t * vNodes = Vec_IntStart( Limit ); + Vec_Int_t * vLevels = Vec_IntStart( Limit ); + Vec_Int_t * vLevel = Vec_IntStart( Gia_ManObjNum(p) ); + int i, DriverId, Value, nTotalLuts = 0; + Gia_ManForEachCoDriverId( p, DriverId, i ) { + Vec_IntClear( vLuts ); + Gia_ManIncrementTravId(p); + Gia_ManCollectLuts_rec( p, DriverId, vLuts ); + if ( Vec_IntSize(vLuts) < Limit ) + Vec_IntAddToEntry( vNodes, Vec_IntSize(vLuts), 1 ); + int Level = Gia_ManCountLutLevels( p, vLuts, vLevel ); + if ( Level < Limit ) + Vec_IntAddToEntry( vLevels, Level, 1 ); + nTotalLuts += Vec_IntSize(vLuts); + } + printf( "Level count statistics for %d AIG outputs:\n", Gia_ManCoNum(p) ); + Vec_IntForEachEntry( vLevels, Value, i ) + if ( Value ) + printf( " %2d level : Function count = %8d (%6.2f %%)\n", i, Value, 100.0*Value/Gia_ManCoNum(p) ); + printf( "LUT count statistics for %d AIG outputs:\n", Gia_ManCoNum(p) ); + Vec_IntForEachEntry( vNodes, Value, i ) + if ( Value ) + printf( " %2d LUT%d : Function count = %8d (%6.2f %%)\n", i, nLutSize, Value, 100.0*Value/Gia_ManCoNum(p) ); + printf( "Sum total of LUT counts for all outputs = %d. Shared LUT count = %d.\n", nTotalLuts, Gia_ManLutNum(p) ); + Vec_IntFree( vLuts ); + Vec_IntFree( vNodes ); + Vec_IntFree( vLevels ); + Vec_IntFree( vLevel ); +} + void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile ) { int fDisable2Lut = 1; diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c index 7f3d27826..2f271e35c 100644 --- a/src/aig/gia/giaMan.c +++ b/src/aig/gia/giaMan.c @@ -640,6 +640,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) } if ( pPars && pPars->fSlacks ) Gia_ManDfsSlacksPrint( p ); + if ( Gia_ManHasMapping(p) && pPars->fMapOutStats ) + Gia_ManPrintOutputLutStats( p ); } /**Function************************************************************* diff --git a/src/base/abc/abcSop.c b/src/base/abc/abcSop.c index adc1639a6..3275e4772 100644 --- a/src/base/abc/abcSop.c +++ b/src/base/abc/abcSop.c @@ -1131,6 +1131,8 @@ Vec_Ptr_t * Abc_SopFromTruthsHex( char * pTruth ) char * pToken = strtok( pCopy, " \r\n\t|" ); while ( pToken ) { + if ( pToken[0] == '0' && pToken[1] == 'x' ) + pToken += 2; if ( !Abc_SopCheckReadTruth( vRes, pToken, 1 ) ) break; Vec_PtrPush( vRes, Abc_SopFromTruthHex(pToken) ); diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index be619df7a..83f1e06ba 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -34444,7 +34444,7 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv ) int c, fBest = 0; memset( pPars, 0, sizeof(Gps_Par_t) ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmaszxbh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmasozxbh" ) ) != EOF ) { switch ( c ) { @@ -34472,6 +34472,9 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv ) case 's': pPars->fSlacks ^= 1; break; + case 'o': + pPars->fMapOutStats ^= 1; + break; case 'z': pPars->fSkipMap ^= 1; break; @@ -34517,7 +34520,7 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &ps [-tpcnlmaszxbh] [-D file]\n" ); + Abc_Print( -2, "usage: &ps [-tpcnlmasozxbh] [-D file]\n" ); Abc_Print( -2, "\t prints stats of the current AIG\n" ); Abc_Print( -2, "\t-t : toggle printing BMC tents [default = %s]\n", pPars->fTents? "yes": "no" ); Abc_Print( -2, "\t-p : toggle printing switching activity [default = %s]\n", pPars->fSwitch? "yes": "no" ); @@ -34527,6 +34530,7 @@ usage: Abc_Print( -2, "\t-m : toggle printing MUX/XOR statistics [default = %s]\n", pPars->fMuxXor? "yes": "no" ); Abc_Print( -2, "\t-a : toggle printing miter statistics [default = %s]\n", pPars->fMiter? "yes": "no" ); Abc_Print( -2, "\t-s : toggle printing slack distribution [default = %s]\n", pPars->fSlacks? "yes": "no" ); + Abc_Print( -2, "\t-o : toggle printing mapping output stats [default = %s]\n", pPars->fMapOutStats? "yes": "no" ); Abc_Print( -2, "\t-z : skip mapping statistics even if mapped [default = %s]\n", pPars->fSkipMap? "yes": "no" ); Abc_Print( -2, "\t-x : toggle using no color in the printout [default = %s]\n", pPars->fNoColor? "yes": "no" ); Abc_Print( -2, "\t-b : toggle printing saved AIG statistics [default = %s]\n", fBest? "yes": "no" );