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,81 +292,6 @@ usage: ...@@ -292,81 +292,6 @@ usage:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c, fVerbose = 0;
int nSteps = 100000;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
{
switch ( c )
{
case 'N':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage;
}
nSteps = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nSteps <= 0 )
goto usage;
break;
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 \"buffer -N 1000\").\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc), nSteps, fVerbose );
return 0;
usage:
fprintf( pAbc->Err, "usage: gsize [-N num] [-vh]\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", nSteps );
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" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
...@@ -432,6 +357,104 @@ usage: ...@@ -432,6 +357,104 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Scl_CommandGsize( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c, fVerbose = 0;
int fPrintCP = 0;
int nSteps = 100000;
int nRange = 0;
int fTryAll = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "NWvaph" ) ) != EOF )
{
switch ( c )
{
case 'N':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage;
}
nSteps = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
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;
break;
case 'a':
fTryAll ^= 1;
break;
case 'p':
fPrintCP ^= 1;
break;
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 \"buffer -N 1000\").\n" );
return 1;
}
if ( pAbc->pLibScl == NULL )
{
fprintf( pAbc->Err, "There is no Liberty library available.\n" );
return 1;
}
Abc_SclSizingPerform( pAbc->pLibScl, Abc_FrameReadNtk(pAbc), nSteps, nRange, fTryAll, fPrintCP, fVerbose );
return 0;
usage:
fprintf( pAbc->Err, "usage: gsize [-NW num] [-apvh]\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", 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-h : print the help massage\n" );
return 1;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -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 );
......
...@@ -34,6 +34,127 @@ ABC_NAMESPACE_IMPL_START ...@@ -34,6 +34,127 @@ ABC_NAMESPACE_IMPL_START
/**Function************************************************************* /**Function*************************************************************
Synopsis [Collect nodes in network.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Abc_SclCollectNodes( Abc_Ntk_t * p )
{
Vec_Int_t * vRes;
Abc_Obj_t * pObj;
int i;
vRes = Vec_IntAlloc( Abc_NtkNodeNum(p) );
Abc_NtkForEachNode( p, pObj, i )
Vec_IntPush( vRes, i );
return vRes;
}
/**Function*************************************************************
Synopsis [Collect near-critical CO nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Abc_SclFindCriticalCoRange( SC_Man * p, int Range )
{
float fMaxArr = Abc_SclGetMaxDelay( p );
Vec_Int_t * vPivots;
Abc_Obj_t * pObj;
int i;
vPivots = Vec_IntAlloc( 100 );
Abc_NtkForEachCo( p->pNtk, pObj, i )
if ( Abc_SclObjTimeMax(p, pObj) >= fMaxArr * (100 - Range) / 100 )
Vec_IntPush( vPivots, Abc_ObjId(pObj) );
assert( Vec_IntSize(vPivots) > 0 );
return vPivots;
}
/**Function*************************************************************
Synopsis [Collect nodes in cone.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_SclFindCriticalCone_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited )
{
Abc_Obj_t * pNext;
int i;
if ( Abc_ObjIsCi(pObj) )
return;
if ( Abc_NodeIsTravIdCurrent( pObj ) )
return;
Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) );
Abc_ObjForEachFanin( pObj, pNext, i )
Abc_SclFindCriticalCone_rec( pNext, vVisited );
Vec_IntPush( vVisited, Abc_ObjId(pObj) );
}
Vec_Int_t * Abc_SclFindCriticalCone( SC_Man * p, int Range, Vec_Int_t ** pvPivots )
{
Vec_Int_t * vPivots = Abc_SclFindCriticalCoRange( p, Range );
Vec_Int_t * vPath = Vec_IntAlloc( 100 );
Abc_Obj_t * pObj;
int i;
Abc_NtkIncrementTravId( p->pNtk );
Abc_NtkForEachObjVec( vPivots, p->pNtk, pObj, i )
Abc_SclFindCriticalCone_rec( Abc_ObjFanin0(pObj), vPath );
if ( pvPivots )
*pvPivots = vPivots;
else
Vec_IntFree( vPivots );
return vPath;
}
/**Function*************************************************************
Synopsis [Collect nodes in critical path.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Abc_SclFindCriticalPath( SC_Man * p, int Range, Vec_Int_t ** pvPivots )
{
Vec_Int_t * vPivots = Abc_SclFindCriticalCoRange( p, Range );
Vec_Int_t * vPath = Vec_IntAlloc( 100 );
Abc_Obj_t * pObj;
int i, fRise = 0;
Abc_NtkForEachObjVec( vPivots, p->pNtk, pObj, i )
{
pObj = Abc_ObjFanin0(pObj);
while ( pObj && Abc_ObjIsNode(pObj) )
{
Vec_IntPush( vPath, Abc_ObjId(pObj) );
pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj );
}
}
if ( pvPivots )
*pvPivots = vPivots;
else
Vec_IntFree( vPivots );
return vPath;
}
/**Function*************************************************************
Synopsis [Collect TFO of the fanins of the object.] Synopsis [Collect TFO of the fanins of the object.]
Description [] Description []
...@@ -47,6 +168,8 @@ void Abc_SclCollectTfo_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited ) ...@@ -47,6 +168,8 @@ void Abc_SclCollectTfo_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited )
{ {
Abc_Obj_t * pNext; Abc_Obj_t * pNext;
int i; int i;
// if ( Abc_ObjIsCo(pObj) )
// return;
if ( Abc_NodeIsTravIdCurrent( pObj ) ) if ( Abc_NodeIsTravIdCurrent( pObj ) )
return; return;
Abc_NodeSetTravIdCurrent( pObj ); Abc_NodeSetTravIdCurrent( pObj );
...@@ -54,18 +177,48 @@ void Abc_SclCollectTfo_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited ) ...@@ -54,18 +177,48 @@ void Abc_SclCollectTfo_rec( Abc_Obj_t * pObj, Vec_Int_t * vVisited )
Abc_SclCollectTfo_rec( pNext, vVisited ); Abc_SclCollectTfo_rec( pNext, vVisited );
Vec_IntPush( vVisited, Abc_ObjId(pObj) ); Vec_IntPush( vVisited, Abc_ObjId(pObj) );
} }
Vec_Int_t * Abc_SclCollectTfo( Abc_Ntk_t * p, Abc_Obj_t * pObj ) void Abc_SclMarkTfi_rec( Abc_Obj_t * pObj )
{
Abc_Obj_t * pNext;
int i;
if ( Abc_ObjIsCi(pObj) )
return;
if ( !Abc_NodeIsTravIdPrevious( pObj ) )
return;
if ( Abc_NodeIsTravIdCurrent( pObj ) )
return;
Abc_NodeSetTravIdCurrent( pObj );
assert( Abc_ObjIsNode(pObj) || Abc_ObjIsCo(pObj) );
Abc_ObjForEachFanin( pObj, pNext, i )
Abc_SclMarkTfi_rec( pNext );
}
Vec_Int_t * Abc_SclCollectTfo( Abc_Ntk_t * p, Abc_Obj_t * pObj, Vec_Int_t * vPivots )
{ {
Vec_Int_t * vVisited; Vec_Int_t * vVisited;
Abc_Obj_t * pFanin; Abc_Obj_t * pFanin;
int i; int i, k;
assert( Abc_ObjIsNode(pObj) ); assert( Abc_ObjIsNode(pObj) );
vVisited = Vec_IntAlloc( 100 ); vVisited = Vec_IntAlloc( 100 );
// collect nodes in the TFO
Abc_NtkIncrementTravId( p ); Abc_NtkIncrementTravId( p );
Abc_SclCollectTfo_rec( pObj, vVisited ); Abc_SclCollectTfo_rec( pObj, vVisited );
Abc_ObjForEachFanin( pObj, pFanin, i ) Abc_ObjForEachFanin( pObj, pFanin, i )
if ( Abc_ObjIsNode(pFanin) ) if ( Abc_ObjIsNode(pFanin) )
Abc_SclCollectTfo_rec( pFanin, vVisited ); Abc_SclCollectTfo_rec( pFanin, vVisited );
if ( vPivots )
{
// mark nodes in the TFI
Abc_NtkIncrementTravId( p );
Abc_NtkForEachObjVec( vPivots, p, pObj, i )
Abc_SclMarkTfi_rec( pObj );
// remove unmarked nodes
k = 0;
Abc_NtkForEachObjVec( vVisited, p, pObj, i )
if ( Abc_NodeIsTravIdCurrent( pObj ) )
Vec_IntWriteEntry( vVisited, k++, Abc_ObjId(pObj) );
Vec_IntShrink( vVisited, k );
}
// reverse order
Vec_IntReverseOrder( vVisited ); Vec_IntReverseOrder( vVisited );
return vVisited; return vVisited;
} }
...@@ -86,29 +239,32 @@ SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj ) ...@@ -86,29 +239,32 @@ SC_Cell * Abc_SclObjResiable( SC_Man * p, Abc_Obj_t * pObj )
SC_Cell * pOld = Abc_SclObjCell( p, pObj ); SC_Cell * pOld = Abc_SclObjCell( p, pObj );
return pOld->pNext != pOld ? pOld->pNext : NULL; return pOld->pNext != pOld ? pOld->pNext : NULL;
} }
float Abc_SclSizingGain( SC_Man * p, Abc_Obj_t * pPivot ) float Abc_SclSizingGain( SC_Man * p, Abc_Obj_t * pPivot, Vec_Int_t * vPivots )
{ {
double dGain = 0; double dGain = 0;
Vec_Int_t * vCone; Vec_Int_t * vCone;
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
assert( Abc_ObjIsNode(pPivot) ); assert( Abc_ObjIsNode(pPivot) );
vCone = Abc_SclCollectTfo( p->pNtk, pPivot ); vCone = Abc_SclCollectTfo( p->pNtk, pPivot, vPivots );
Abc_SclConeStore( p, vCone ); Abc_SclConeStore( p, vCone );
Abc_SclTimeCone( p, vCone ); Abc_SclTimeCone( p, vCone );
//Abc_SclTimeNtkPrint( p, 1 ); // Abc_NtkForEachObjVec( vCone, p->pNtk, pObj, i )
Abc_NtkForEachObjVec( vCone, p->pNtk, pObj, i ) Abc_NtkForEachObjVec( vPivots, p->pNtk, pObj, i )
if ( Abc_ObjIsCo(pObj) ) if ( Abc_ObjIsCo(pObj) )
{
Abc_SclObjDupFanin( p, pObj );
dGain += Abc_SclObjGain( p, pObj ); dGain += Abc_SclObjGain( p, pObj );
}
Abc_SclConeRestore( p, vCone ); Abc_SclConeRestore( p, vCone );
Vec_IntFree( vCone ); Vec_IntFree( vCone );
return dGain; return dGain;
} }
Abc_Obj_t * Abc_SclChooseBiggestGain( SC_Man * p, Vec_Int_t * vPath ) Abc_Obj_t * Abc_SclChooseBiggestGain( SC_Man * p, Vec_Int_t * vPath, Vec_Int_t * vPivots )
{ {
SC_Cell * pOld, * pNew; SC_Cell * pOld, * pNew;
Abc_Obj_t * pPivot = NULL, * pObj; Abc_Obj_t * pPivot = NULL, * pObj;
double dGainBest = 0, dGain; double dGainBest = 0.00001, dGain;
int i, gateId; int i, gateId;
Abc_NtkForEachObjVec( vPath, p->pNtk, pObj, i ) Abc_NtkForEachObjVec( vPath, p->pNtk, pObj, i )
{ {
...@@ -123,7 +279,7 @@ Abc_Obj_t * Abc_SclChooseBiggestGain( SC_Man * p, Vec_Int_t * vPath ) ...@@ -123,7 +279,7 @@ Abc_Obj_t * Abc_SclChooseBiggestGain( SC_Man * p, Vec_Int_t * vPath )
Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pNew->pName) ); Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pNew->pName) );
Abc_SclUpdateLoad( p, pObj, pOld, pNew ); Abc_SclUpdateLoad( p, pObj, pOld, pNew );
dGain = Abc_SclSizingGain( p, pObj ); dGain = Abc_SclSizingGain( p, pObj, vPivots );
Abc_SclUpdateLoad( p, pObj, pNew, pOld ); Abc_SclUpdateLoad( p, pObj, pNew, pOld );
//printf( "gain is %f\n", dGain ); //printf( "gain is %f\n", dGain );
Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pOld->pName) ); Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pOld->pName) );
...@@ -149,7 +305,7 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose ...@@ -149,7 +305,7 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose
p->SumArea += pNew->area - pOld->area; p->SumArea += pNew->area - pOld->area;
Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pNew->pName) ); Vec_IntWriteEntry( p->vGates, Abc_ObjId(pObj), Abc_SclCellFind(p->pLib, pNew->pName) );
// update info // update info
vCone = Abc_SclCollectTfo( p->pNtk, pObj ); vCone = Abc_SclCollectTfo( p->pNtk, pObj, NULL );
Abc_SclConeStore( p, vCone ); Abc_SclConeStore( p, vCone );
Abc_SclTimeCone( p, vCone ); Abc_SclTimeCone( p, vCone );
Vec_IntFree( vCone ); Vec_IntFree( vCone );
...@@ -161,10 +317,11 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose ...@@ -161,10 +317,11 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose
printf( "%-12s-> %-12s ", pOld->pName, pNew->pName ); printf( "%-12s-> %-12s ", pOld->pName, pNew->pName );
printf( "delay =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) ); printf( "delay =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) );
printf( "area =%10.2f ", p->SumArea ); printf( "area =%10.2f ", p->SumArea );
Abc_PrintTime( 1, "Time", clock() - p->clkStart ); // Abc_PrintTime( 1, "Time", clock() - p->clkStart );
ABC_PRTr( "Time", clock() - p->clkStart );
} }
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -176,41 +333,56 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose ...@@ -176,41 +333,56 @@ void Abc_SclUpdateNetwork( SC_Man * p, Abc_Obj_t * pObj, int iStep, int fVerbose
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nSteps, int fVerbose ) void Abc_SclSizingPerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nSteps, int nRange, int fTryAll, int fPrintCP, int fVerbose )
{ {
SC_Man * p; SC_Man * p;
Vec_Int_t * vPath; Vec_Int_t * vPath, * vPivots;
Abc_Obj_t * pBest; Abc_Obj_t * pBest;
int i; int i, nCones = 0;
p = Abc_SclManStart( pLib, pNtk ); p = Abc_SclManStart( pLib, pNtk );
if ( fVerbose ) if ( fPrintCP )
Abc_SclTimeNtkPrint( p, 0 ); Abc_SclTimeNtkPrint( p, 0 );
if ( fVerbose ) if ( fVerbose )
printf( "Iterating gate sizing of network \"%s\" with library \"%s\":\n", Abc_NtkName(pNtk), pLib->pName ); printf( "Iterative gate-sizing of network \"%s\" with library \"%s\":\n", Abc_NtkName(pNtk), pLib->pName );
if ( fVerbose ) if ( fVerbose )
{ {
printf( "%5d : ", 0 ); // printf( "%5d : ", 0 );
printf( "Starting parameters of current mapping: " );
printf( "delay =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) ); printf( "delay =%8.2f ps ", SC_LibTimePs(p->pLib, Abc_SclGetMaxDelay(p)) );
printf( "area =%10.2f ", p->SumArea ); printf( "area =%10.2f ", p->SumArea );
Abc_PrintTime( 1, "Time", clock() - p->clkStart ); Abc_PrintTime( 1, "Time", clock() - p->clkStart );
} }
for ( i = 0; i < nSteps; i++ ) for ( i = 0; i < nSteps; i++ )
{ {
vPath = Abc_SclFindCriticalPath( p ); vPath = Abc_SclFindCriticalPath( p, nRange, &vPivots );
pBest = Abc_SclChooseBiggestGain( p, vPath ); pBest = Abc_SclChooseBiggestGain( p, vPath, vPivots );
Vec_IntFree( vPath ); Vec_IntFree( vPath );
Vec_IntFree( vPivots );
if ( pBest == NULL ) if ( pBest == NULL )
break; {
if ( fTryAll )
{
vPath = Abc_SclFindCriticalCone( p, nRange, &vPivots );
// vPath = Abc_SclFindCriticalPath( p, nRange+5, &vPivots );
pBest = Abc_SclChooseBiggestGain( p, vPath, vPivots );
Vec_IntFree( vPath );
Vec_IntFree( vPivots );
nCones++;
}
if ( pBest == NULL )
break;
}
Abc_SclUpdateNetwork( p, pBest, i+1, fVerbose ); Abc_SclUpdateNetwork( p, pBest, i+1, fVerbose );
// recompute loads every 100 steps // recompute loads every 100 steps
if ( i && i % 100 == 0 ) if ( i && i % 100 == 0 )
Abc_SclComputeLoad( p ); Abc_SclComputeLoad( p );
} }
p->MaxDelay = Abc_SclGetMaxDelay(p); p->MaxDelay = Abc_SclGetMaxDelay(p);
if ( fVerbose ) if ( fPrintCP )
Abc_SclTimeNtkPrint( p, 0 ); Abc_SclTimeNtkPrint( p, 0 );
// print cumulative statistics // print cumulative statistics
printf( "Resized: %d. ", i ); printf( "Cones: %d. ", nCones );
printf( "Resized: %d. ", i );
printf( "Delay: " ); printf( "Delay: " );
printf( "%.2f -> %.2f ps ", SC_LibTimePs(p->pLib, p->MaxDelay0), SC_LibTimePs(p->pLib, p->MaxDelay) ); printf( "%.2f -> %.2f ps ", SC_LibTimePs(p->pLib, p->MaxDelay0), SC_LibTimePs(p->pLib, p->MaxDelay) );
printf( "(%+.1f %%). ", 100.0 * (p->MaxDelay - p->MaxDelay0)/ p->MaxDelay0 ); printf( "(%+.1f %%). ", 100.0 * (p->MaxDelay - p->MaxDelay0)/ p->MaxDelay0 );
......
...@@ -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