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
......
...@@ -63,9 +63,9 @@ void Scl_Init( Abc_Frame_t * pAbc ) ...@@ -63,9 +63,9 @@ void Scl_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "topo", Scl_CommandTopo, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "topo", Scl_CommandTopo, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "minsize", Scl_CommandMinsize, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "upsize", Scl_CommandUpsize, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "upsize", Scl_CommandUpsize, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "minsize", Scl_CommandMinsize, 1 );
} }
void Scl_End( Abc_Frame_t * pAbc ) void Scl_End( Abc_Frame_t * pAbc )
{ {
...@@ -510,10 +510,73 @@ usage: ...@@ -510,10 +510,73 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Scl_CommandMinsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
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 ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) )
{
fprintf( pAbc->Err, "The current networks is not in a topo order (run \"topo\").\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclMinsizePerform( (SC_Lib *)pAbc->pLibScl, pNtk, fVerbose );
return 0;
usage:
fprintf( pAbc->Err, "usage: minsize [-vh]\n" );
fprintf( pAbc->Err, "\t downsized all gates to their minimum size\n" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv ) int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{ {
SC_SizePars Pars, * pPars = &Pars; SC_SizePars Pars, * pPars = &Pars;
int c; int c;
memset( pPars, 0, sizeof(SC_SizePars) );
pPars->nSteps = 1000000; pPars->nSteps = 1000000;
pPars->nRange = 0; pPars->nRange = 0;
pPars->nRangeF = 10; pPars->nRangeF = 10;
...@@ -623,8 +686,8 @@ usage: ...@@ -623,8 +686,8 @@ usage:
fprintf( pAbc->Err, "usage: gsize [-NWUT num] [-acpvwh]\n" ); fprintf( pAbc->Err, "usage: gsize [-NWUT num] [-acpvwh]\n" );
fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" ); fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" );
fprintf( pAbc->Err, "\t-N <num> : the number of gate-sizing steps performed [default = %d]\n", pPars->nSteps ); fprintf( pAbc->Err, "\t-N <num> : the number of gate-sizing steps performed [default = %d]\n", pPars->nSteps );
fprintf( pAbc->Err, "\t-W <num> : delay window (in percents) of near-critical COs [default = %d]\n", pPars->nRange ); fprintf( pAbc->Err, "\t-W <num> : delay window (in percent) of near-critical COs [default = %d]\n", pPars->nRange );
fprintf( pAbc->Err, "\t-U <num> : delay window (in percents) of near-critical fanins [default = %d]\n", pPars->nRangeF ); fprintf( pAbc->Err, "\t-U <num> : delay window (in percent) of near-critical fanins [default = %d]\n", pPars->nRangeF );
fprintf( pAbc->Err, "\t-T <num> : an approximate timeout, in seconds [default = %d]\n", pPars->nTimeOut ); fprintf( pAbc->Err, "\t-T <num> : an approximate timeout, in seconds [default = %d]\n", pPars->nTimeOut );
fprintf( pAbc->Err, "\t-a : try resizing all gates (not only critical) [default = %s]\n", pPars->fTryAll? "yes": "no" ); fprintf( pAbc->Err, "\t-a : try resizing all gates (not only critical) [default = %s]\n", pPars->fTryAll? "yes": "no" );
fprintf( pAbc->Err, "\t-c : toggle using wire-loads if specified [default = %s]\n", pPars->fUseWireLoads? "yes": "no" ); fprintf( pAbc->Err, "\t-c : toggle using wire-loads if specified [default = %s]\n", pPars->fUseWireLoads? "yes": "no" );
...@@ -648,18 +711,22 @@ usage: ...@@ -648,18 +711,22 @@ usage:
***********************************************************************/ ***********************************************************************/
int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
{ {
SC_UpSizePars Pars, * pPars = &Pars;
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nIters = 1000; int c;
int nIterNoChange = 50; memset( pPars, 0, sizeof(SC_UpSizePars) );
int Window = 2; pPars->nIters = 1000;
int Ratio = 10; pPars->nIterNoChange = 50;
int Notches = 10; pPars->Window = 2;
int TimeOut = 0; pPars->Ratio = 10;
int fDumpStats = 0; pPars->Notches = 20;
int c, fVerbose = 0; pPars->TimeOut = 0;
int fVeryVerbose = 0; pPars->fUseDept = 1;
pPars->fDumpStats = 0;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNTdvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNTsdvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -669,9 +736,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -669,9 +736,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
nIterNoChange = atoi(argv[globalUtilOptind]); pPars->nIters = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nIterNoChange < 0 ) if ( pPars->nIters < 0 )
goto usage; goto usage;
break; break;
case 'J': case 'J':
...@@ -680,9 +747,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -680,9 +747,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-J\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-J\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
nIters = atoi(argv[globalUtilOptind]); pPars->nIterNoChange = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nIters < 0 ) if ( pPars->nIterNoChange < 0 )
goto usage; goto usage;
break; break;
case 'W': case 'W':
...@@ -691,9 +758,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -691,9 +758,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
Window = atoi(argv[globalUtilOptind]); pPars->Window = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( Window < 0 ) if ( pPars->Window < 0 )
goto usage; goto usage;
break; break;
case 'R': case 'R':
...@@ -702,9 +769,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -702,9 +769,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-R\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-R\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
Ratio = atoi(argv[globalUtilOptind]); pPars->Ratio = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( Ratio < 0 ) if ( pPars->Ratio < 0 )
goto usage; goto usage;
break; break;
case 'N': case 'N':
...@@ -713,9 +780,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -713,9 +780,9 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
Notches = atoi(argv[globalUtilOptind]); pPars->Notches = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( Notches < 0 ) if ( pPars->Notches < 0 )
goto usage; goto usage;
break; break;
case 'T': case 'T':
...@@ -724,19 +791,22 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -724,19 +791,22 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer.\n" ); Abc_Print( -1, "Command line switch \"-T\" should be followed by a positive integer.\n" );
goto usage; goto usage;
} }
TimeOut = atoi(argv[globalUtilOptind]); pPars->TimeOut = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( TimeOut < 0 ) if ( pPars->TimeOut < 0 )
goto usage; goto usage;
break; break;
case 's':
pPars->fUseDept ^= 1;
break;
case 'd': case 'd':
fDumpStats ^= 1; pPars->fDumpStats ^= 1;
break; break;
case 'v': case 'v':
fVerbose ^= 1; pPars->fVerbose ^= 1;
break; break;
case 'w': case 'w':
fVeryVerbose ^= 1; pPars->fVeryVerbose ^= 1;
break; break;
case 'h': case 'h':
goto usage; goto usage;
...@@ -766,83 +836,22 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -766,83 +836,22 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
return 1; return 1;
} }
Abc_SclUpsizePerform( (SC_Lib *)pAbc->pLibScl, pNtk, nIters, nIterNoChange, Window, Ratio, Notches, TimeOut, fDumpStats, fVerbose, fVeryVerbose ); Abc_SclUpsizePerform( (SC_Lib *)pAbc->pLibScl, pNtk, pPars );
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: upsize [-IJWRNT num] [-dvwh]\n" ); fprintf( pAbc->Err, "usage: upsize [-IJWRNT num] [-dvwh]\n" );
fprintf( pAbc->Err, "\t selectively increases gate sizes in timing-critical regions\n" ); fprintf( pAbc->Err, "\t selectively increases gate sizes on the critical path\n" );
fprintf( pAbc->Err, "\t-I <num> : the number of upsizing iterations to perform [default = %d]\n", nIters ); fprintf( pAbc->Err, "\t-I <num> : the number of upsizing iterations to perform [default = %d]\n", pPars->nIters );
fprintf( pAbc->Err, "\t-J <num> : the number of iterations without improvement [default = %d]\n", nIterNoChange ); fprintf( pAbc->Err, "\t-J <num> : the number of iterations without improvement to stop [default = %d]\n", pPars->nIterNoChange );
fprintf( pAbc->Err, "\t-W <num> : delay window (in percents) of near-critical COs [default = %d]\n", Window ); fprintf( pAbc->Err, "\t-W <num> : delay window (in percent) of near-critical COs [default = %d]\n", pPars->Window );
fprintf( pAbc->Err, "\t-R <num> : ratio of critical nodes (in percents) to update [default = %d]\n", Ratio ); fprintf( pAbc->Err, "\t-R <num> : ratio of critical nodes (in percent) to update [default = %d]\n", pPars->Ratio );
fprintf( pAbc->Err, "\t-N <num> : limit on discrete upsizing steps at a node [default = %d]\n", Notches ); fprintf( pAbc->Err, "\t-N <num> : limit on discrete upsizing steps at a node [default = %d]\n", pPars->Notches );
fprintf( pAbc->Err, "\t-T <num> : approximate timeout in seconds [default = %d]\n", TimeOut ); fprintf( pAbc->Err, "\t-T <num> : approximate timeout in seconds [default = %d]\n", pPars->TimeOut );
fprintf( pAbc->Err, "\t-d : toggle dumping statistics into a file [default = %s]\n", fDumpStats? "yes": "no" ); fprintf( pAbc->Err, "\t-s : toggle using slack based on departure times [default = %s]\n", pPars->fUseDept? "yes": "no" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pAbc->Err, "\t-d : toggle dumping statistics into a file [default = %s]\n", pPars->fDumpStats? "yes": "no" );
fprintf( pAbc->Err, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n"); fprintf( pAbc->Err, "\t-w : toggle printing more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandMinsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
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 ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) )
{
fprintf( pAbc->Err, "The current networks is not in a topo order (run \"topo\").\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclMinsizePerform( (SC_Lib *)pAbc->pLibScl, pNtk, fVerbose );
return 0;
usage:
fprintf( pAbc->Err, "usage: minsize [-vh]\n" );
fprintf( pAbc->Err, "\t downsized all gates to their minimum size\n" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n"); fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1; return 1;
} }
......
...@@ -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 );
......
...@@ -28,8 +28,6 @@ ABC_NAMESPACE_IMPL_START ...@@ -28,8 +28,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
extern Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -100,7 +98,7 @@ Vec_Int_t * Abc_SclFindTFO( Abc_Ntk_t * p, Vec_Int_t * vPath ) ...@@ -100,7 +98,7 @@ Vec_Int_t * Abc_SclFindTFO( Abc_Ntk_t * p, Vec_Int_t * vPath )
***********************************************************************/ ***********************************************************************/
Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window ) Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window )
{ {
float fMaxArr = Abc_SclGetMaxDelay( p ) * (100.0 - Window) / 100.0; float fMaxArr = Abc_SclReadMaxDelay( p ) * (100.0 - Window) / 100.0;
Vec_Int_t * vPivots; Vec_Int_t * vPivots;
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
...@@ -123,7 +121,7 @@ Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window ) ...@@ -123,7 +121,7 @@ Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t * vPath, float fSlack ) void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t * vPath, float fSlack, int fDept )
{ {
Abc_Obj_t * pNext; Abc_Obj_t * pNext;
float fArrMax, fSlackFan; float fArrMax, fSlackFan;
...@@ -135,30 +133,40 @@ void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t ...@@ -135,30 +133,40 @@ void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t
Abc_NodeSetTravIdCurrent( pObj ); Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) ); assert( Abc_ObjIsNode(pObj) );
// compute the max arrival time of the fanins // compute the max arrival time of the fanins
fArrMax = Abc_SclGetMaxDelayNodeFanins( p, pObj ); if ( fDept )
fArrMax = p->pSlack[Abc_ObjId(pObj)];
else
fArrMax = Abc_SclGetMaxDelayNodeFanins( p, pObj );
assert( fArrMax >= 0 );
// traverse all fanins whose arrival times are within a window // traverse all fanins whose arrival times are within a window
Abc_ObjForEachFanin( pObj, pNext, i ) Abc_ObjForEachFanin( pObj, pNext, i )
{ {
fSlackFan = fSlack - (fArrMax - Abc_SclObjTimeMax(p, pNext)); if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
continue;
assert( Abc_ObjIsNode(pNext) );
if ( fDept )
fSlackFan = fSlack - (p->pSlack[Abc_ObjId(pNext)] - fArrMax);
else
fSlackFan = fSlack - (fArrMax - Abc_SclObjTimeMax(p, pNext));
if ( fSlackFan >= 0 ) if ( fSlackFan >= 0 )
Abc_SclFindCriticalNodeWindow_rec( p, pNext, vPath, fSlackFan ); Abc_SclFindCriticalNodeWindow_rec( p, pNext, vPath, fSlackFan, fDept );
} }
if ( Abc_ObjFaninNum(pObj) > 0 ) if ( Abc_ObjFaninNum(pObj) > 0 )
Vec_IntPush( vPath, Abc_ObjId(pObj) ); Vec_IntPush( vPath, Abc_ObjId(pObj) );
} }
Vec_Int_t * Abc_SclFindCriticalNodeWindow( SC_Man * p, Vec_Int_t * vPathCos, int Window ) Vec_Int_t * Abc_SclFindCriticalNodeWindow( SC_Man * p, Vec_Int_t * vPathCos, int Window, int fDept )
{ {
float fMaxArr = Abc_SclGetMaxDelay( p ); float fMaxArr = Abc_SclReadMaxDelay( p );
float fSlack = fMaxArr * Window / 100.0; float fSlackMax = fMaxArr * Window / 100.0;
Vec_Int_t * vPath = Vec_IntAlloc( 100 ); Vec_Int_t * vPath = Vec_IntAlloc( 100 );
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
Abc_NtkIncrementTravId( p->pNtk ); Abc_NtkIncrementTravId( p->pNtk );
Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i ) Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i )
{ {
float fSlackThis = fSlack - (fMaxArr - Abc_SclObjTimeMax(p, pObj)); float fSlackThis = fSlackMax - (fMaxArr - Abc_SclObjTimeMax(p, pObj));
if ( fSlackThis >= 0 ) if ( fSlackThis >= 0 )
Abc_SclFindCriticalNodeWindow_rec( p, Abc_ObjFanin0(pObj), vPath, fSlackThis ); Abc_SclFindCriticalNodeWindow_rec( p, Abc_ObjFanin0(pObj), vPath, fSlackThis, fDept );
} }
// label critical nodes // label critical nodes
Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i ) Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i )
...@@ -454,29 +462,30 @@ void Abc_SclUpsizePrint( SC_Man * p, int Iter, int win, int nPathPos, int nPathN ...@@ -454,29 +462,30 @@ void Abc_SclUpsizePrint( SC_Man * p, int Iter, int win, int nPathPos, int nPathN
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
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 ) void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_UpSizePars * pPars )
{ {
SC_Man * p; SC_Man * p;
Vec_Int_t * vPathPos = NULL; // critical POs Vec_Int_t * vPathPos = NULL; // critical POs
Vec_Int_t * vPathNodes = NULL; // critical nodes and PIs Vec_Int_t * vPathNodes = NULL; // critical nodes and PIs
Vec_Int_t * vTFO; Vec_Int_t * vTFO;
clock_t clk, nRuntimeLimit = pPars->TimeOut ? pPars->TimeOut * CLOCKS_PER_SEC + clock() : 0;
int i, win, nUpsizes = -1, nFramesNoChange = 0; int i, win, nUpsizes = -1, nFramesNoChange = 0;
int nAllPos, nAllNodes, nAllTfos, nAllUpsizes; int nAllPos, nAllNodes, nAllTfos, nAllUpsizes;
clock_t clk;
if ( fVerbose ) if ( pPars->fVerbose )
{ {
printf( "Sizing parameters: " ); printf( "Sizing parameters: " );
printf( "Iters =%4d. ", nIters ); printf( "Iters =%5d. ", pPars->nIters );
printf( "Time window =%3d %%. ", Window ); printf( "Time window =%3d %%. ", pPars->Window );
printf( "Update ratio =%3d %%. ", Ratio ); printf( "Update ratio =%3d %%. ", pPars->Ratio );
printf( "Max upsize steps =%2d. ", Notches ); printf( "Max steps =%3d. ", pPars->Notches );
printf( "Timeout =%3d sec", TimeOut ); printf( "UseDept =%2d. ", pPars->fUseDept );
printf( "Timeout =%4d sec", pPars->TimeOut );
printf( "\n" ); printf( "\n" );
} }
// prepare the manager; collect init stats // prepare the manager; collect init stats
p = Abc_SclManStart( pLib, pNtk, 1 ); p = Abc_SclManStart( pLib, pNtk, 1, pPars->fUseDept );
p->timeTotal = clock(); p->timeTotal = clock();
assert( p->vGatesBest == NULL ); assert( p->vGatesBest == NULL );
p->vGatesBest = Vec_IntDup( p->vGates ); p->vGatesBest = Vec_IntDup( p->vGates );
...@@ -484,19 +493,19 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte ...@@ -484,19 +493,19 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
// perform upsizing // perform upsizing
nAllPos = nAllNodes = nAllTfos = nAllUpsizes = 0; nAllPos = nAllNodes = nAllTfos = nAllUpsizes = 0;
for ( i = 0; i < nIters; i++ ) for ( i = 0; i < pPars->nIters; i++ )
{ {
for ( win = Window; win <= 100; win *= 2 ) for ( win = pPars->Window; win <= 100; win *= 2 )
{ {
// detect critical path // detect critical path
clk = clock(); clk = clock();
vPathPos = Abc_SclFindCriticalCoWindow( p, win ); vPathPos = Abc_SclFindCriticalCoWindow( p, win );
vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, win ); vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, win, pPars->fUseDept );
p->timeCone += clock() - clk; p->timeCone += clock() - clk;
// selectively upsize the nodes // selectively upsize the nodes
clk = clock(); clk = clock();
nUpsizes = Abc_SclFindUpsizes( p, vPathNodes, Ratio, Notches, i ); nUpsizes = Abc_SclFindUpsizes( p, vPathNodes, pPars->Ratio, pPars->Notches, i );
p->timeSize += clock() - clk; p->timeSize += clock() - clk;
// unmark critical path // unmark critical path
...@@ -514,15 +523,21 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte ...@@ -514,15 +523,21 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
// update timing information // update timing information
clk = clock(); clk = clock();
// vTFO = Abc_SclFindTFO( p->pNtk, vPathNodes ); if ( pPars->fUseDept )
// Abc_SclTimeCone( p, vTFO ); {
vTFO = Vec_IntAlloc( 0 ); vTFO = Vec_IntAlloc( 0 );
Abc_SclTimeNtkRecompute( p, NULL, NULL, 0 ); Abc_SclTimeNtkRecompute( p, NULL, NULL, pPars->fUseDept );
}
else
{
vTFO = Abc_SclFindTFO( p->pNtk, vPathNodes );
Abc_SclTimeCone( p, vTFO );
}
p->timeTime += clock() - clk; p->timeTime += clock() - clk;
// Abc_SclUpsizePrintDiffs( p, pLib, pNtk ); // Abc_SclUpsizePrintDiffs( p, pLib, pNtk );
// save the best network // save the best network
p->MaxDelay = Abc_SclGetMaxDelay( p ); p->MaxDelay = Abc_SclReadMaxDelay( p );
if ( p->BestDelay > p->MaxDelay ) if ( p->BestDelay > p->MaxDelay )
{ {
p->BestDelay = p->MaxDelay; p->BestDelay = p->MaxDelay;
...@@ -531,27 +546,35 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte ...@@ -531,27 +546,35 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
} }
else else
nFramesNoChange++; nFramesNoChange++;
if ( nFramesNoChange > nIterNoChange ) if ( nFramesNoChange > pPars->nIterNoChange )
{
Vec_IntFree( vPathPos );
Vec_IntFree( vPathNodes );
Vec_IntFree( vTFO );
break; break;
}
// report and cleanup // report and cleanup
Abc_SclUpsizePrint( p, i, win, Vec_IntSize(vPathPos), Vec_IntSize(vPathNodes), nUpsizes, Vec_IntSize(vTFO), fVeryVerbose ); //|| (i == nIters-1) ); Abc_SclUpsizePrint( p, i, win, Vec_IntSize(vPathPos), Vec_IntSize(vPathNodes), nUpsizes, Vec_IntSize(vTFO), pPars->fVeryVerbose ); //|| (i == nIters-1) );
nAllPos += Vec_IntSize(vPathPos); nAllPos += Vec_IntSize(vPathPos);
nAllNodes += Vec_IntSize(vPathNodes); nAllNodes += Vec_IntSize(vPathNodes);
nAllTfos += Vec_IntSize(vTFO); nAllTfos += Vec_IntSize(vTFO);
nAllUpsizes += nUpsizes; nAllUpsizes += nUpsizes;
Vec_IntFree( vPathPos ); Vec_IntFree( vPathPos );
Vec_IntFree( vPathNodes ); Vec_IntFree( vPathNodes );
Vec_IntFree( vTFO ); Vec_IntFree( vTFO );
// check timeout
if ( nRuntimeLimit && clock() > nRuntimeLimit )
break;
} }
// update for best gates and recompute timing // update for best gates and recompute timing
ABC_SWAP( Vec_Int_t *, p->vGatesBest, p->vGates ); ABC_SWAP( Vec_Int_t *, p->vGatesBest, p->vGates );
Abc_SclTimeNtkRecompute( p, &p->SumArea, &p->MaxDelay, 0 ); Abc_SclTimeNtkRecompute( p, &p->SumArea, &p->MaxDelay, 0 );
if ( fVerbose ) if ( pPars->fVerbose )
Abc_SclUpsizePrint( p, i, Window, nAllPos/i, nAllNodes/i, nAllUpsizes/i, nAllTfos/i, 1 ); Abc_SclUpsizePrint( p, i, pPars->Window, nAllPos/(i?i:1), nAllNodes/(i?i:1), nAllUpsizes/(i?i:1), nAllTfos/(i?i:1), 1 );
// report runtime // report runtime
p->timeTotal = clock() - p->timeTotal; p->timeTotal = clock() - p->timeTotal;
if ( fVerbose ) if ( pPars->fVerbose )
{ {
p->timeOther = p->timeTotal - p->timeCone - p->timeSize - p->timeTime; p->timeOther = p->timeTotal - p->timeCone - p->timeSize - p->timeTime;
ABC_PRTP( "Runtime: Critical path", p->timeCone, p->timeTotal ); ABC_PRTP( "Runtime: Critical path", p->timeCone, p->timeTotal );
...@@ -560,8 +583,10 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte ...@@ -560,8 +583,10 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal ); ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal );
ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal ); ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal );
} }
if ( fDumpStats ) if ( pPars->fDumpStats )
Abc_SclDumpStats( p, "stats2.txt", p->timeTotal ); Abc_SclDumpStats( p, "stats2.txt", p->timeTotal );
if ( nRuntimeLimit && clock() > nRuntimeLimit )
printf( "Gate sizing timed out at %d seconds.\n", pPars->TimeOut );
// save the result and quit // save the result and quit
Abc_SclManSetGates( pLib, pNtk, p->vGates ); // updates gate pointers Abc_SclManSetGates( pLib, pNtk, p->vGates ); // updates gate pointers
......
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