Commit ec4804aa by Alan Mishchenko

Integrated buffering and sizing.

parent 679a9a02
...@@ -575,7 +575,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -575,7 +575,7 @@ 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);
Abc_Ntk_t * pNtkRes; Abc_Ntk_t * pNtkRes;
int FanMin, FanMax, FanMaxR, fAddInvs, fUseInvs, fBufPis; int FanMin, FanMax, FanMaxR, fAddInvs, fUseInvs, fBufPis, fSkipDup;
int c, fVerbose; int c, fVerbose;
int fOldAlgo = 0; int fOldAlgo = 0;
FanMin = 6; FanMin = 6;
...@@ -584,9 +584,10 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -584,9 +584,10 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
fAddInvs = 0; fAddInvs = 0;
fUseInvs = 0; fUseInvs = 0;
fBufPis = 0; fBufPis = 0;
fSkipDup = 0;
fVerbose = 0; fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "NMRaixpvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "NMRaixpdvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -635,6 +636,9 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -635,6 +636,9 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'p': case 'p':
fBufPis ^= 1; fBufPis ^= 1;
break; break;
case 'd':
fSkipDup ^= 1;
break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
...@@ -667,7 +671,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -667,7 +671,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
else if ( fOldAlgo ) else if ( fOldAlgo )
pNtkRes = Abc_SclPerformBuffering( pNtk, FanMaxR, FanMax, fUseInvs, fVerbose ); pNtkRes = Abc_SclPerformBuffering( pNtk, FanMaxR, FanMax, fUseInvs, fVerbose );
else else
pNtkRes = Abc_SclBufPerform( pNtk, FanMin, FanMax, fBufPis, fVerbose ); pNtkRes = Abc_SclBufPerform( pNtk, FanMin, FanMax, fBufPis, fSkipDup, fVerbose );
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
Abc_Print( -1, "The command has failed.\n" ); Abc_Print( -1, "The command has failed.\n" );
...@@ -678,7 +682,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -678,7 +682,7 @@ int Scl_CommandBuffer( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pAbc->Err, "usage: buffer [-NMR num] [-aixpvh]\n" ); fprintf( pAbc->Err, "usage: buffer [-NMR num] [-aixpdvh]\n" );
fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" ); fprintf( pAbc->Err, "\t performs buffering of the mapped network\n" );
fprintf( pAbc->Err, "\t-N <num> : the min fanout considered by the algorithm [default = %d]\n", FanMin ); fprintf( pAbc->Err, "\t-N <num> : the min fanout considered by the algorithm [default = %d]\n", FanMin );
fprintf( pAbc->Err, "\t-M <num> : the max allowed fanout count of node/buffer [default = %d]\n", FanMax ); fprintf( pAbc->Err, "\t-M <num> : the max allowed fanout count of node/buffer [default = %d]\n", FanMax );
...@@ -687,6 +691,7 @@ usage: ...@@ -687,6 +691,7 @@ usage:
fprintf( pAbc->Err, "\t-i : toggle adding interters instead of buffering [default = %s]\n", fAddInvs? "yes": "no" ); fprintf( pAbc->Err, "\t-i : toggle adding interters instead of buffering [default = %s]\n", fAddInvs? "yes": "no" );
fprintf( pAbc->Err, "\t-x : toggle using interters instead of buffers [default = %s]\n", fUseInvs? "yes": "no" ); fprintf( pAbc->Err, "\t-x : toggle using interters instead of buffers [default = %s]\n", fUseInvs? "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-d : toggle disabling gate duplication [default = %s]\n", fSkipDup? "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 command usage\n");
return 1; return 1;
...@@ -710,8 +715,8 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -710,8 +715,8 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
memset( pPars, 0, sizeof(SC_BusPars) ); memset( pPars, 0, sizeof(SC_BusPars) );
pPars->GainRatio = 200; pPars->GainRatio = 200;
pPars->Slew = 80; pPars->Slew = 100;
pPars->nDegree = 4; pPars->nDegree = 8;
pPars->fSizeOnly = 0; pPars->fSizeOnly = 0;
pPars->fAddBufs = 0; pPars->fAddBufs = 0;
pPars->fBufPis = 0; pPars->fBufPis = 0;
......
...@@ -80,7 +80,7 @@ Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ) ...@@ -80,7 +80,7 @@ Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars )
p->pPars = pPars; p->pPars = pPars;
p->pNtk = pNtk; p->pNtk = pNtk;
p->pLib = pLib; p->pLib = pLib;
p->pInv = Abc_SclFindInvertor(pLib, pPars->fAddBufs)->pAve; p->pInv = Abc_SclFindInvertor(pLib, pPars->fAddBufs)->pRepr->pPrev;//->pAve;
if ( pPars->fUseWireLoads ) if ( pPars->fUseWireLoads )
{ {
if ( pNtk->pWLoadUsed == NULL ) if ( pNtk->pWLoadUsed == NULL )
......
...@@ -704,8 +704,8 @@ Buf_Man_t * Buf_ManStart( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis ...@@ -704,8 +704,8 @@ Buf_Man_t * Buf_ManStart( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis
// Abc_NtkForEachNode( p->pNtk, pObj, i ) // Abc_NtkForEachNode( p->pNtk, pObj, i )
// printf( "%4d : %4d %4d\n", i, Abc_BufNodeArr(p, pObj), Abc_BufNodeDep(p, pObj) ); // printf( "%4d : %4d %4d\n", i, Abc_BufNodeArr(p, pObj), Abc_BufNodeDep(p, pObj) );
// create fanout queue // create fanout queue
Abc_NtkForEachCi( p->pNtk, pObj, i ) // Abc_NtkForEachCi( p->pNtk, pObj, i )
Abc_BufAddToQue( p, pObj ); // Abc_BufAddToQue( p, pObj );
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Abc_BufAddToQue( p, pObj ); Abc_BufAddToQue( p, pObj );
Vec_PtrFree( vNodes ); Vec_PtrFree( vNodes );
...@@ -860,7 +860,7 @@ int Abc_BufCountNonCritical( Buf_Man_t * p, Abc_Obj_t * pObj ) ...@@ -860,7 +860,7 @@ int Abc_BufCountNonCritical( Buf_Man_t * p, Abc_Obj_t * pObj )
Vec_IntPush( p->vNonCrit, Abc_ObjId(pFanout) ); Vec_IntPush( p->vNonCrit, Abc_ObjId(pFanout) );
return Vec_IntSize(p->vNonCrit); return Vec_IntSize(p->vNonCrit);
} }
void Abc_BufPerformOne( Buf_Man_t * p, int iPivot, int fVerbose ) void Abc_BufPerformOne( Buf_Man_t * p, int iPivot, int fSkipDup, int fVerbose )
{ {
Abc_Obj_t * pObj, * pFanout; Abc_Obj_t * pObj, * pFanout;
int i, j, nCrit, nNonCrit; int i, j, nCrit, nNonCrit;
...@@ -889,11 +889,12 @@ printf( "ObjId = %6d : %-10s FI = %d. FO =%4d. Crit =%4d. ", ...@@ -889,11 +889,12 @@ printf( "ObjId = %6d : %-10s FI = %d. FO =%4d. Crit =%4d. ",
Abc_BufUpdateDep( p, pBuffer ); Abc_BufUpdateDep( p, pBuffer );
Abc_BufAddToQue( p, pObj ); Abc_BufAddToQue( p, pObj );
Abc_BufAddToQue( p, pBuffer ); Abc_BufAddToQue( p, pBuffer );
Abc_SclTimeIncUpdateLevel( pBuffer );
p->nSeparate++; p->nSeparate++;
if ( fVerbose ) if ( fVerbose )
printf( "Adding buffer\n" ); printf( "Adding buffer\n" );
} }
else if ( nCrit > 0 && Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > p->nFanMin )//&& Abc_ObjFaninNum(pObj) < 2 ) else if ( !fSkipDup && nCrit > 0 && Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > p->nFanMin )//&& Abc_ObjLevel(pObj) < 4 )//&& Abc_ObjFaninNum(pObj) < 2 )
{ {
// (2) only critical are present - duplicate // (2) only critical are present - duplicate
Abc_Obj_t * pClone = Abc_NtkDupObj( p->pNtk, pObj, 0 ); Abc_Obj_t * pClone = Abc_NtkDupObj( p->pNtk, pObj, 0 );
...@@ -911,7 +912,9 @@ printf( "Adding buffer\n" ); ...@@ -911,7 +912,9 @@ printf( "Adding buffer\n" );
Abc_BufAddToQue( p, pClone ); Abc_BufAddToQue( p, pClone );
Abc_ObjForEachFanin( pObj, pFanout, i ) Abc_ObjForEachFanin( pObj, pFanout, i )
Abc_BufAddToQue( p, pFanout ); Abc_BufAddToQue( p, pFanout );
Abc_SclTimeIncUpdateLevel( pClone );
p->nDuplicate++; p->nDuplicate++;
// printf( "Duplicating %s on level %d\n", Mio_GateReadName((Mio_Gate_t *)pObj->pData), Abc_ObjLevel(pObj) );
if ( fVerbose ) if ( fVerbose )
printf( "Duplicating node\n" ); printf( "Duplicating node\n" );
} }
...@@ -963,6 +966,8 @@ printf( "Adding %d buffers\n", nDegree ); ...@@ -963,6 +966,8 @@ printf( "Adding %d buffers\n", nDegree );
Abc_BufUpdateDep( p, pObj ); Abc_BufUpdateDep( p, pObj );
for ( i = 0; i < nDegree; i++ ) for ( i = 0; i < nDegree; i++ )
Abc_BufAddToQue( p, Abc_NtkObj(p->pNtk, iFirstBuf + i) ); Abc_BufAddToQue( p, Abc_NtkObj(p->pNtk, iFirstBuf + i) );
for ( i = 0; i < nDegree; i++ )
Abc_SclTimeIncUpdateLevel( Abc_NtkObj(p->pNtk, iFirstBuf + i) );
} }
else else
{ {
...@@ -972,13 +977,16 @@ printf( "Doing nothing\n" ); ...@@ -972,13 +977,16 @@ printf( "Doing nothing\n" );
// if ( DelayMax != p->DelayMax ) // if ( DelayMax != p->DelayMax )
// printf( "%d (%.2f) ", p->DelayMax, 1.0 * p->DelayMax * p->DelayInv / BUF_SCALE ); // printf( "%d (%.2f) ", p->DelayMax, 1.0 * p->DelayMax * p->DelayInv / BUF_SCALE );
} }
Abc_Ntk_t * Abc_SclBufPerform( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis, int fVerbose ) Abc_Ntk_t * Abc_SclBufPerform( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis, int fSkipDup, int fVerbose )
{ {
Abc_Ntk_t * pNew; Abc_Ntk_t * pNew;
Buf_Man_t * p = Buf_ManStart( pNtk, FanMin, FanMax, fBufPis ); Buf_Man_t * p = Buf_ManStart( pNtk, FanMin, FanMax, fBufPis );
int i, Limit = ABC_INFINITY; int i, Limit = ABC_INFINITY;
Abc_NtkLevel( pNtk );
if ( Abc_NtkNodeNum(pNtk) < 1000 )
fSkipDup = 1;
for ( i = 0; i < Limit && Vec_QueSize(p->vQue); i++ ) for ( i = 0; i < Limit && Vec_QueSize(p->vQue); i++ )
Abc_BufPerformOne( p, Vec_QuePop(p->vQue), fVerbose ); Abc_BufPerformOne( p, Vec_QuePop(p->vQue), fSkipDup, fVerbose );
Buf_ManStop( p ); Buf_ManStop( p );
// Abc_BufReplaceBufsByInvs( pNtk ); // Abc_BufReplaceBufsByInvs( pNtk );
// duplicate network in topo order // duplicate network in topo order
......
...@@ -133,11 +133,12 @@ void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath ) ...@@ -133,11 +133,12 @@ void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
p->ReportDelay = maxDelay; p->ReportDelay = maxDelay;
printf( "WireLoad model = \"%s\" ", p->pWLoadUsed ? p->pWLoadUsed->pName : "none" ); printf( "WireLoad model = \"%s\" ", p->pWLoadUsed ? p->pWLoadUsed->pName : "none" );
printf( "Gates = %6d ", Abc_NtkNodeNum(p->pNtk) ); printf( "Gates =%7d ", Abc_NtkNodeNum(p->pNtk) );
printf( "Cave = %5.1f ff ", p->EstLoadAve ); printf( "(%5.1f %%) ", Abc_SclGetAverageSize(p->pNtk) );
printf( "Area = %12.2f ", Abc_SclGetTotalArea(p->pNtk) ); printf( "Cave =%5.1f ff ", p->EstLoadAve );
printf( "Area =%12.2f ", Abc_SclGetTotalArea(p->pNtk) );
printf( "(%5.1f %%) ", 100.0 * Abc_SclCountMinSize(p->pLib, p->pNtk, 0) / Abc_NtkNodeNum(p->pNtk) ); printf( "(%5.1f %%) ", 100.0 * Abc_SclCountMinSize(p->pLib, p->pNtk, 0) / Abc_NtkNodeNum(p->pNtk) );
printf( "Delay = %8.2f ps ", maxDelay ); printf( "Delay =%9.2f ps ", maxDelay );
printf( "(%5.1f %%) ", 100.0 * Abc_SclCountNearCriticalNodes(p) / Abc_NtkNodeNum(p->pNtk) ); printf( "(%5.1f %%) ", 100.0 * Abc_SclCountNearCriticalNodes(p) / Abc_NtkNodeNum(p->pNtk) );
printf( " \n" ); printf( " \n" );
if ( fShowAll ) if ( fShowAll )
......
...@@ -400,6 +400,15 @@ static inline void Abc_SclConeClean( SC_Man * p, Vec_Int_t * vCone ) ...@@ -400,6 +400,15 @@ static inline void Abc_SclConeClean( SC_Man * p, Vec_Int_t * vCone )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline float Abc_SclGetAverageSize( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
double Total = 0;
int i, Count = 0;
Abc_NtkForEachNode1( pNtk, pObj, i )
Count++, Total += 100.0*Abc_SclObjCell(pObj)->Order/Abc_SclObjCell(pObj)->nGates;
return (float)(Total / Count);
}
static inline float Abc_SclGetTotalArea( Abc_Ntk_t * pNtk ) static inline float Abc_SclGetTotalArea( Abc_Ntk_t * pNtk )
{ {
double Area = 0; double Area = 0;
...@@ -504,7 +513,7 @@ extern Abc_Ntk_t * Abc_SclUnBufferPhase( Abc_Ntk_t * pNtk, int fVerbose ); ...@@ -504,7 +513,7 @@ extern Abc_Ntk_t * Abc_SclUnBufferPhase( Abc_Ntk_t * pNtk, int fVerbose );
extern Abc_Ntk_t * Abc_SclBufferPhase( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_Ntk_t * Abc_SclBufferPhase( Abc_Ntk_t * pNtk, int fVerbose );
extern int Abc_SclCheckNtk( Abc_Ntk_t * p, int fVerbose ); extern int Abc_SclCheckNtk( Abc_Ntk_t * p, int fVerbose );
extern Abc_Ntk_t * Abc_SclPerformBuffering( Abc_Ntk_t * p, int DegreeR, int Degree, int fUseInvs, int fVerbose ); extern Abc_Ntk_t * Abc_SclPerformBuffering( Abc_Ntk_t * p, int DegreeR, int Degree, int fUseInvs, int fVerbose );
extern Abc_Ntk_t * Abc_SclBufPerform( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis, int fVerbose ); extern Abc_Ntk_t * Abc_SclBufPerform( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis, int fSkipDup, int fVerbose );
/*=== sclDnsize.c ===============================================================*/ /*=== sclDnsize.c ===============================================================*/
extern void Abc_SclDnsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars ); extern void Abc_SclDnsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars );
/*=== sclLoad.c ===============================================================*/ /*=== sclLoad.c ===============================================================*/
......
...@@ -469,8 +469,8 @@ int Abc_SclFindBypasses( SC_Man * p, Vec_Int_t * vPathNodes, int Ratio, int Notc ...@@ -469,8 +469,8 @@ int Abc_SclFindBypasses( SC_Man * p, Vec_Int_t * vPathNodes, int Ratio, int Notc
// remember gain // remember gain
if ( dGainBest2 == -1 ) if ( dGainBest2 == -1 )
dGainBest2 = Vec_FltEntry(p->vNode2Gain, iNode); dGainBest2 = Vec_FltEntry(p->vNode2Gain, iNode);
else if ( dGainBest2 > 2*Vec_FltEntry(p->vNode2Gain, iNode) ) // else if ( dGainBest2 > 2*Vec_FltEntry(p->vNode2Gain, iNode) )
break; // break;
// redirect // redirect
Abc_SclUpdateLoadSplit( p, pBuf, pFanout ); Abc_SclUpdateLoadSplit( p, pBuf, pFanout );
Abc_SclAddWireLoad( p, pBuf, 1 ); Abc_SclAddWireLoad( p, pBuf, 1 );
...@@ -932,7 +932,7 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars ...@@ -932,7 +932,7 @@ void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars
clk = Abc_Clock(); clk = Abc_Clock();
if ( pPars->fUseDept ) if ( pPars->fUseDept )
{ {
if ( Vec_IntSize(p->vChanged) && pPars->BypassFreq == 0 ) if ( Vec_IntSize(p->vChanged) && !(pPars->BypassFreq && i && (i % pPars->BypassFreq) == 0) )
nConeSize = Abc_SclTimeIncUpdate( p ); nConeSize = Abc_SclTimeIncUpdate( p );
else else
Abc_SclTimeNtkRecompute( p, NULL, NULL, pPars->fUseDept, 0 ); Abc_SclTimeNtkRecompute( p, NULL, NULL, pPars->fUseDept, 0 );
......
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