Commit 1ba1e657 by Alan Mishchenko

New package to read/write a subset of Liberty for STA.

parent 95e14cd7
...@@ -30,6 +30,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -30,6 +30,7 @@ ABC_NAMESPACE_IMPL_START
static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -51,6 +52,7 @@ void Scl_Init( Abc_Frame_t * pAbc ) ...@@ -51,6 +52,7 @@ void Scl_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "SC mapping", "read_scl", Scl_CommandRead, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "read_scl", Scl_CommandRead, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "write_scl", Scl_CommandWrite, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "write_scl", Scl_CommandWrite, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "stime", Scl_CommandStime, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "stime", Scl_CommandStime, 0 );
Cmd_CommandAdd( pAbc, "SC mapping", "gsize", Scl_CommandGsize, 1 );
} }
void Scl_End( Abc_Frame_t * pAbc ) void Scl_End( Abc_Frame_t * pAbc )
{ {
...@@ -144,7 +146,7 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -144,7 +146,7 @@ int Scl_CommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage; goto usage;
if ( pAbc->pLibScl == NULL ) if ( pAbc->pLibScl == NULL )
{ {
fprintf( pAbc->Err, "There is no Liberty Library available.\n" ); fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1; return 1;
} }
// get the input file name // get the input file name
...@@ -207,7 +209,7 @@ int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -207,7 +209,7 @@ int Scl_CommandStime( Abc_Frame_t * pAbc, int argc, char **argv )
} }
if ( pAbc->pLibScl == NULL ) if ( pAbc->pLibScl == NULL )
{ {
fprintf( pAbc->Err, "There is no Liberty Library available.\n" ); fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1; return 1;
} }
...@@ -221,6 +223,59 @@ usage: ...@@ -221,6 +223,59 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( Abc_FrameReadNtk(pAbc) == NULL )
{
fprintf( pAbc->Err, "There is no current network.\n" );
return 1;
}
if ( !Abc_NtkHasMapping(Abc_FrameReadNtk(pAbc)) )
{
fprintf( pAbc->Err, "The current network is not mapped.\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc) );
return 0;
usage:
fprintf( pAbc->Err, "usage: gsize [-h]\n" );
fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -51,7 +51,8 @@ extern void Abc_SclLoad( char * pFileName, void ** ppScl ); ...@@ -51,7 +51,8 @@ extern void Abc_SclLoad( char * pFileName, void ** ppScl );
extern void Abc_SclSave( char * pFileName, void * pScl ); extern void Abc_SclSave( char * pFileName, void * pScl );
/*=== sclTime.c =============================================================*/ /*=== sclTime.c =============================================================*/
extern void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk ); extern void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk );
/*=== sclSize.c =============================================================*/
extern void Abc_SclSizingPerform( SC_Lib * pLib, void * pNtk );
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -29,6 +29,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -29,6 +29,7 @@ ABC_NAMESPACE_IMPL_START
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -40,6 +41,9 @@ ABC_NAMESPACE_IMPL_START ...@@ -40,6 +41,9 @@ ABC_NAMESPACE_IMPL_START
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclSizingPerform( SC_Lib * pLib, void * pNtk )
{
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -82,6 +82,7 @@ void Abc_SclManFindGates( SC_Man * p ) ...@@ -82,6 +82,7 @@ void Abc_SclManFindGates( SC_Man * p )
gateId = Abc_SclCellFind( p->pLib, pName ); gateId = Abc_SclCellFind( p->pLib, pName );
assert( gateId >= 0 ); assert( gateId >= 0 );
Vec_IntWriteEntry( p->vGates, i, gateId ); Vec_IntWriteEntry( p->vGates, i, gateId );
//printf( "Found gate %s\n", pName );
} }
} }
SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk ) SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk )
...@@ -133,9 +134,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -133,9 +134,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
{ {
Vec_Flt_t * vCaps = NULL; Vec_Flt_t * vCaps = NULL;
SC_WireLoad * pWL = NULL; SC_WireLoad * pWL = NULL;
int i, Entry, EntryPrev, EntryMax; int i, Entry, EntryMax;
float EntryPrev, EntryCur;
p->pWireLoadUsed = NULL; p->pWireLoadUsed = NULL;
if ( p->pLib->default_wire_load_sel ) if ( p->pLib->default_wire_load_sel && strlen(p->pLib->default_wire_load_sel) )
{ {
float Area; float Area;
SC_WireLoadSel * pWLS = NULL; SC_WireLoadSel * pWLS = NULL;
...@@ -157,7 +159,7 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -157,7 +159,7 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
if ( i == Vec_FltSize(pWLS->vAreaFrom) ) if ( i == Vec_FltSize(pWLS->vAreaFrom) )
p->pWireLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel); p->pWireLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel);
} }
else if ( p->pLib->default_wire_load ) else if ( p->pLib->default_wire_load && strlen(p->pLib->default_wire_load) )
p->pWireLoadUsed = p->pLib->default_wire_load; p->pWireLoadUsed = p->pLib->default_wire_load;
else else
{ {
...@@ -184,10 +186,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -184,10 +186,10 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
Vec_FltWriteEntry( vCaps, Entry, Vec_FltEntry(pWL->vLen, i) * pWL->cap ); Vec_FltWriteEntry( vCaps, Entry, Vec_FltEntry(pWL->vLen, i) * pWL->cap );
// reformat // reformat
EntryPrev = 0; EntryPrev = 0;
Vec_FltForEachEntry( vCaps, Entry, i ) Vec_FltForEachEntry( vCaps, EntryCur, i )
{ {
if ( Entry ) if ( EntryCur )
EntryPrev = Entry; EntryPrev = EntryCur;
else else
Vec_FltWriteEntry( vCaps, i, EntryPrev ); Vec_FltWriteEntry( vCaps, i, EntryPrev );
} }
...@@ -205,6 +207,97 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes ) ...@@ -205,6 +207,97 @@ Vec_Flt_t * Abc_SclFindWireCaps( SC_Man * p, Vec_Ptr_t * vNodes )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclComputeLoad( SC_Man * p, Vec_Ptr_t * vNodes, Vec_Flt_t * vWireCaps )
{
Abc_Obj_t * pObj, * pFanin;
int i, k;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Cell * pCell = Abc_SclObjCell( p, pObj );
Abc_ObjForEachFanin( pObj, pFanin, k )
{
SC_Pin * pPin = SC_CellPin( pCell, k );
SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
pLoad->rise += pPin->rise_cap;
pLoad->fall += pPin->fall_cap;
}
}
if ( vWireCaps )
{
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
k = Abc_MinInt( Vec_FltSize(vWireCaps)-1, Abc_ObjFanoutNum(pObj) );
pLoad->rise += Vec_FltEntry(vWireCaps, k);
pLoad->fall += Vec_FltEntry(vWireCaps, k);
}
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Abc_Obj_t * Abc_SclFindMostCritical( SC_Man * p, int * pfRise, Vec_Ptr_t * vNodes )
{
Abc_Obj_t * pObj, * pPivot = NULL;
float fMaxArr = 0;
int i;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pArr = Abc_SclObjArr( p, pObj );
if ( fMaxArr < pArr->rise ) fMaxArr = pArr->rise, *pfRise = 1, pPivot = pObj;
if ( fMaxArr < pArr->fall ) fMaxArr = pArr->fall, *pfRise = 0, pPivot = pObj;
}
assert( pPivot != NULL );
return pPivot;
}
void Abc_SclTimeNtkPrint( SC_Man * p, Vec_Ptr_t * vNodes )
{
/*
int fRise = 0;
Abc_Obj_t * pPivot = Abc_SclFindMostCritical( p, &fRise, vNodes );
printf( "Critical delay: ObjId = %d. ", Abc_ObjId(pPivot) );
printf( "Rise = %f. ", Abc_SclObjArr(p, pPivot)->rise );
printf( "Fall = %f. ", Abc_SclObjArr(p, pPivot)->fall );
printf( "\n" );
*/
Abc_Obj_t * pObj;
int i;
printf( "WireLoad model = \"%s\".\n", p->pWireLoadUsed );
printf( "Area = %f.\n", Abc_SclTotalArea( p, vNodes ) );
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
printf( "Node %6d : ", Abc_ObjId(pObj) );
printf( "TimeR = %f. ", Abc_SclObjArr(p, pObj)->rise );
printf( "RimeF = %f. ", Abc_SclObjArr(p, pObj)->fall );
printf( "SlewR = %f. ", Abc_SclObjSlew(p, pObj)->rise );
printf( "SlewF = %f. ", Abc_SclObjSlew(p, pObj)->fall );
printf( "LoadR = %f. ", Abc_SclObjLoad(p, pObj)->rise );
printf( "LoadF = %f. ", Abc_SclObjLoad(p, pObj)->fall );
printf( "\n" );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline float Abc_SclLookup( SC_Surface * p, float slew, float load ) static inline float Abc_SclLookup( SC_Surface * p, float slew, float load )
{ {
float * pIndex0, * pIndex1, * pDataS, * pDataS1; float * pIndex0, * pIndex1, * pDataS, * pDataS1;
...@@ -238,51 +331,25 @@ static inline float Abc_SclLookup( SC_Surface * p, float slew, float load ) ...@@ -238,51 +331,25 @@ static inline float Abc_SclLookup( SC_Surface * p, float slew, float load )
} }
void Abc_SclTimeGate( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) void Abc_SclTimeGate( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin )
{ {
SC_Pair * pArrIn = Abc_SclObjLoad( p, pFanin ); SC_Pair * pArrIn = Abc_SclObjArr ( p, pFanin );
SC_Pair * pSlewIn = Abc_SclObjLoad( p, pFanin ); SC_Pair * pSlewIn = Abc_SclObjSlew( p, pFanin );
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj ); SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
SC_Pair * pArrOut = Abc_SclObjLoad( p, pObj ); // modified SC_Pair * pArrOut = Abc_SclObjArr ( p, pObj ); // modified
SC_Pair * pSlewOut = Abc_SclObjLoad( p, pObj ); // modified SC_Pair * pSlewOut = Abc_SclObjSlew( p, pObj ); // modified
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non) if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
{ {
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->rise + Abc_SclLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) ); pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->rise + Abc_SclLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) ); pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) ); pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) ); pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
} }
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non) if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
{ {
pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->fall + Abc_SclLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) ); pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->fall + Abc_SclLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->rise + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) ); pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->rise + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) ); pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Abc_SclLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) ); pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Abc_SclLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
}
}
void Abc_SclComputeLoad( SC_Man * p, Vec_Ptr_t * vNodes, Vec_Flt_t * vWireCaps )
{
Abc_Obj_t * pObj, * pFanin;
int i, k;
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Cell * pCell = Abc_SclObjCell( p, pObj );
Abc_ObjForEachFanin( pObj, pFanin, k )
{
SC_Pin * pPin = SC_CellPin( pCell, k );
SC_Pair * pLoad = Abc_SclObjLoad( p, pFanin );
pLoad->rise += pPin->rise_cap;
pLoad->fall += pPin->fall_cap;
}
}
if ( vWireCaps )
{
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
k = Abc_MinInt( Vec_FltSize(vWireCaps)-1, Abc_ObjFanoutNum(pObj) );
pLoad->rise += Vec_FltEntry(vWireCaps, k);
pLoad->fall += Vec_FltEntry(vWireCaps, k);
}
} }
} }
void Abc_SclTimeNtk( SC_Man * p ) void Abc_SclTimeNtk( SC_Man * p )
...@@ -313,6 +380,8 @@ void Abc_SclTimeNtk( SC_Man * p ) ...@@ -313,6 +380,8 @@ void Abc_SclTimeNtk( SC_Man * p )
Abc_SclTimeGate( p, pTime, pObj, Abc_ObjFanin(pObj, k) ); Abc_SclTimeGate( p, pTime, pObj, Abc_ObjFanin(pObj, k) );
} }
} }
Abc_SclTimeNtkPrint( p, vNodes );
Vec_FltFree( vWireCaps );
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
} }
...@@ -327,27 +396,11 @@ void Abc_SclTimeNtk( SC_Man * p ) ...@@ -327,27 +396,11 @@ void Abc_SclTimeNtk( SC_Man * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclTimeNtkPrint( SC_Man * p )
{
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk ) void Abc_SclTimePerform( SC_Lib * pLib, void * pNtk )
{ {
SC_Man * p; SC_Man * p;
p = Abc_SclManAlloc( pLib, (Abc_Ntk_t *)pNtk ); p = Abc_SclManAlloc( pLib, (Abc_Ntk_t *)pNtk );
Abc_SclTimeNtk( p ); Abc_SclTimeNtk( p );
Abc_SclTimeNtkPrint( p );
Abc_SclManFree( p ); Abc_SclManFree( p );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment