Commit 1e7ea2ca by Alan Mishchenko

Improvements to gate sizing.

parent daeffe79
...@@ -436,7 +436,7 @@ void Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk ) ...@@ -436,7 +436,7 @@ void Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk )
int i, k, Num; int i, k, Num;
if ( pNtk->pDesign == NULL || pNtk->pDesign->vModules == NULL ) if ( pNtk->pDesign == NULL || pNtk->pDesign->vModules == NULL )
{ {
printf( "There is no hierarchy information.\n" ); // printf( "There is no hierarchy information.\n" );
return; return;
} }
// sort models by name // sort models by name
......
...@@ -74,6 +74,21 @@ struct SC_SizePars_ ...@@ -74,6 +74,21 @@ struct SC_SizePars_
int fVeryVerbose; int fVeryVerbose;
}; };
typedef struct SC_UpSizePars_ SC_UpSizePars;
struct SC_UpSizePars_
{
int nIters;
int nIterNoChange;
int Window;
int Ratio;
int Notches;
int TimeOut;
int fUseDept;
int fDumpStats;
int fVerbose;
int fVeryVerbose;
};
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS /// /// STRUCTURE DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -439,7 +454,7 @@ extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fU ...@@ -439,7 +454,7 @@ extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fU
/*=== sclSize.c ===============================================================*/ /*=== sclSize.c ===============================================================*/
extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * p ); extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * p );
/*=== sclUpsize.c ===============================================================*/ /*=== sclUpsize.c ===============================================================*/
extern void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIterNoChange, int Window, int Ratio, int Notches, int TimeOut, int fDumpStats, int fVerbose, int fVeryVerbose ); extern void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_UpSizePars * pPars );
/*=== sclUtil.c ===============================================================*/ /*=== sclUtil.c ===============================================================*/
extern void Abc_SclHashCells( SC_Lib * p ); extern void Abc_SclHashCells( SC_Lib * p );
extern int Abc_SclCellFind( SC_Lib * p, char * pName ); extern int Abc_SclCellFind( SC_Lib * p, char * pName );
......
...@@ -64,6 +64,7 @@ struct SC_Man_ ...@@ -64,6 +64,7 @@ struct SC_Man_
SC_Pair * pSlews; // slews for each gate SC_Pair * pSlews; // slews for each gate
SC_Pair * pTimes2; // arrivals for each gate SC_Pair * pTimes2; // arrivals for each gate
SC_Pair * pSlews2; // slews for each gate SC_Pair * pSlews2; // slews for each gate
float * pSlack; // slacks for each gate
Vec_Flt_t * vTimesOut; // output arrival times Vec_Flt_t * vTimesOut; // output arrival times
Vec_Que_t * vQue; // outputs by their time Vec_Que_t * vQue; // outputs by their time
SC_WireLoad * pWLoadUsed; // name of the used WireLoad model SC_WireLoad * pWLoadUsed; // name of the used WireLoad model
...@@ -147,6 +148,7 @@ static inline SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk ) ...@@ -147,6 +148,7 @@ static inline SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk )
p->pSlews = ABC_CALLOC( SC_Pair, p->nObjs ); p->pSlews = ABC_CALLOC( SC_Pair, p->nObjs );
p->pTimes2 = ABC_CALLOC( SC_Pair, p->nObjs ); p->pTimes2 = ABC_CALLOC( SC_Pair, p->nObjs );
p->pSlews2 = ABC_CALLOC( SC_Pair, p->nObjs ); p->pSlews2 = ABC_CALLOC( SC_Pair, p->nObjs );
p->pSlack = ABC_FALLOC( float, p->nObjs );
p->vTimesOut = Vec_FltStart( Abc_NtkCoNum(pNtk) ); p->vTimesOut = Vec_FltStart( Abc_NtkCoNum(pNtk) );
p->vQue = Vec_QueAlloc( Abc_NtkCoNum(pNtk) ); p->vQue = Vec_QueAlloc( Abc_NtkCoNum(pNtk) );
Vec_QueSetCosts( p->vQue, Vec_FltArray(p->vTimesOut) ); Vec_QueSetCosts( p->vQue, Vec_FltArray(p->vTimesOut) );
...@@ -182,6 +184,7 @@ static inline void Abc_SclManFree( SC_Man * p ) ...@@ -182,6 +184,7 @@ static inline void Abc_SclManFree( SC_Man * p )
ABC_FREE( p->pSlews ); ABC_FREE( p->pSlews );
ABC_FREE( p->pTimes2 ); ABC_FREE( p->pTimes2 );
ABC_FREE( p->pSlews2 ); ABC_FREE( p->pSlews2 );
ABC_FREE( p->pSlack );
ABC_FREE( p ); ABC_FREE( p );
} }
static inline void Abc_SclManCleanTime( SC_Man * p ) static inline void Abc_SclManCleanTime( SC_Man * p )
...@@ -300,6 +303,10 @@ static inline float Abc_SclGetMaxDelayNodeFanins( SC_Man * p, Abc_Obj_t * pNode ...@@ -300,6 +303,10 @@ static inline float Abc_SclGetMaxDelayNodeFanins( SC_Man * p, Abc_Obj_t * pNode
fMaxArr = Abc_MaxFloat( fMaxArr, Abc_SclObjTimeMax(p, pObj) ); fMaxArr = Abc_MaxFloat( fMaxArr, Abc_SclObjTimeMax(p, pObj) );
return fMaxArr; return fMaxArr;
} }
static inline float Abc_SclReadMaxDelay( SC_Man * p )
{
return Abc_SclObjTimeMax( p, Abc_NtkPo(p->pNtk, Vec_QueTop(p->vQue)) );
}
/**Function************************************************************* /**Function*************************************************************
...@@ -340,8 +347,8 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, clock_t Time ...@@ -340,8 +347,8 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, clock_t Time
fprintf( pTable, "%d ", Abc_NtkPiNum(p->pNtk) ); fprintf( pTable, "%d ", Abc_NtkPiNum(p->pNtk) );
fprintf( pTable, "%d ", Abc_NtkPoNum(p->pNtk) ); fprintf( pTable, "%d ", Abc_NtkPoNum(p->pNtk) );
fprintf( pTable, "%d ", Abc_NtkNodeNum(p->pNtk) ); fprintf( pTable, "%d ", Abc_NtkNodeNum(p->pNtk) );
fprintf( pTable, "%d ", (int)p->SumArea0 ); fprintf( pTable, "%d ", (int)p->SumArea );
fprintf( pTable, "%d ", (int)p->MaxDelay0 ); fprintf( pTable, "%d ", (int)SC_LibTimePs(p->pLib, p->MaxDelay) );
fprintf( pTable, "%.2f ", 1.0*Time/CLOCKS_PER_SEC ); fprintf( pTable, "%.2f ", 1.0*Time/CLOCKS_PER_SEC );
fprintf( pTable, "\n" ); fprintf( pTable, "\n" );
fclose( pTable ); fclose( pTable );
...@@ -352,7 +359,7 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, clock_t Time ...@@ -352,7 +359,7 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, clock_t Time
extern Abc_Obj_t * Abc_SclFindCriticalCo( SC_Man * p, int * pfRise ); extern Abc_Obj_t * Abc_SclFindCriticalCo( SC_Man * p, int * pfRise );
extern Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t * pNode ); extern Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t * pNode );
extern void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fShort ); extern void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fShort );
extern SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads ); extern SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, int fDept );
extern void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ); extern void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone );
extern void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse ); extern void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse );
/*=== sclTime.c =============================================================*/ /*=== sclTime.c =============================================================*/
......
...@@ -67,7 +67,8 @@ Vec_Int_t * Abc_SclCollectNodes( Abc_Ntk_t * p ) ...@@ -67,7 +67,8 @@ Vec_Int_t * Abc_SclCollectNodes( Abc_Ntk_t * p )
***********************************************************************/ ***********************************************************************/
Vec_Int_t * Abc_SclFindCriticalCoRange( SC_Man * p, int Range ) Vec_Int_t * Abc_SclFindCriticalCoRange( SC_Man * p, int Range )
{ {
float fMaxArr = Abc_SclGetMaxDelay( p ) * (100.0 - Range) / 100.0; // float fMaxArr = Abc_SclGetMaxDelay( p ) * (100.0 - Range) / 100.0;
float fMaxArr = Abc_SclReadMaxDelay( p ) * (100.0 - Range) / 100.0;
Vec_Int_t * vPivots; Vec_Int_t * vPivots;
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
...@@ -333,7 +334,7 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int nCone, int fUpsize, ...@@ -333,7 +334,7 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int nCone, int fUpsize,
printf( "%5d :", iStep ); printf( "%5d :", iStep );
printf( "%7d ", Abc_ObjId(pObj) ); printf( "%7d ", Abc_ObjId(pObj) );
printf( "%-12s-> %-12s ", pOld->pName, pNew->pName ); printf( "%-12s-> %-12s ", pOld->pName, pNew->pName );
printf( "d =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) ); printf( "d =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclReadMaxDelay(p)) );
printf( "a =%10.2f ", p->SumArea ); printf( "a =%10.2f ", p->SumArea );
printf( "n =%5d ", nCone ); printf( "n =%5d ", nCone );
// Abc_PrintTime( 1, "Time", clock() - p->timeTotal ); // Abc_PrintTime( 1, "Time", clock() - p->timeTotal );
...@@ -365,7 +366,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars ...@@ -365,7 +366,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
Abc_Obj_t * pBest; Abc_Obj_t * pBest;
clock_t nRuntimeLimit = pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + clock() : 0; clock_t nRuntimeLimit = pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + clock() : 0;
int r, i, nNodes, nCones = 0, nDownSize = 0; int r, i, nNodes, nCones = 0, nDownSize = 0;
p = Abc_SclManStart( pLib, pNtk, pPars->fUseWireLoads ); p = Abc_SclManStart( pLib, pNtk, pPars->fUseWireLoads, 0 );
p->timeTotal = clock(); p->timeTotal = clock();
if ( pPars->fPrintCP ) if ( pPars->fPrintCP )
Abc_SclTimeNtkPrint( p, 0, 0 ); Abc_SclTimeNtkPrint( p, 0, 0 );
...@@ -375,7 +376,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars ...@@ -375,7 +376,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
{ {
// printf( "%5d : ", 0 ); // printf( "%5d : ", 0 );
printf( "Starting parameters of current mapping: " ); printf( "Starting parameters of current mapping: " );
printf( "d =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) ); printf( "d =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclReadMaxDelay(p)) );
printf( "a =%10.2f ", p->SumArea ); printf( "a =%10.2f ", p->SumArea );
printf( " " ); printf( " " );
Abc_PrintTime( 1, "Time", clock() - p->timeTotal ); Abc_PrintTime( 1, "Time", clock() - p->timeTotal );
...@@ -458,7 +459,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars ...@@ -458,7 +459,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
printf( "\n" ); printf( "\n" );
} }
p->MaxDelay = Abc_SclGetMaxDelay(p); p->MaxDelay = Abc_SclReadMaxDelay(p);
if ( pPars->fPrintCP ) if ( pPars->fPrintCP )
Abc_SclTimeNtkPrint( p, 0, 0 ); Abc_SclTimeNtkPrint( p, 0, 0 );
if ( nRuntimeLimit && clock() > nRuntimeLimit ) if ( nRuntimeLimit && clock() > nRuntimeLimit )
......
...@@ -226,7 +226,7 @@ void Abc_SclDeptFanin( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_ ...@@ -226,7 +226,7 @@ void Abc_SclDeptFanin( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_
pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) ); pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->fall + Abc_SclLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
} }
} }
void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept ) void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept, float D )
{ {
SC_Timings * pRTime; SC_Timings * pRTime;
SC_Timing * pTime; SC_Timing * pTime;
...@@ -256,6 +256,8 @@ void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept ) ...@@ -256,6 +256,8 @@ void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept )
else else
Abc_SclTimeFanin( p, pTime, pObj, Abc_ObjFanin(pObj, k) ); Abc_SclTimeFanin( p, pTime, pObj, Abc_ObjFanin(pObj, k) );
} }
if ( fDept )
p->pSlack[Abc_ObjId(pObj)] = Abc_MaxFloat( 0.0, Abc_SclObjSlack(p, pObj, D) );
} }
void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ) void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone )
{ {
...@@ -269,7 +271,7 @@ void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ) ...@@ -269,7 +271,7 @@ void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone )
printf( " Updating node %d with gate %s\n", Abc_ObjId(pObj), Abc_SclObjCell(p, pObj)->pName ); printf( " Updating node %d with gate %s\n", Abc_ObjId(pObj), Abc_SclObjCell(p, pObj)->pName );
if ( fVerbose && Abc_ObjIsNode(pObj) ) if ( fVerbose && Abc_ObjIsNode(pObj) )
printf( " before (%6.1f ps %6.1f ps) ", Abc_SclObjTimePs(p, pObj, 1), Abc_SclObjTimePs(p, pObj, 0) ); printf( " before (%6.1f ps %6.1f ps) ", Abc_SclObjTimePs(p, pObj, 1), Abc_SclObjTimePs(p, pObj, 0) );
Abc_SclTimeNode( p, pObj, 0 ); Abc_SclTimeNode( p, pObj, 0, 0 );
if ( fVerbose && Abc_ObjIsNode(pObj) ) if ( fVerbose && Abc_ObjIsNode(pObj) )
printf( "after (%6.1f ps %6.1f ps)\n", Abc_SclObjTimePs(p, pObj, 1), Abc_SclObjTimePs(p, pObj, 0) ); printf( "after (%6.1f ps %6.1f ps)\n", Abc_SclObjTimePs(p, pObj, 1), Abc_SclObjTimePs(p, pObj, 0) );
} }
...@@ -277,27 +279,26 @@ void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ) ...@@ -277,27 +279,26 @@ void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone )
void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse ) void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
float D;
int i; int i;
Abc_SclComputeLoad( p ); Abc_SclComputeLoad( p );
Abc_SclManCleanTime( p ); Abc_SclManCleanTime( p );
Abc_NtkForEachNode1( p->pNtk, pObj, i ) Abc_NtkForEachNode1( p->pNtk, pObj, i )
Abc_SclTimeNode( p, pObj, 0 ); Abc_SclTimeNode( p, pObj, 0, 0 );
if ( fReverse )
Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
Abc_SclTimeNode( p, pObj, 1 );
Abc_NtkForEachCo( p->pNtk, pObj, i ) Abc_NtkForEachCo( p->pNtk, pObj, i )
{ {
Abc_SclObjDupFanin( p, pObj ); Abc_SclObjDupFanin( p, pObj );
Vec_FltWriteEntry( p->vTimesOut, i, Abc_SclObjTimeMax(p, pObj) ); Vec_FltWriteEntry( p->vTimesOut, i, Abc_SclObjTimeMax(p, pObj) );
Vec_QueUpdate( p->vQue, i ); Vec_QueUpdate( p->vQue, i );
} }
// Vec_FltClear( p->vTimesOut ); D = Abc_SclReadMaxDelay( p );
// Abc_NtkForEachCo( p->pNtk, pObj, i )
// Vec_FltPush( p->vTimesOut, Abc_SclObjTimeMax(p, pObj) );
if ( pArea ) if ( pArea )
*pArea = Abc_SclGetTotalArea( p ); *pArea = Abc_SclGetTotalArea( p );
if ( pDelay ) if ( pDelay )
*pDelay = Abc_SclGetMaxDelay( p ); *pDelay = D;
if ( fReverse )
Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
Abc_SclTimeNode( p, pObj, 1, D );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -311,14 +312,14 @@ void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fRe ...@@ -311,14 +312,14 @@ void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fRe
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads ) SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, int fDept )
{ {
SC_Man * p = Abc_SclManAlloc( pLib, pNtk ); SC_Man * p = Abc_SclManAlloc( pLib, pNtk );
assert( p->vGates == NULL ); assert( p->vGates == NULL );
p->vGates = Abc_SclManFindGates( pLib, pNtk ); p->vGates = Abc_SclManFindGates( pLib, pNtk );
if ( fUseWireLoads ) if ( fUseWireLoads )
p->pWLoadUsed = Abc_SclFindWireLoadModel( pLib, Abc_SclGetTotalArea(p) ); p->pWLoadUsed = Abc_SclFindWireLoadModel( pLib, Abc_SclGetTotalArea(p) );
Abc_SclTimeNtkRecompute( p, &p->SumArea0, &p->MaxDelay0, 0 ); Abc_SclTimeNtkRecompute( p, &p->SumArea0, &p->MaxDelay0, fDept );
p->SumArea = p->SumArea0; p->SumArea = p->SumArea0;
return p; return p;
} }
...@@ -337,7 +338,7 @@ SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads ) ...@@ -337,7 +338,7 @@ SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads )
void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, int fShowAll, int fShort, int fDumpStats ) void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, int fShowAll, int fShort, int fDumpStats )
{ {
SC_Man * p; SC_Man * p;
p = Abc_SclManStart( pLib, pNtk, fUseWireLoads ); p = Abc_SclManStart( pLib, pNtk, fUseWireLoads, 1 );
Abc_SclTimeNtkPrint( p, fShowAll, fShort ); Abc_SclTimeNtkPrint( p, fShowAll, fShort );
if ( fDumpStats ) if ( fDumpStats )
Abc_SclDumpStats( p, "stats.txt", 0 ); Abc_SclDumpStats( p, "stats.txt", 0 );
......
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