From 00efa6805380739f36ca9cc73623aefe25eeb9b5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 21 Nov 2013 12:58:13 -0800 Subject: Several changes to allow Liberty files without delay info. --- src/base/abci/abcMap.c | 2 +- src/base/abci/abcPrint.c | 2 +- src/map/mio/mio.h | 1 + src/map/scl/scl.c | 22 +++++++++++++------ src/map/scl/sclLib.h | 3 +++ src/map/scl/sclLibUtil.c | 56 ++++++++++++++++++++++++++++++++++++++---------- 6 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/base/abci/abcMap.c b/src/base/abci/abcMap.c index b04a7076..aca51c88 100644 --- a/src/base/abci/abcMap.c +++ b/src/base/abci/abcMap.c @@ -71,7 +71,7 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, assert( Abc_NtkIsStrash(pNtk) ); // derive library from SCL // if the library is created here, it will be deleted when pSuperLib is deleted in Map_SuperLibFree() - if ( Abc_FrameReadLibScl() ) + if ( Abc_FrameReadLibScl() && Abc_SclHasDelayInfo( Abc_FrameReadLibScl() ) ) { pLib = Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin, fVerbose ); if ( Abc_FrameReadLibGen() ) diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 907a7cd2..66cb5af0 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -1034,7 +1034,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary ) } // determine the longest gate name - nGateNameLen = 0; + nGateNameLen = 5; for ( i = 0; i < nGates; i++ ) { Counter = Mio_GateReadValue( ppGates[i] ); diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h index 9c4d4c4c..c7d90917 100644 --- a/src/map/mio/mio.h +++ b/src/map/mio/mio.h @@ -165,6 +165,7 @@ extern void Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_L /*=== sclUtil.c =========================================================*/ extern Mio_Library_t * Abc_SclDeriveGenlibSimple( void * pScl ); extern Mio_Library_t * Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin, int fVerbose ); +extern int Abc_SclHasDelayInfo( void * pScl ); ABC_NAMESPACE_HEADER_END diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c index b3175dbb..ac490c73 100644 --- a/src/map/scl/scl.c +++ b/src/map/scl/scl.c @@ -958,6 +958,11 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Fanin phase information is not avaiable.\n" ); return 1; } + if ( !pAbc->pLibScl || !Abc_SclHasDelayInfo(pAbc->pLibScl) ) + { + Abc_Print( -1, "Library delay info is not available.\n" ); + return 1; + } // modify the current network pNtkRes = Abc_SclBufferingPerform( pNtk, (SC_Lib *)pAbc->pLibScl, pPars ); if ( pNtkRes == NULL ) @@ -1089,6 +1094,11 @@ int Scl_CommandBufferOld( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Fanin phase information is not avaiable.\n" ); return 1; } + if ( !pAbc->pLibScl || !Abc_SclHasDelayInfo(pAbc->pLibScl) ) + { + Abc_Print( -1, "Library delay info is not available.\n" ); + return 1; + } // modify the current network if ( fAddInvs ) @@ -1428,9 +1438,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) fprintf( pAbc->Err, "The current network is not in a topo order (run \"topo\").\n" ); return 1; } - if ( pAbc->pLibScl == NULL ) + if ( !pAbc->pLibScl || !Abc_SclHasDelayInfo(pAbc->pLibScl) ) { - fprintf( pAbc->Err, "There is no Liberty library available.\n" ); + Abc_Print( -1, "Library delay info is not available.\n" ); return 1; } @@ -1605,9 +1615,9 @@ int Scl_CommandDnsize( Abc_Frame_t * pAbc, int argc, char **argv ) fprintf( pAbc->Err, "The current network is not in a topo order (run \"topo\").\n" ); return 1; } - if ( pAbc->pLibScl == NULL ) + if ( !pAbc->pLibScl || !Abc_SclHasDelayInfo(pAbc->pLibScl) ) { - fprintf( pAbc->Err, "There is no Liberty library available.\n" ); + Abc_Print( -1, "Library delay info is not available.\n" ); return 1; } @@ -1678,9 +1688,9 @@ int Scl_CommandPrintBuf( Abc_Frame_t * pAbc, int argc, char **argv ) fprintf( pAbc->Err, "The current network is not in a topo order (run \"topo\").\n" ); return 1; } - if ( pAbc->pLibScl == NULL ) + if ( !pAbc->pLibScl || !Abc_SclHasDelayInfo(pAbc->pLibScl) ) { - fprintf( pAbc->Err, "There is no Liberty library available.\n" ); + Abc_Print( -1, "Library delay info is not available.\n" ); return 1; } diff --git a/src/map/scl/sclLib.h b/src/map/scl/sclLib.h index b8ac624a..18335085 100644 --- a/src/map/scl/sclLib.h +++ b/src/map/scl/sclLib.h @@ -559,6 +559,8 @@ static inline SC_Timing * Scl_CellPinTime( SC_Cell * pCell, int iPin ) pPin = SC_CellPin( pCell, pCell->n_inputs ); assert( Vec_PtrSize(pPin->vRTimings) == pCell->n_inputs ); pRTime = (SC_Timings *)Vec_PtrEntry( pPin->vRTimings, iPin ); + if ( Vec_PtrSize(pRTime->vTimings) == 0 ) + return NULL; assert( Vec_PtrSize(pRTime->vTimings) == 1 ); return (SC_Timing *)Vec_PtrEntry( pRTime->vTimings, 0 ); } @@ -610,6 +612,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 int Abc_SclHasDelayInfo( void * pScl ); 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 c078e4e3..8f4bcd61 100644 --- a/src/map/scl/sclLibUtil.c +++ b/src/map/scl/sclLibUtil.c @@ -278,6 +278,31 @@ SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area ) return Abc_SclFetchWireLoadModel( p, pWLoadUsed ); } +/**Function************************************************************* + + Synopsis [Returns 1 if the library has delay info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_SclHasDelayInfo( void * pScl ) +{ + SC_Lib * p = (SC_Lib *)pScl; + SC_Cell * pCell; + SC_Timing * pTime; + pCell = Abc_SclFindInvertor(p, 0); + if ( pCell == NULL ) + return 0; + pTime = Scl_CellPinTime( pCell, 0 ); + if ( pTime == NULL ) + return 0; + return 1; +} + /**Function************************************************************* Synopsis [Returns "average" slew.] @@ -298,6 +323,8 @@ float Abc_SclComputeAverageSlew( SC_Lib * p ) if ( pCell == NULL ) return 0; pTime = Scl_CellPinTime( pCell, 0 ); + if ( pTime == NULL ) + return 0; vIndex = pTime->pCellRise->vIndex0; // slew return Vec_FltEntry( vIndex, Vec_FltSize(vIndex)/3 ); } @@ -313,7 +340,7 @@ float Abc_SclComputeAverageSlew( SC_Lib * p ) SeeAlso [] ***********************************************************************/ -void Abc_SclComputeParametersPin( SC_Lib * p, SC_Cell * pCell, int iPin, float Slew, float * pLD, float * pPD ) +int Abc_SclComputeParametersPin( SC_Lib * p, SC_Cell * pCell, int iPin, float Slew, float * pLD, float * pPD ) { SC_Pair Load0, Load1, Load2; SC_Pair ArrIn = { 0.0, 0.0 }; @@ -323,7 +350,9 @@ void Abc_SclComputeParametersPin( SC_Lib * p, SC_Cell * pCell, int iPin, float S SC_Pair ArrOut2 = { 0.0, 0.0 }; SC_Pair SlewOut = { 0.0, 0.0 }; SC_Timing * pTime = Scl_CellPinTime( pCell, iPin ); - Vec_Flt_t * vIndex = pTime->pCellRise->vIndex1; // capacitance + Vec_Flt_t * vIndex = pTime ? pTime->pCellRise->vIndex1 : NULL; // capacitance + if ( vIndex == NULL ) + return 0; // get load points Load0.rise = Load0.fall = 0.0; Load1.rise = Load1.fall = Vec_FltEntry( vIndex, 0 ); @@ -339,8 +368,9 @@ void Abc_SclComputeParametersPin( SC_Lib * p, SC_Cell * pCell, int iPin, float S *pLD = (ArrOut2.rise - ArrOut1.rise) / ((Load2.rise - Load1.rise) / SC_CellPinCap(pCell, iPin)); // get constant *pPD = ArrOut0.rise; + return 1; } -void Abc_SclComputeParametersCell( SC_Lib * p, SC_Cell * pCell, float Slew, float * pLD, float * pPD ) +int Abc_SclComputeParametersCell( SC_Lib * p, SC_Cell * pCell, float Slew, float * pLD, float * pPD ) { SC_Pin * pPin; float LD, PD, ld, pd; @@ -348,11 +378,13 @@ void Abc_SclComputeParametersCell( SC_Lib * p, SC_Cell * pCell, float Slew, floa LD = PD = ld = pd = 0; SC_CellForEachPinIn( pCell, pPin, i ) { - Abc_SclComputeParametersPin( p, pCell, i, Slew, &ld, &pd ); + if ( !Abc_SclComputeParametersPin( p, pCell, i, Slew, &ld, &pd ) ) + return 0; LD += ld; PD += pd; } *pLD = LD / Abc_MaxInt(1, pCell->n_inputs); *pPD = PD / Abc_MaxInt(1, pCell->n_inputs); + return 1; } void Abc_SclComputeParametersClass( SC_Lib * p, SC_Cell * pRepr, float Slew, float * pLD, float * pPD ) { @@ -513,13 +545,15 @@ void Abc_SclPrintCells( SC_Lib * p, float SlewInit, float Gain, int fInvOnly, in printf( "A =%8.2f ", pCell->area ); if ( pCell->n_outputs == 1 ) { - Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ); - printf( "D =%6.1f ps ", 0.01 * Gain * LD + PD ); - printf( "LD =%6.1f ps ", LD ); - printf( "PD =%6.1f ps ", PD ); - printf( "C =%5.1f ff ", SC_CellPinCapAve(pCell) ); - printf( "Cm =%5.0f ff ", SC_CellPin(pCell, pCell->n_inputs)->max_out_cap ); - printf( "Sm =%5.1f ps ", SC_CellPin(pCell, pCell->n_inputs)->max_out_slew ); + if ( Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ) ) + { + printf( "D =%6.1f ps ", 0.01 * Gain * LD + PD ); + printf( "LD =%6.1f ps ", LD ); + printf( "PD =%6.1f ps ", PD ); + printf( "C =%5.1f ff ", SC_CellPinCapAve(pCell) ); + printf( "Cm =%5.0f ff ", SC_CellPin(pCell, pCell->n_inputs)->max_out_cap ); + printf( "Sm =%5.1f ps ", SC_CellPin(pCell, pCell->n_inputs)->max_out_slew ); + } } printf( "\n" ); } -- cgit v1.2.3