Commit fbdaf207 by Alan Mishchenko

Integrated buffering and sizing.

parent d4ad3b41
...@@ -707,14 +707,15 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -707,14 +707,15 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkRes; Abc_Ntk_t * pNtkRes;
int c, GainRatio, nDegree, fBufPis, fAddBufs, fVerbose; int c, GainRatio, nDegree, fSizeOnly, fBufPis, fAddBufs, fVerbose;
GainRatio = 200; GainRatio = 150;
nDegree = 4; nDegree = 4;
fSizeOnly = 0;
fAddBufs = 0; fAddBufs = 0;
fBufPis = 0; fBufPis = 0;
fVerbose = 0; fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "GNbpvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "GNsbpvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -740,6 +741,9 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -740,6 +741,9 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nDegree < 0 ) if ( nDegree < 0 )
goto usage; goto usage;
break; break;
case 's':
fSizeOnly ^= 1;
break;
case 'b': case 'b':
fAddBufs ^= 1; fAddBufs ^= 1;
break; break;
...@@ -766,13 +770,13 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -766,13 +770,13 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "This command can only be applied to a logic network.\n" ); Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1; return 1;
} }
if ( !fAddBufs && pNtk->vPhases == NULL ) if ( !fSizeOnly && !fAddBufs && pNtk->vPhases == NULL )
{ {
Abc_Print( -1, "Fanin phase information is not avaiable.\n" ); Abc_Print( -1, "Fanin phase information is not avaiable.\n" );
return 1; return 1;
} }
// modify the current network // modify the current network
pNtkRes = Abc_SclBufSizePerform( pNtk, (SC_Lib *)pAbc->pLibScl, GainRatio, nDegree, fAddBufs, fBufPis, fVerbose ); pNtkRes = Abc_SclBufSizePerform( pNtk, (SC_Lib *)pAbc->pLibScl, GainRatio, nDegree, fSizeOnly, fAddBufs, fBufPis, fVerbose );
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
Abc_Print( -1, "The command has failed.\n" ); Abc_Print( -1, "The command has failed.\n" );
...@@ -783,10 +787,11 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -783,10 +787,11 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: bufsize [-GM num] [-bpvh]\n" ); fprintf( pAbc->Err, "usage: bufsize [-GM num] [-sbpvh]\n" );
fprintf( pAbc->Err, "\t performs buffering and sizing and mapped network\n" ); fprintf( pAbc->Err, "\t performs buffering and sizing and mapped network\n" );
fprintf( pAbc->Err, "\t-G <num> : target gain percentage [default = %d]\n", GainRatio ); fprintf( pAbc->Err, "\t-G <num> : target gain percentage [default = %d]\n", GainRatio );
fprintf( pAbc->Err, "\t-M <num> : the maximum fanout degree [default = %d]\n", nDegree ); fprintf( pAbc->Err, "\t-M <num> : the maximum fanout degree [default = %d]\n", nDegree );
fprintf( pAbc->Err, "\t-s : toggle performing only sizing [default = %s]\n", fSizeOnly? "yes": "no" );
fprintf( pAbc->Err, "\t-b : toggle using buffers instead of inverters [default = %s]\n", fAddBufs? "yes": "no" ); fprintf( pAbc->Err, "\t-b : toggle using buffers instead of inverters [default = %s]\n", fAddBufs? "yes": "no" );
fprintf( pAbc->Err, "\t-p : toggle buffering primary inputs [default = %s]\n", fBufPis? "yes": "no" ); fprintf( pAbc->Err, "\t-p : toggle buffering primary inputs [default = %s]\n", fBufPis? "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" );
......
...@@ -34,6 +34,7 @@ struct Bus_Man_t_ ...@@ -34,6 +34,7 @@ struct Bus_Man_t_
// parameters // parameters
float Gain; // target gain float Gain; // target gain
int nDegree; // max branching factor int nDegree; // max branching factor
int fSizeOnly; // perform only sizing
int fAddBufs; // add buffers int fAddBufs; // add buffers
int fBufPis; // use CI buffering int fBufPis; // use CI buffering
int fVerbose; // verbose int fVerbose; // verbose
...@@ -72,12 +73,13 @@ static inline void Bus_SclObjUpdateDept( Abc_Obj_t * p, float time ) { f ...@@ -72,12 +73,13 @@ static inline void Bus_SclObjUpdateDept( Abc_Obj_t * p, float time ) { f
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fAddBufs, int fBufPis, int fVerbose ) Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fSizeOnly, int fAddBufs, int fBufPis, int fVerbose )
{ {
Bus_Man_t * p; Bus_Man_t * p;
p = ABC_CALLOC( Bus_Man_t, 1 ); p = ABC_CALLOC( Bus_Man_t, 1 );
p->Gain = 0.01 * GainRatio; p->Gain = 0.01 * GainRatio;
p->nDegree = nDegree; p->nDegree = nDegree;
p->fSizeOnly = fSizeOnly;
p->fAddBufs = fAddBufs; p->fAddBufs = fAddBufs;
p->fBufPis = fBufPis; p->fBufPis = fBufPis;
p->fVerbose = fVerbose; p->fVerbose = fVerbose;
...@@ -168,7 +170,11 @@ void Abc_NtkComputeFanoutCins( Abc_Obj_t * pObj ) ...@@ -168,7 +170,11 @@ void Abc_NtkComputeFanoutCins( Abc_Obj_t * pObj )
int i; int i;
Abc_ObjForEachFanout( pObj, pFanout, i ) Abc_ObjForEachFanout( pObj, pFanout, i )
if ( Abc_ObjIsNode(pFanout) ) if ( Abc_ObjIsNode(pFanout) )
Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), Abc_NodeFindFanin(pFanout, pObj) ) ); {
float cap = SC_CellPinCap( Abc_SclObjCell(pFanout), Abc_NodeFindFanin(pFanout, pObj) );
assert( cap > 0 );
Bus_SclObjSetCin( pFanout, cap );
}
} }
float Abc_NtkComputeNodeLoad( Abc_Obj_t * pObj ) float Abc_NtkComputeNodeLoad( Abc_Obj_t * pObj )
{ {
...@@ -196,7 +202,7 @@ float Abc_NtkComputeNodeDept( Abc_Obj_t * pObj ) ...@@ -196,7 +202,7 @@ float Abc_NtkComputeNodeDept( Abc_Obj_t * pObj )
Edge = Scl_LibPinArrivalEstimate( Abc_SclObjCell(pFanout), Abc_NodeFindFanin(pFanout, pObj), Load ); Edge = Scl_LibPinArrivalEstimate( Abc_SclObjCell(pFanout), Abc_NodeFindFanin(pFanout, pObj), Load );
Bus_SclObjUpdateDept( pObj, Dept + Edge ); Bus_SclObjUpdateDept( pObj, Dept + Edge );
assert( Edge > 0 ); assert( Edge > 0 );
assert( Load > 0 ); // assert( Load > 0 );
} }
return Bus_SclObjDept( pObj ); return Bus_SclObjDept( pObj );
} }
...@@ -318,11 +324,13 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -318,11 +324,13 @@ void Abc_SclBufSize( Bus_Man_t * p )
SC_Cell * pCell, * pCellNew; SC_Cell * pCell, * pCellNew;
Vec_Ptr_t * vFanouts; Vec_Ptr_t * vFanouts;
Abc_Obj_t * pObj, * pInv; Abc_Obj_t * pObj, * pInv;
abctime clk = Abc_Clock();
float Dept, DeptMax = 0;
float Load, Cin; float Load, Cin;
int i; int i;
vFanouts = Vec_PtrAlloc( 100 ); vFanouts = Vec_PtrAlloc( 100 );
Abc_SclMioGates2SclGates( p->pLib, p->pNtk ); Abc_SclMioGates2SclGates( p->pLib, p->pNtk );
Abc_NtkForEachNodeReverse( p->pNtk, pObj, i ) Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
{ {
// compute load // compute load
Abc_NtkComputeFanoutCins( pObj ); Abc_NtkComputeFanoutCins( pObj );
...@@ -331,7 +339,7 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -331,7 +339,7 @@ void Abc_SclBufSize( Bus_Man_t * p )
pCell = Abc_SclObjCell( pObj ); pCell = Abc_SclObjCell( pObj );
Cin = SC_CellPinCapAve( pCell->pAve ); Cin = SC_CellPinCapAve( pCell->pAve );
// consider upsizing the gate // consider upsizing the gate
if ( Load > p->Gain * Cin ) if ( !p->fSizeOnly && Load > p->Gain * Cin )
{ {
// add one or more inverters // add one or more inverters
Abc_NodeCollectFanouts( pObj, vFanouts ); Abc_NodeCollectFanouts( pObj, vFanouts );
...@@ -351,22 +359,38 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -351,22 +359,38 @@ void Abc_SclBufSize( Bus_Man_t * p )
// create cell // create cell
pCellNew = Abc_SclFindSmallestGate( pCell, Load / p->Gain ); pCellNew = Abc_SclFindSmallestGate( pCell, Load / p->Gain );
Abc_SclObjSetCell( pObj, pCellNew ); Abc_SclObjSetCell( pObj, pCellNew );
Abc_NtkComputeNodeDept( pObj ); Dept = Abc_NtkComputeNodeDept( pObj );
DeptMax = Abc_MaxFloat( DeptMax, Dept );
if ( p->fVerbose )
{
printf( "Node %7d : ", i );
printf( "%12s ", pCellNew->pName );
printf( "(%2d/%2d) ", pCellNew->Order, pCellNew->nGates );
printf( "gain =%5.2f ", Load / SC_CellPinCapAve(pCellNew) );
printf( "dept =%7.0f ps ", SC_LibTimePs(p->pLib, Dept) );
printf( "\n" );
}
} }
Abc_SclSclGates2MioGates( p->pLib, p->pNtk ); Abc_SclSclGates2MioGates( p->pLib, p->pNtk );
Vec_PtrFree( vFanouts ); Vec_PtrFree( vFanouts );
if ( p->fVerbose )
{
printf( "Largest departure time = %7.0f ps ", SC_LibTimePs(p->pLib, DeptMax) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
}
} }
Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fAddBufs, int fBufPis, int fVerbose ) Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fSizeOnly, int fAddBufs, int fBufPis, int fVerbose )
{ {
Abc_Ntk_t * pNtkNew; Abc_Ntk_t * pNtkNew;
Bus_Man_t * p; Bus_Man_t * p;
if ( !Abc_SclCheckNtk( pNtk, 0 ) ) if ( !Abc_SclCheckNtk( pNtk, 0 ) )
return NULL; return NULL;
Abc_SclReportDupFanins( pNtk ); Abc_SclReportDupFanins( pNtk );
p = Bus_ManStart( pNtk, pLib, GainRatio, nDegree, fAddBufs, fBufPis, fVerbose ); p = Bus_ManStart( pNtk, pLib, GainRatio, nDegree, fSizeOnly, fAddBufs, fBufPis, fVerbose );
Bus_ManReadInOutLoads( p ); Bus_ManReadInOutLoads( p );
Abc_SclBufSize( p ); Abc_SclBufSize( p );
Bus_ManStop( p ); Bus_ManStop( p );
if ( pNtk->vPhases )
Vec_IntFillExtra( pNtk->vPhases, Abc_NtkObjNumMax(pNtk), 0 ); Vec_IntFillExtra( pNtk->vPhases, Abc_NtkObjNumMax(pNtk), 0 );
pNtkNew = Abc_NtkDupDfs( pNtk ); pNtkNew = Abc_NtkDupDfs( pNtk );
return pNtkNew; return pNtkNew;
......
...@@ -109,7 +109,7 @@ Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t * ...@@ -109,7 +109,7 @@ Abc_Obj_t * Abc_SclFindMostCriticalFanin( SC_Man * p, int * pfRise, Abc_Obj_t *
static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise, int Length, float maxDelay ) static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise, int Length, float maxDelay )
{ {
SC_Cell * pCell = Abc_ObjIsNode(pObj) ? Abc_SclObjCell(pObj) : NULL; SC_Cell * pCell = Abc_ObjIsNode(pObj) ? Abc_SclObjCell(pObj) : NULL;
printf( "%6d : ", Abc_ObjId(pObj) ); printf( "%8d : ", Abc_ObjId(pObj) );
printf( "%d ", Abc_ObjFaninNum(pObj) ); printf( "%d ", Abc_ObjFaninNum(pObj) );
printf( "%4d ", Abc_ObjFanoutNum(pObj) ); printf( "%4d ", Abc_ObjFanoutNum(pObj) );
printf( "%-*s ", Length, pCell ? pCell->pName : "pi" ); printf( "%-*s ", Length, pCell ? pCell->pName : "pi" );
...@@ -170,7 +170,7 @@ void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath ) ...@@ -170,7 +170,7 @@ void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
pObj = Abc_ObjFanin0(pPivot); pObj = Abc_ObjFanin0(pPivot);
while ( pObj )//&& Abc_ObjIsNode(pObj) ) while ( pObj )//&& Abc_ObjIsNode(pObj) )
{ {
printf( "Path%3d -- ", i-- ); printf( "Path%3d --", i-- );
Abc_SclTimeNodePrint( p, pObj, fRise, nLength, maxDelay ); Abc_SclTimeNodePrint( p, pObj, fRise, nLength, maxDelay );
pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj ); pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj );
} }
......
...@@ -188,6 +188,14 @@ static inline SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk ) ...@@ -188,6 +188,14 @@ static inline SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk )
} }
static inline void Abc_SclManFree( SC_Man * p ) static inline void Abc_SclManFree( SC_Man * p )
{ {
Abc_Obj_t * pObj;
int i;
// set CI/CO ids
Abc_NtkForEachCi( p->pNtk, pObj, i )
pObj->iData = 0;
Abc_NtkForEachCo( p->pNtk, pObj, i )
pObj->iData = 0;
// other
p->pNtk->pSCLib = NULL; p->pNtk->pSCLib = NULL;
Vec_IntFreeP( &p->pNtk->vGates ); Vec_IntFreeP( &p->pNtk->vGates );
Vec_IntFreeP( &p->vNodeIter ); Vec_IntFreeP( &p->vNodeIter );
...@@ -485,7 +493,7 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, abctime Time ...@@ -485,7 +493,7 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, abctime Time
} }
/*=== sclBufSize.c ===============================================================*/ /*=== sclBufSize.c ===============================================================*/
extern Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fAddBufs, int fBufPis, int fVerbose ); extern Abc_Ntk_t * Abc_SclBufSizePerform( Abc_Ntk_t * pNtk, SC_Lib * pLib, int GainRatio, int nDegree, int fSizeOnly, int fAddBufs, int fBufPis, int fVerbose );
/*=== sclBuffer.c ===============================================================*/ /*=== sclBuffer.c ===============================================================*/
extern int Abc_SclIsInv( Abc_Obj_t * pObj ); extern int Abc_SclIsInv( Abc_Obj_t * pObj );
extern void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj ); extern void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj );
......
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