diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-13 23:08:52 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-13 23:08:52 -0700 |
commit | 1692c1a57a74938a396812375f29f0065b5337b7 (patch) | |
tree | 8eee10f90bef82325f134dbaadf86d158b92de21 /src/map/scl | |
parent | a4f80c1d36ee2ea986ac3fd637aa91f97537cdb6 (diff) | |
download | abc-1692c1a57a74938a396812375f29f0065b5337b7.tar.gz abc-1692c1a57a74938a396812375f29f0065b5337b7.tar.bz2 abc-1692c1a57a74938a396812375f29f0065b5337b7.zip |
Improvements to buffering and sizing.
Diffstat (limited to 'src/map/scl')
-rw-r--r-- | src/map/scl/scl.c | 20 | ||||
-rw-r--r-- | src/map/scl/sclBufSize.c | 13 | ||||
-rw-r--r-- | src/map/scl/sclLib.h | 1 | ||||
-rw-r--r-- | src/map/scl/sclLibUtil.c | 54 | ||||
-rw-r--r-- | src/map/scl/sclLiberty.c | 1 | ||||
-rw-r--r-- | src/map/scl/sclSize.h | 6 | ||||
-rw-r--r-- | src/map/scl/sclUpsize.c | 4 |
7 files changed, 67 insertions, 32 deletions
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index 1c5e3354..36bec7b4 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -308,7 +308,7 @@ usage: ***********************************************************************/ int Scl_CommandPrintLib( Abc_Frame_t * pAbc, int argc, char **argv ) { - float Slew = 200; + float Slew = 0; // use library float Gain = 100; int fInvOnly = 0; int fShort = 0; @@ -512,8 +512,8 @@ usage: int Scl_CommandDumpGen( Abc_Frame_t * pAbc, int argc, char **argv ) { char * pFileName = NULL; - float Slew = 200; - float Gain = 100; + float Slew = 0; // use the library + float Gain = 200; int nGatesMin = 4; int c, fVerbose = 0; Extra_UtilGetoptReset(); @@ -871,8 +871,8 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc); int c; memset( pPars, 0, sizeof(SC_BusPars) ); - pPars->GainRatio = 1000; - pPars->Slew = 100; + pPars->GainRatio = 250; + pPars->Slew = pAbc->pLibScl ? Abc_SclComputeAverageSlew((SC_Lib *)pAbc->pLibScl) : 100; pPars->nDegree = 10; pPars->fSizeOnly = 0; pPars->fAddBufs = 1; @@ -881,7 +881,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) pPars->fVerbose = 0; pPars->fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "GSDsbpcvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "GSNsbpcvwh" ) ) != EOF ) { switch ( c ) { @@ -907,7 +907,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( pPars->Slew < 0 ) goto usage; break; - case 'D': + case 'N': if ( globalUtilOptind >= argc ) { Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" ); @@ -959,7 +959,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } // modify the current network - pNtkRes = Abc_SclBufSizePerform( pNtk, (SC_Lib *)pAbc->pLibScl, pPars ); + pNtkRes = Abc_SclBufferingPerform( pNtk, (SC_Lib *)pAbc->pLibScl, pPars ); if ( pNtkRes == NULL ) { Abc_Print( -1, "The command has failed.\n" ); @@ -970,11 +970,11 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - fprintf( pAbc->Err, "usage: buffer [-GSD num] [-sbpcvwh]\n" ); + fprintf( pAbc->Err, "usage: buffer [-GSN num] [-sbpcvwh]\n" ); fprintf( pAbc->Err, "\t performs buffering and sizing and mapped network\n" ); fprintf( pAbc->Err, "\t-G <num> : target gain percentage [default = %d]\n", pPars->GainRatio ); fprintf( pAbc->Err, "\t-S <num> : target slew in pisoseconds [default = %d]\n", pPars->Slew ); - fprintf( pAbc->Err, "\t-D <num> : the maximum fanout degree [default = %d]\n", pPars->nDegree ); + fprintf( pAbc->Err, "\t-N <num> : the maximum fanout count [default = %d]\n", pPars->nDegree ); fprintf( pAbc->Err, "\t-s : toggle performing only sizing [default = %s]\n", pPars->fSizeOnly? "yes": "no" ); fprintf( pAbc->Err, "\t-b : toggle using buffers instead of inverters [default = %s]\n", pPars->fAddBufs? "yes": "no" ); fprintf( pAbc->Err, "\t-p : toggle buffering primary inputs [default = %s]\n", pPars->fBufPis? "yes": "no" ); diff --git a/src/map/scl/sclBufSize.c b/src/map/scl/sclBufSize.c index 00601dd5..aca87673 100644 --- a/src/map/scl/sclBufSize.c +++ b/src/map/scl/sclBufSize.c @@ -394,7 +394,6 @@ void Abc_SclBufSize( Bus_Man_t * p ) float GainGate = (float)1.0 * GainInv; float Load, LoadNew, Cin, DeptMax = 0; int i, k, nObjOld = Abc_NtkObjNumMax(p->pNtk); - Abc_SclMioGates2SclGates( p->pLib, p->pNtk ); Abc_NtkForEachObjReverse( p->pNtk, pObj, i ) { if ( !((Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0) || (Abc_ObjIsCi(pObj) && p->pPiDrive)) ) @@ -470,26 +469,30 @@ void Abc_SclBufSize( Bus_Man_t * p ) } DeptMax = Abc_MaxFloat( DeptMax, DeptCur ); } - Abc_SclSclGates2MioGates( p->pLib, p->pNtk ); if ( p->pPars->fVerbose ) { - printf( "WireLoads = %d. Degree = %d. Target gain =%5d Slew =%5d Buf = %6d Delay =%7.0f ps ", - p->pPars->fUseWireLoads, p->pPars->nDegree, p->pPars->GainRatio, p->pPars->Slew, + printf( "WireLoads = %d Degree = %d Target slew =%4d ps Gain2 =%5d Buf = %6d Delay =%7.0f ps ", + p->pPars->fUseWireLoads, p->pPars->nDegree, p->pPars->Slew, p->pPars->GainRatio, Abc_NtkObjNumMax(p->pNtk) - nObjOld, DeptMax ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); } } -Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ) +Abc_Ntk_t * Abc_SclBufferingPerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ) { Abc_Ntk_t * pNtkNew; Bus_Man_t * p; if ( !Abc_SclCheckNtk( pNtk, 0 ) ) return NULL; + // update gain if buffers are used + if ( pPars->fAddBufs ) + pPars->GainRatio = pPars->GainRatio * pPars->GainRatio / 100; Abc_SclReportDupFanins( pNtk ); + Abc_SclMioGates2SclGates( pLib, pNtk ); p = Bus_ManStart( pNtk, pLib, pPars ); Bus_ManReadInOutLoads( p ); Abc_SclBufSize( p ); Bus_ManStop( p ); + Abc_SclSclGates2MioGates( pLib, pNtk ); if ( pNtk->vPhases ) Vec_IntFillExtra( pNtk->vPhases, Abc_NtkObjNumMax(pNtk), 0 ); pNtkNew = Abc_NtkDupDfs( pNtk ); diff --git a/src/map/scl/sclLib.h b/src/map/scl/sclLib.h index 2ee25ffc..a4d553fa 100644 --- a/src/map/scl/sclLib.h +++ b/src/map/scl/sclLib.h @@ -610,6 +610,7 @@ extern SC_Cell * Abc_SclFindInvertor( SC_Lib * p, int fFindBuff ); extern SC_Cell * Abc_SclFindSmallestGate( SC_Cell * p, float CinMin ); extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area ); extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName ); +extern float Abc_SclComputeAverageSlew( SC_Lib * p ); extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin ); extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin ); diff --git a/src/map/scl/sclLibUtil.c b/src/map/scl/sclLibUtil.c index a8a5caf0..fb7cbd3a 100644 --- a/src/map/scl/sclLibUtil.c +++ b/src/map/scl/sclLibUtil.c @@ -280,6 +280,30 @@ SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area ) /**Function************************************************************* + Synopsis [Returns "average" slew.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float Abc_SclComputeAverageSlew( SC_Lib * p ) +{ + SC_Cell * pCell; + SC_Timing * pTime; + Vec_Flt_t * vIndex; + pCell = Abc_SclFindInvertor(p, 0); + if ( pCell == NULL ) + return 0; + pTime = Scl_CellPinTime( pCell, 0 ); + vIndex = pTime->pCellRise->vIndex0; // slew + return Vec_FltEntry( vIndex, Vec_FltSize(vIndex)/3 ); +} + +/**Function************************************************************* + Synopsis [Compute delay parameters of pin/cell/class.] Description [] @@ -437,18 +461,19 @@ void Abc_SclMarkSkippedCells( SC_Lib * p ) fclose( pFile ); printf( "Marked %d cells for skipping in the library \"%s\".\n", nSkipped, p->pName ); } -void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fShort ) +void Abc_SclPrintCells( SC_Lib * p, float SlewInit, float Gain, int fInvOnly, int fShort ) { SC_Cell * pCell, * pRepr; SC_Pin * pPin; int i, j, k, nLength = 0; + float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit; float LD = 0, PD = 0; assert( Vec_PtrSize(p->vCellClasses) > 0 ); printf( "Library \"%s\" ", p->pName ); printf( "has %d cells in %d classes. ", Vec_PtrSize(p->vCells), Vec_PtrSize(p->vCellClasses) ); if ( !fShort ) - printf( "Delay estimate is based on slew %.2f and gain %.2f.", Slew, Gain ); + printf( "Delay estimate is based on slew %.2f ps and gain %.2f.", Slew, Gain ); printf( "\n" ); Abc_SclMarkSkippedCells( p ); // find the longest name @@ -628,7 +653,7 @@ Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl ) Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 ); Vec_StrFree( vStr ); if ( pLib ) - printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) ); + printf( "Derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) ); else printf( "Reading library has filed.\n" ); return pLib; @@ -706,10 +731,11 @@ Vec_Str_t * Abc_SclProduceGenlibStr( SC_Lib * p, float Slew, float Gain, int nGa *pnCellCount = Count; return vStr; } -void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin ) +void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float SlewInit, float Gain, int nGatesMin ) { int nCellCount = 0; char FileName[1000]; + float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit; Vec_Str_t * vStr; FILE * pFile; if ( pFileName == NULL ) @@ -728,17 +754,18 @@ void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, in fclose( pFile ); printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName ); } -Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin ) +Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float SlewInit, float Gain, int nGatesMin, int fVerbose ) { int nCellCount = 0; SC_Lib * p = (SC_Lib *)pScl; + float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit; Vec_Str_t * vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount ); Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 ); Vec_StrFree( vStr ); - if ( pLib ) - printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, nCellCount ); - else + if ( !pLib ) printf( "Reading library has filed.\n" ); + else if ( fVerbose ) + printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nCellCount, Slew, Gain ); return pLib; } @@ -753,10 +780,11 @@ Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nG SeeAlso [] ***********************************************************************/ -void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin ) +void Abc_SclInstallGenlib( void * pScl, float SlewInit, float Gain, int nGatesMin ) { SC_Lib * p = (SC_Lib *)pScl; Vec_Str_t * vStr, * vStr2; + float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit; int RetValue, nGateCount = SC_LibCellNum(p); if ( Gain == 0 ) vStr = Abc_SclProduceGenlibStrSimple(p); @@ -766,10 +794,12 @@ void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin ) RetValue = Mio_UpdateGenlib2( vStr, vStr2, p->pName, 0 ); Vec_StrFree( vStr ); Vec_StrFree( vStr2 ); - if ( RetValue ) - printf( "Internally derived GENLIB library \"%s\" with %d gates.\n", p->pName, nGateCount ); - else + if ( !RetValue ) printf( "Reading library has filed.\n" ); + else if ( Gain != 0 ) + printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nGateCount, Slew, Gain ); +// else +// printf( "Derived unit-delay GENLIB library \"%s\" with %d gates.\n", p->pName, nGateCount ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/map/scl/sclLiberty.c b/src/map/scl/sclLiberty.c index 74d19143..a949f70b 100644 --- a/src/map/scl/sclLiberty.c +++ b/src/map/scl/sclLiberty.c @@ -1333,6 +1333,7 @@ SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose ) pLib->pFileName = Abc_UtilStrsav( pFileName ); Abc_SclLibNormalize( pLib ); Vec_StrFree( vStr ); +// printf( "Average slew = %.2f ps\n", Abc_SclComputeAverageSlew(pLib) ); return pLib; } diff --git a/src/map/scl/sclSize.h b/src/map/scl/sclSize.h index 76022448..1087651e 100644 --- a/src/map/scl/sclSize.h +++ b/src/map/scl/sclSize.h @@ -532,14 +532,14 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, abctime Time fprintf( pTable, "%.1f ", 100.0 * Abc_NtkNodeNum(p->pNtk) / nNodesOld ); fprintf( pTable, "%.1f ", 100.0 * (int)p->SumArea / nAreaOld ); fprintf( pTable, "%.1f ", 100.0 * (int)p->ReportDelay / nDelayOld ); - fprintf( pTable, "%.2f", 1.0*(Abc_Clock() - clk)/CLOCKS_PER_SEC ); + fprintf( pTable, "%.2f", 1.0*(Abc_Clock() - clk)/CLOCKS_PER_SEC ); } fclose( pTable ); } -/*=== sclBufSize.c ===============================================================*/ -extern Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ); /*=== sclBuffer.c ===============================================================*/ +extern Abc_Ntk_t * Abc_SclBufferingPerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ); +/*=== sclBufferOld.c ===============================================================*/ extern int Abc_SclIsInv( Abc_Obj_t * pObj ); extern void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj ); extern void Abc_NodeInvUpdateObjFanoutPolarity( Abc_Obj_t * pObj, Abc_Obj_t * pFanout ); diff --git a/src/map/scl/sclUpsize.c b/src/map/scl/sclUpsize.c index fbcaff83..f1e0fbd9 100644 --- a/src/map/scl/sclUpsize.c +++ b/src/map/scl/sclUpsize.c @@ -309,8 +309,8 @@ int Abc_SclFindBestCell( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t * vRecalcs, Vec } else if ( NoChange ) NoChange++; -// if ( NoChange == 4 ) -// break; + if ( NoChange == 4 ) + break; // printf( "%.2f ", dGain ); } // printf( "Best = %.2f ", dGainBest ); |