Commit 6dd270d4 by Alan Mishchenko

Improvements to gate-sizing.

parent c84f26c9
...@@ -32,8 +32,8 @@ static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); ...@@ -32,8 +32,8 @@ static int Scl_CommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandPrint ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandPrint ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandStime ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandStime ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandGsize ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char **argv ); static int Scl_CommandBuffer ( Abc_Frame_t * pAbc, int argc, char **argv );
static int Scl_CommandGsize ( Abc_Frame_t * pAbc, int argc, char **argv );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -56,8 +56,8 @@ void Scl_Init( Abc_Frame_t * pAbc ) ...@@ -56,8 +56,8 @@ void Scl_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "write_scl", Scl_CommandWrite, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "print_scl", Scl_CommandPrint, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "print_scl", Scl_CommandPrint, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 ); Cmd_CommandAdd( pAbc, "SCL mapping", "stime", Scl_CommandStime, 0 );
Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 ); Cmd_CommandAdd( pAbc, "SCL mapping", "buffer", Scl_CommandBuffer, 1 );
Cmd_CommandAdd( pAbc, "SCL mapping", "gsize", Scl_CommandGsize, 1 );
} }
void Scl_End( Abc_Frame_t * pAbc ) void Scl_End( Abc_Frame_t * pAbc )
{ {
...@@ -292,11 +292,14 @@ usage: ...@@ -292,11 +292,14 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv ) int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
int c, fVerbose = 0; Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nSteps = 100000; Abc_Ntk_t * pNtkRes;
int Degree;
int c, fVerbose;
Degree = 4;
fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
{ {
...@@ -308,9 +311,9 @@ int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -308,9 +311,9 @@ int Scl_CommandGsize( 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;
} }
nSteps = atoi(argv[globalUtilOptind]); Degree = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nSteps <= 0 ) if ( Degree < 0 )
goto usage; goto usage;
break; break;
case 'v': case 'v':
...@@ -323,36 +326,34 @@ int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -323,36 +326,34 @@ int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
} }
} }
if ( Abc_FrameReadNtk(pAbc) == NULL ) if ( pNtk == 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" ); Abc_Print( -1, "Empty network.\n" );
return 1; return 1;
} }
if ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) ) if ( !Abc_NtkIsLogic(pNtk) )
{ {
fprintf( pAbc->Err, "The current networks is not in a topo order (run \"buffer -N 1000\").\n" ); Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1; return 1;
} }
if ( pAbc->pLibScl == NULL )
// modify the current network
pNtkRes = Abc_SclPerformBuffering( pNtk, Degree, fVerbose );
if ( pNtkRes == NULL )
{ {
fprintf( pAbc->Err, "There is no Liberty library available.\n" ); Abc_Print( -1, "The command has failed.\n" );
return 1; return 1;
} }
// replace the current network
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc), nSteps, fVerbose ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: gsize [-N num] [-vh]\n" ); fprintf( pAbc->Err, "usage: buffer [-N num] [-vh]\n" );
fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" ); fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" );
fprintf( pAbc->Err, "\t-N <num> : the number of gate-sizing steps performed [default = %d]\n", nSteps ); fprintf( pAbc->Err, "\t-N <num> : the max allowed fanout count of node/buffer [default = %d]\n", Degree );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\t-h : print the command usage\n");
return 1; return 1;
} }
...@@ -367,16 +368,16 @@ usage: ...@@ -367,16 +368,16 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); int c, fVerbose = 0;
Abc_Ntk_t * pNtkRes; int fPrintCP = 0;
int Degree; int nSteps = 100000;
int c, fVerbose; int nRange = 0;
Degree = 4; int fTryAll = 0;
fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "NWvaph" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -386,11 +387,28 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -386,11 +387,28 @@ int Scl_CommandBuffer( 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;
} }
Degree = atoi(argv[globalUtilOptind]); nSteps = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( Degree < 0 ) if ( nSteps <= 0 )
goto usage;
break;
case 'W':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-W\" should be followed by a positive integer.\n" );
goto usage;
}
nRange = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRange < 0 )
goto usage; goto usage;
break; break;
case 'a':
fTryAll ^= 1;
break;
case 'p':
fPrintCP ^= 1;
break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
...@@ -401,34 +419,39 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -401,34 +419,39 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
} }
if ( pNtk == NULL ) if ( Abc_FrameReadNtk(pAbc) == NULL )
{ {
Abc_Print( -1, "Empty network.\n" ); fprintf( pAbc->Err, "There is no current network.\n" );
return 1; return 1;
} }
if ( !Abc_NtkIsLogic(pNtk) ) if ( !Abc_NtkHasMapping(Abc_FrameReadNtk(pAbc)) )
{ {
Abc_Print( -1, "This command can only be applied to a logic network.\n" ); fprintf( pAbc->Err, "The current network is not mapped.\n" );
return 1; return 1;
} }
if ( !Abc_SclCheckNtk(Abc_FrameReadNtk(pAbc), 0) )
// modify the current network
pNtkRes = Abc_SclPerformBuffering( pNtk, Degree, fVerbose );
if ( pNtkRes == NULL )
{ {
Abc_Print( -1, "The command has failed.\n" ); fprintf( pAbc->Err, "The current networks is not in a topo order (run \"buffer -N 1000\").\n" );
return 1; return 1;
} }
// replace the current network if ( pAbc->pLibScl == NULL )
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); {
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc), nSteps, nRange, fTryAll, fPrintCP, fVerbose );
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: buffer [-N num] [-vh]\n" ); fprintf( pAbc->Err, "usage: gsize [-NW num] [-apvh]\n" );
fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" ); fprintf( pAbc->Err, "\t performs gate sizing using Liberty library\n" );
fprintf( pAbc->Err, "\t-N <num> : the max allowed fanout count of node/buffer [default = %d]\n", Degree ); fprintf( pAbc->Err, "\t-N <num> : the number of gate-sizing steps performed [default = %d]\n", nSteps );
fprintf( pAbc->Err, "\t-W <num> : delay window (in percents) of near-critical COs [default = %d]\n", nRange );
fprintf( pAbc->Err, "\t-a : try resizing all gates (not only critical) [default = %s]\n", fTryAll? "yes": "no" );
fprintf( pAbc->Err, "\t-p : toggle printing critical path before and after sizing [default = %s]\n", fPrintCP? "yes": "no" );
fprintf( pAbc->Err, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); 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 help massage\n" );
return 1; return 1;
} }
......
...@@ -414,7 +414,7 @@ extern void Abc_SclSave( char * pFileName, SC_Lib * pScl ); ...@@ -414,7 +414,7 @@ extern void Abc_SclSave( char * pFileName, SC_Lib * pScl );
/*=== sclTime.c =============================================================*/ /*=== sclTime.c =============================================================*/
extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fShowAll ); extern void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fShowAll );
/*=== sclSize.c =============================================================*/ /*=== sclSize.c =============================================================*/
extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nSteps, int fVerbose ); extern void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nSteps, int nRange, int fTryAll, int fPrintCP, int fVerbose );
/*=== 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 );
......
...@@ -80,6 +80,8 @@ static inline SC_Pair * Abc_SclObjSlew( SC_Man * p, Abc_Obj_t * pObj ) { re ...@@ -80,6 +80,8 @@ static inline SC_Pair * Abc_SclObjSlew( SC_Man * p, Abc_Obj_t * pObj ) { re
static inline SC_Pair * Abc_SclObjTime2( SC_Man * p, Abc_Obj_t * pObj ) { return p->pTimes2 + Abc_ObjId(pObj); } static inline SC_Pair * Abc_SclObjTime2( SC_Man * p, Abc_Obj_t * pObj ) { return p->pTimes2 + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjSlew2( SC_Man * p, Abc_Obj_t * pObj ) { return p->pSlews2 + Abc_ObjId(pObj); } static inline SC_Pair * Abc_SclObjSlew2( SC_Man * p, Abc_Obj_t * pObj ) { return p->pSlews2 + Abc_ObjId(pObj); }
static inline float Abc_SclObjTimeMax( SC_Man * p, Abc_Obj_t * pObj ) { return Abc_MaxFloat(Abc_SclObjTime(p, pObj)->rise, Abc_SclObjTime(p, pObj)->fall); }
static inline void Abc_SclObjDupFanin( SC_Man * p, Abc_Obj_t * pObj ) { assert( Abc_ObjIsCo(pObj) ); *Abc_SclObjTime(p, pObj) = *Abc_SclObjTime(p, Abc_ObjFanin0(pObj)); } static inline void Abc_SclObjDupFanin( SC_Man * p, Abc_Obj_t * pObj ) { assert( Abc_ObjIsCo(pObj) ); *Abc_SclObjTime(p, pObj) = *Abc_SclObjTime(p, Abc_ObjFanin0(pObj)); }
static inline float Abc_SclObjGain( SC_Man * p, Abc_Obj_t * pObj ) { return (Abc_SclObjTime2(p, pObj)->rise - Abc_SclObjTime(p, pObj)->rise) + (Abc_SclObjTime2(p, pObj)->fall - Abc_SclObjTime(p, pObj)->fall); } static inline float Abc_SclObjGain( SC_Man * p, Abc_Obj_t * pObj ) { return (Abc_SclObjTime2(p, pObj)->rise - Abc_SclObjTime(p, pObj)->rise) + (Abc_SclObjTime2(p, pObj)->fall - Abc_SclObjTime(p, pObj)->fall); }
...@@ -200,8 +202,8 @@ static inline float Abc_SclGetMaxDelay( SC_Man * p ) ...@@ -200,8 +202,8 @@ static inline float Abc_SclGetMaxDelay( SC_Man * p )
/*=== sclTime.c =============================================================*/ /*=== sclTime.c =============================================================*/
extern Vec_Int_t * Abc_SclFindCriticalPath( SC_Man * p );
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 void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll ); extern void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll );
extern SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk ); extern SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk );
extern void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone ); extern void Abc_SclTimeCone( SC_Man * p, Vec_Int_t * vCone );
......
...@@ -70,21 +70,6 @@ Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t * ...@@ -70,21 +70,6 @@ Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t *
} }
return pPivot; return pPivot;
} }
Vec_Int_t * Abc_SclFindCriticalPath( SC_Man * p )
{
int fRise = 0;
Abc_Obj_t * pPivot = Abc_SclFindCriticalCo( p, &fRise );
Vec_Int_t * vPath = Vec_IntAlloc( 100 );
Vec_IntPush( vPath, Abc_ObjId(pPivot) );
pPivot = Abc_ObjFanin0(pPivot);
while ( pPivot && Abc_ObjIsNode(pPivot) )
{
Vec_IntPush( vPath, Abc_ObjId(pPivot) );
pPivot = Abc_SclFindMostCriticalFanin( p, &fRise, pPivot );
}
Vec_IntReverseOrder( vPath );
return vPath;
}
/**Function************************************************************* /**Function*************************************************************
......
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