summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-10-09 21:14:32 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-10-09 21:14:32 -0700
commit1e7ea2ca459184461c1461fb13e7fd54e0a467b8 (patch)
tree682ef972611a0d6032359de9a159b1fcd0a8c517
parentdaeffe791cb2f6690a23f4cf4d0d3101a5ac54b5 (diff)
downloadabc-1e7ea2ca459184461c1461fb13e7fd54e0a467b8.tar.gz
abc-1e7ea2ca459184461c1461fb13e7fd54e0a467b8.tar.bz2
abc-1e7ea2ca459184461c1461fb13e7fd54e0a467b8.zip
Improvements to gate sizing.
-rw-r--r--src/base/abc/abcHie.c2
-rw-r--r--src/map/scl/scl.c211
-rw-r--r--src/map/scl/sclInt.h17
-rw-r--r--src/map/scl/sclMan.h13
-rw-r--r--src/map/scl/sclSize.c11
-rw-r--r--src/map/scl/sclTime.c27
-rw-r--r--src/map/scl/sclUpsize.c103
7 files changed, 221 insertions, 163 deletions
diff --git a/src/base/abc/abcHie.c b/src/base/abc/abcHie.c
index 73b08fcc..886056e2 100644
--- a/src/base/abc/abcHie.c
+++ b/src/base/abc/abcHie.c
@@ -436,7 +436,7 @@ void Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk )
int i, k, Num;
if ( pNtk->pDesign == NULL || pNtk->pDesign->vModules == NULL )
{
- printf( "There is no hierarchy information.\n" );
+// printf( "There is no hierarchy information.\n" );
return;
}
// sort models by name
diff --git a/src/map/scl/scl.c b/src/map/scl/scl.c
index fb11311f..f9d88c45 100644
--- a/src/map/scl/scl.c
+++ b/src/map/scl/scl.c
@@ -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", "topo", Scl_CommandTopo, 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", "upsize", Scl_CommandUpsize, 1 );
- Cmd_CommandAdd( pAbc, "SCL mapping", "minsize", Scl_CommandMinsize, 1 );
}
void Scl_End( Abc_Frame_t * pAbc )
{
@@ -510,10 +510,73 @@ usage:
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 )
{
SC_SizePars Pars, * pPars = &Pars;
int c;
+ memset( pPars, 0, sizeof(SC_SizePars) );
pPars->nSteps = 1000000;
pPars->nRange = 0;
pPars->nRangeF = 10;
@@ -623,8 +686,8 @@ usage:
fprintf( pAbc->Err, "usage: gsize [-NWUT num] [-acpvwh]\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-W <num> : delay window (in percents) 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-W <num> : delay window (in percent) of near-critical COs [default = %d]\n", pPars->nRange );
+ 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-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" );
@@ -648,18 +711,22 @@ usage:
***********************************************************************/
int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
+ SC_UpSizePars Pars, * pPars = &Pars;
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
- int nIters = 1000;
- int nIterNoChange = 50;
- int Window = 2;
- int Ratio = 10;
- int Notches = 10;
- int TimeOut = 0;
- int fDumpStats = 0;
- int c, fVerbose = 0;
- int fVeryVerbose = 0;
+ int c;
+ memset( pPars, 0, sizeof(SC_UpSizePars) );
+ pPars->nIters = 1000;
+ pPars->nIterNoChange = 50;
+ pPars->Window = 2;
+ pPars->Ratio = 10;
+ pPars->Notches = 20;
+ pPars->TimeOut = 0;
+ pPars->fUseDept = 1;
+ pPars->fDumpStats = 0;
+ pPars->fVerbose = 0;
+ pPars->fVeryVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNTdvwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNTsdvwh" ) ) != EOF )
{
switch ( c )
{
@@ -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" );
goto usage;
}
- nIterNoChange = atoi(argv[globalUtilOptind]);
+ pPars->nIters = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( nIterNoChange < 0 )
+ if ( pPars->nIters < 0 )
goto usage;
break;
case 'J':
@@ -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" );
goto usage;
}
- nIters = atoi(argv[globalUtilOptind]);
+ pPars->nIterNoChange = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( nIters < 0 )
+ if ( pPars->nIterNoChange < 0 )
goto usage;
break;
case 'W':
@@ -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" );
goto usage;
}
- Window = atoi(argv[globalUtilOptind]);
+ pPars->Window = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( Window < 0 )
+ if ( pPars->Window < 0 )
goto usage;
break;
case 'R':
@@ -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" );
goto usage;
}
- Ratio = atoi(argv[globalUtilOptind]);
+ pPars->Ratio = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( Ratio < 0 )
+ if ( pPars->Ratio < 0 )
goto usage;
break;
case 'N':
@@ -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" );
goto usage;
}
- Notches = atoi(argv[globalUtilOptind]);
+ pPars->Notches = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( Notches < 0 )
+ if ( pPars->Notches < 0 )
goto usage;
break;
case 'T':
@@ -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" );
goto usage;
}
- TimeOut = atoi(argv[globalUtilOptind]);
+ pPars->TimeOut = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( TimeOut < 0 )
+ if ( pPars->TimeOut < 0 )
goto usage;
break;
+ case 's':
+ pPars->fUseDept ^= 1;
+ break;
case 'd':
- fDumpStats ^= 1;
+ pPars->fDumpStats ^= 1;
break;
case 'v':
- fVerbose ^= 1;
+ pPars->fVerbose ^= 1;
break;
case 'w':
- fVeryVerbose ^= 1;
+ pPars->fVeryVerbose ^= 1;
break;
case 'h':
goto usage;
@@ -766,83 +836,22 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
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;
usage:
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-I <num> : the number of upsizing iterations to perform [default = %d]\n", nIters );
- fprintf( pAbc->Err, "\t-J <num> : the number of iterations without improvement [default = %d]\n", nIterNoChange );
- fprintf( pAbc->Err, "\t-W <num> : delay window (in percents) of near-critical COs [default = %d]\n", Window );
- fprintf( pAbc->Err, "\t-R <num> : ratio of critical nodes (in percents) to update [default = %d]\n", Ratio );
- fprintf( pAbc->Err, "\t-N <num> : limit on discrete upsizing steps at a node [default = %d]\n", Notches );
- fprintf( pAbc->Err, "\t-T <num> : approximate timeout in seconds [default = %d]\n", TimeOut );
- fprintf( pAbc->Err, "\t-d : toggle dumping statistics into a file [default = %s]\n", fDumpStats? "yes": "no" );
- fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pAbc->Err, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pAbc->Err, "\t-h : print the command usage\n");
- 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 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", pPars->nIters );
+ 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 percent) of near-critical COs [default = %d]\n", pPars->Window );
+ 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", pPars->Notches );
+ fprintf( pAbc->Err, "\t-T <num> : approximate timeout in seconds [default = %d]\n", pPars->TimeOut );
+ fprintf( pAbc->Err, "\t-s : toggle using slack based on departure times [default = %s]\n", pPars->fUseDept? "yes": "no" );
+ fprintf( pAbc->Err, "\t-d : toggle dumping statistics into a file [default = %s]\n", pPars->fDumpStats? "yes": "no" );
+ fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ fprintf( pAbc->Err, "\t-w : toggle printing more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1;
}
diff --git a/src/map/scl/sclInt.h b/src/map/scl/sclInt.h
index da997d98..5a9336d8 100644
--- a/src/map/scl/sclInt.h
+++ b/src/map/scl/sclInt.h
@@ -74,6 +74,21 @@ struct SC_SizePars_
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 ///
////////////////////////////////////////////////////////////////////////
@@ -439,7 +454,7 @@ extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fU
/*=== sclSize.c ===============================================================*/
extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * p );
/*=== 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 ===============================================================*/
extern void Abc_SclHashCells( SC_Lib * p );
extern int Abc_SclCellFind( SC_Lib * p, char * pName );
diff --git a/src/map/scl/sclMan.h b/src/map/scl/sclMan.h
index c8fb2ebd..155dccc4 100644
--- a/src/map/scl/sclMan.h
+++ b/src/map/scl/sclMan.h
@@ -64,6 +64,7 @@ struct SC_Man_
SC_Pair * pSlews; // slews for each gate
SC_Pair * pTimes2; // arrivals for each gate
SC_Pair * pSlews2; // slews for each gate
+ float * pSlack; // slacks for each gate
Vec_Flt_t * vTimesOut; // output arrival times
Vec_Que_t * vQue; // outputs by their time
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 )
p->pSlews = ABC_CALLOC( SC_Pair, p->nObjs );
p->pTimes2 = 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->vQue = Vec_QueAlloc( Abc_NtkCoNum(pNtk) );
Vec_QueSetCosts( p->vQue, Vec_FltArray(p->vTimesOut) );
@@ -182,6 +184,7 @@ static inline void Abc_SclManFree( SC_Man * p )
ABC_FREE( p->pSlews );
ABC_FREE( p->pTimes2 );
ABC_FREE( p->pSlews2 );
+ ABC_FREE( p->pSlack );
ABC_FREE( 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
fMaxArr = Abc_MaxFloat( fMaxArr, Abc_SclObjTimeMax(p, pObj) );
return fMaxArr;
}
+static inline float Abc_SclReadMaxDelay( SC_Man * p )
+{
+ return Abc_SclObjTimeMax( p, Abc_NtkPo(p->pNtk, Vec_QueTop(p->vQue)) );
+}
/**Function*************************************************************
@@ -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_NtkPoNum(p->pNtk) );
fprintf( pTable, "%d ", Abc_NtkNodeNum(p->pNtk) );
- fprintf( pTable, "%d ", (int)p->SumArea0 );
- fprintf( pTable, "%d ", (int)p->MaxDelay0 );
+ fprintf( pTable, "%d ", (int)p->SumArea );
+ fprintf( pTable, "%d ", (int)SC_LibTimePs(p->pLib, p->MaxDelay) );
fprintf( pTable, "%.2f ", 1.0*Time/CLOCKS_PER_SEC );
fprintf( pTable, "\n" );
fclose( pTable );
@@ -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_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t * pNode );
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_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse );
/*=== sclTime.c =============================================================*/
diff --git a/src/map/scl/sclSize.c b/src/map/scl/sclSize.c
index 45b0bcd2..f7bb9371 100644
--- a/src/map/scl/sclSize.c
+++ b/src/map/scl/sclSize.c
@@ -67,7 +67,8 @@ Vec_Int_t * Abc_SclCollectNodes( Abc_Ntk_t * p )
***********************************************************************/
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;
Abc_Obj_t * pObj;
int i;
@@ -333,7 +334,7 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int nCone, int fUpsize,
printf( "%5d :", iStep );
printf( "%7d ", Abc_ObjId(pObj) );
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( "n =%5d ", nCone );
// Abc_PrintTime( 1, "Time", clock() - p->timeTotal );
@@ -365,7 +366,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
Abc_Obj_t * pBest;
clock_t nRuntimeLimit = pPars->nTimeOut ? pPars->nTimeOut * CLOCKS_PER_SEC + clock() : 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();
if ( pPars->fPrintCP )
Abc_SclTimeNtkPrint( p, 0, 0 );
@@ -375,7 +376,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
{
// printf( "%5d : ", 0 );
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( " " );
Abc_PrintTime( 1, "Time", clock() - p->timeTotal );
@@ -458,7 +459,7 @@ void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
printf( "\n" );
}
- p->MaxDelay = Abc_SclGetMaxDelay(p);
+ p->MaxDelay = Abc_SclReadMaxDelay(p);
if ( pPars->fPrintCP )
Abc_SclTimeNtkPrint( p, 0, 0 );
if ( nRuntimeLimit && clock() > nRuntimeLimit )
diff --git a/src/map/scl/sclTime.c b/src/map/scl/sclTime.c
index 7b27a9d0..ad0f7446 100644
--- a/src/map/scl/sclTime.c
+++ b/src/map/scl/sclTime.c
@@ -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) );
}
}
-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_Timing * pTime;
@@ -256,6 +256,8 @@ void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept )
else
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 )
{
@@ -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 );
if ( fVerbose && Abc_ObjIsNode(pObj) )
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) )
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 )
void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse )
{
Abc_Obj_t * pObj;
+ float D;
int i;
Abc_SclComputeLoad( p );
Abc_SclManCleanTime( p );
Abc_NtkForEachNode1( p->pNtk, pObj, i )
- Abc_SclTimeNode( p, pObj, 0 );
- if ( fReverse )
- Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
- Abc_SclTimeNode( p, pObj, 1 );
+ Abc_SclTimeNode( p, pObj, 0, 0 );
Abc_NtkForEachCo( p->pNtk, pObj, i )
{
Abc_SclObjDupFanin( p, pObj );
Vec_FltWriteEntry( p->vTimesOut, i, Abc_SclObjTimeMax(p, pObj) );
Vec_QueUpdate( p->vQue, i );
}
-// Vec_FltClear( p->vTimesOut );
-// Abc_NtkForEachCo( p->pNtk, pObj, i )
-// Vec_FltPush( p->vTimesOut, Abc_SclObjTimeMax(p, pObj) );
+ D = Abc_SclReadMaxDelay( p );
if ( pArea )
*pArea = Abc_SclGetTotalArea( p );
if ( pDelay )
- *pDelay = Abc_SclGetMaxDelay( p );
+ *pDelay = D;
+ if ( fReverse )
+ Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
+ Abc_SclTimeNode( p, pObj, 1, D );
}
/**Function*************************************************************
@@ -311,14 +312,14 @@ void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fRe
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 );
assert( p->vGates == NULL );
p->vGates = Abc_SclManFindGates( pLib, pNtk );
if ( fUseWireLoads )
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;
return p;
}
@@ -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 )
{
SC_Man * p;
- p = Abc_SclManStart( pLib, pNtk, fUseWireLoads );
+ p = Abc_SclManStart( pLib, pNtk, fUseWireLoads, 1 );
Abc_SclTimeNtkPrint( p, fShowAll, fShort );
if ( fDumpStats )
Abc_SclDumpStats( p, "stats.txt", 0 );
diff --git a/src/map/scl/sclUpsize.c b/src/map/scl/sclUpsize.c
index 90c7708f..6c9a61bc 100644
--- a/src/map/scl/sclUpsize.c
+++ b/src/map/scl/sclUpsize.c
@@ -28,8 +28,6 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-extern Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -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 )
{
- float fMaxArr = Abc_SclGetMaxDelay( p ) * (100.0 - Window) / 100.0;
+ float fMaxArr = Abc_SclReadMaxDelay( p ) * (100.0 - Window) / 100.0;
Vec_Int_t * vPivots;
Abc_Obj_t * pObj;
int i;
@@ -123,7 +121,7 @@ Vec_Int_t * Abc_SclFindCriticalCoWindow( SC_Man * p, int Window )
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;
float fArrMax, fSlackFan;
@@ -135,30 +133,40 @@ void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t
Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) );
// 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
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 )
- Abc_SclFindCriticalNodeWindow_rec( p, pNext, vPath, fSlackFan );
+ Abc_SclFindCriticalNodeWindow_rec( p, pNext, vPath, fSlackFan, fDept );
}
if ( Abc_ObjFaninNum(pObj) > 0 )
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 fSlack = fMaxArr * Window / 100.0;
+ float fMaxArr = Abc_SclReadMaxDelay( p );
+ float fSlackMax = fMaxArr * Window / 100.0;
Vec_Int_t * vPath = Vec_IntAlloc( 100 );
Abc_Obj_t * pObj;
int i;
Abc_NtkIncrementTravId( p->pNtk );
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 )
- Abc_SclFindCriticalNodeWindow_rec( p, Abc_ObjFanin0(pObj), vPath, fSlackThis );
+ Abc_SclFindCriticalNodeWindow_rec( p, Abc_ObjFanin0(pObj), vPath, fSlackThis, fDept );
}
// label critical nodes
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
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;
Vec_Int_t * vPathPos = NULL; // critical POs
Vec_Int_t * vPathNodes = NULL; // critical nodes and PIs
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 nAllPos, nAllNodes, nAllTfos, nAllUpsizes;
- clock_t clk;
- if ( fVerbose )
+ if ( pPars->fVerbose )
{
printf( "Sizing parameters: " );
- printf( "Iters =%4d. ", nIters );
- printf( "Time window =%3d %%. ", Window );
- printf( "Update ratio =%3d %%. ", Ratio );
- printf( "Max upsize steps =%2d. ", Notches );
- printf( "Timeout =%3d sec", TimeOut );
+ printf( "Iters =%5d. ", pPars->nIters );
+ printf( "Time window =%3d %%. ", pPars->Window );
+ printf( "Update ratio =%3d %%. ", pPars->Ratio );
+ printf( "Max steps =%3d. ", pPars->Notches );
+ printf( "UseDept =%2d. ", pPars->fUseDept );
+ printf( "Timeout =%4d sec", pPars->TimeOut );
printf( "\n" );
}
// prepare the manager; collect init stats
- p = Abc_SclManStart( pLib, pNtk, 1 );
+ p = Abc_SclManStart( pLib, pNtk, 1, pPars->fUseDept );
p->timeTotal = clock();
assert( p->vGatesBest == NULL );
p->vGatesBest = Vec_IntDup( p->vGates );
@@ -484,19 +493,19 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
// perform upsizing
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
clk = clock();
vPathPos = Abc_SclFindCriticalCoWindow( p, win );
- vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, win );
+ vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, win, pPars->fUseDept );
p->timeCone += clock() - clk;
// selectively upsize the nodes
clk = clock();
- nUpsizes = Abc_SclFindUpsizes( p, vPathNodes, Ratio, Notches, i );
+ nUpsizes = Abc_SclFindUpsizes( p, vPathNodes, pPars->Ratio, pPars->Notches, i );
p->timeSize += clock() - clk;
// unmark critical path
@@ -514,15 +523,21 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nIters, int nIte
// update timing information
clk = clock();
-// vTFO = Abc_SclFindTFO( p->pNtk, vPathNodes );
-// Abc_SclTimeCone( p, vTFO );
- vTFO = Vec_IntAlloc( 0 );
- Abc_SclTimeNtkRecompute( p, NULL, NULL, 0 );
+ if ( pPars->fUseDept )
+ {
+ vTFO = Vec_IntAlloc( 0 );
+ Abc_SclTimeNtkRecompute( p, NULL, NULL, pPars->fUseDept );
+ }
+ else
+ {
+ vTFO = Abc_SclFindTFO( p->pNtk, vPathNodes );
+ Abc_SclTimeCone( p, vTFO );
+ }
p->timeTime += clock() - clk;
// Abc_SclUpsizePrintDiffs( p, pLib, pNtk );
// save the best network
- p->MaxDelay = Abc_SclGetMaxDelay( p );
+ p->MaxDelay = Abc_SclReadMaxDelay( p );
if ( 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
}
else
nFramesNoChange++;
- if ( nFramesNoChange > nIterNoChange )
+ if ( nFramesNoChange > pPars->nIterNoChange )
+ {
+ Vec_IntFree( vPathPos );
+ Vec_IntFree( vPathNodes );
+ Vec_IntFree( vTFO );
break;
+ }
// report and cleanup
- Abc_SclUpsizePrint( p, i, win, Vec_IntSize(vPathPos), Vec_IntSize(vPathNodes), nUpsizes, Vec_IntSize(vTFO), fVeryVerbose ); //|| (i == nIters-1) );
- nAllPos += Vec_IntSize(vPathPos);
- nAllNodes += Vec_IntSize(vPathNodes);
- nAllTfos += Vec_IntSize(vTFO);
+ Abc_SclUpsizePrint( p, i, win, Vec_IntSize(vPathPos), Vec_IntSize(vPathNodes), nUpsizes, Vec_IntSize(vTFO), pPars->fVeryVerbose ); //|| (i == nIters-1) );
+ nAllPos += Vec_IntSize(vPathPos);
+ nAllNodes += Vec_IntSize(vPathNodes);
+ nAllTfos += Vec_IntSize(vTFO);
nAllUpsizes += nUpsizes;
Vec_IntFree( vPathPos );
Vec_IntFree( vPathNodes );
Vec_IntFree( vTFO );
+ // check timeout
+ if ( nRuntimeLimit && clock() > nRuntimeLimit )
+ break;
}
// update for best gates and recompute timing
ABC_SWAP( Vec_Int_t *, p->vGatesBest, p->vGates );
Abc_SclTimeNtkRecompute( p, &p->SumArea, &p->MaxDelay, 0 );
- if ( fVerbose )
- Abc_SclUpsizePrint( p, i, Window, nAllPos/i, nAllNodes/i, nAllUpsizes/i, nAllTfos/i, 1 );
+ if ( pPars->fVerbose )
+ 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
p->timeTotal = clock() - p->timeTotal;
- if ( fVerbose )
+ if ( pPars->fVerbose )
{
p->timeOther = p->timeTotal - p->timeCone - p->timeSize - p->timeTime;
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
ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal );
ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal );
}
- if ( fDumpStats )
+ if ( pPars->fDumpStats )
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
Abc_SclManSetGates( pLib, pNtk, p->vGates ); // updates gate pointers