Commit 8576e4b4 by Alan Mishchenko

Improvements to buffering and sizing.

parent 7a6f335e
......@@ -205,6 +205,7 @@ struct Abc_Ntk_t_
void * pData; // misc
Abc_Ntk_t * pCopy; // copy of this network
Vec_Int_t * vPhases; // fanins phases in the mapped netlist
char * pWLoadUsed; // wire load model used
float * pLutTimes; // arrivals/requireds/slacks using LUT-delay model
Vec_Ptr_t * vOnehots; // names of one-hot-encoded registers
Vec_Int_t * vObjPerm; // permutation saved
......
......@@ -325,6 +325,8 @@ void Abc_NtkFinalize( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
Abc_NtkTimeInitialize( pNtkNew, pNtk );
if ( pNtk->vPhases )
Abc_NtkTransferPhases( pNtkNew, pNtk );
if ( pNtk->pWLoadUsed )
pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
}
/**Function*************************************************************
......@@ -482,6 +484,8 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
Abc_NtkTimeInitialize( pNtkNew, pNtk );
if ( pNtk->vPhases )
Abc_NtkTransferPhases( pNtkNew, pNtk );
if ( pNtk->pWLoadUsed )
pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
// check correctness
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
......@@ -520,6 +524,8 @@ Abc_Ntk_t * Abc_NtkDupDfs( Abc_Ntk_t * pNtk )
Abc_NtkTimeInitialize( pNtkNew, pNtk );
if ( pNtk->vPhases )
Abc_NtkTransferPhases( pNtkNew, pNtk );
if ( pNtk->pWLoadUsed )
pNtkNew->pWLoadUsed = Abc_UtilStrsav( pNtk->pWLoadUsed );
// check correctness
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
......@@ -1346,6 +1352,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Vec_AttFree( (Vec_Att_t *)pAttrMan, 1 );
}
Vec_PtrFree( pNtk->vAttrs );
ABC_FREE( pNtk->pWLoadUsed );
ABC_FREE( pNtk->pName );
ABC_FREE( pNtk->pSpec );
ABC_FREE( pNtk->pLutTimes );
......
......@@ -904,13 +904,14 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
pPars->DelayGap = 0;
pPars->TimeOut = 0;
pPars->BuffTreeEst = 0;
pPars->BypassFreq = 0;
pPars->fUseDept = 1;
pPars->fUseWireLoads = 1;
pPars->fDumpStats = 0;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNDGTXcsdvwh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "IJWRNDGTXBcsdvwh" ) ) != EOF )
{
switch ( c )
{
......@@ -1011,6 +1012,17 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
if ( pPars->BuffTreeEst < 0 )
goto usage;
break;
case 'B':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-B\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->BypassFreq = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->BypassFreq < 0 )
goto usage;
break;
case 'c':
pPars->fUseWireLoads ^= 1;
break;
......@@ -1058,7 +1070,7 @@ int Scl_CommandUpsize( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
usage:
fprintf( pAbc->Err, "usage: upsize [-IJWRNDGTX num] [-csdvwh]\n" );
fprintf( pAbc->Err, "usage: upsize [-IJWRNDGTXB num] [-csdvwh]\n" );
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 );
......@@ -1069,6 +1081,7 @@ usage:
fprintf( pAbc->Err, "\t-G <num> : delay gap during updating, in picoseconds [default = %d]\n", pPars->DelayGap );
fprintf( pAbc->Err, "\t-T <num> : approximate timeout in seconds [default = %d]\n", pPars->TimeOut );
fprintf( pAbc->Err, "\t-X <num> : ratio for buffer tree estimation [default = %d]\n", pPars->BuffTreeEst );
fprintf( pAbc->Err, "\t-B <num> : frequency of bypass transforms [default = %d]\n", pPars->BypassFreq );
fprintf( pAbc->Err, "\t-c : toggle using wire-loads if specified [default = %s]\n", pPars->fUseWireLoads? "yes": "no" );
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" );
......
......@@ -113,7 +113,7 @@ static inline int Abc_SclObjIsBufInv( Abc_Obj_t * pObj )
{
return Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) == 1;
}
static inline int Abc_SclIsInv( Abc_Obj_t * pObj )
int Abc_SclIsInv( Abc_Obj_t * pObj )
{
assert( Abc_ObjIsNode(pObj) );
return Mio_GateReadTruth((Mio_Gate_t *)pObj->pData) == ABC_CONST(0x5555555555555555);
......@@ -315,7 +315,7 @@ int Abc_SclCheckNtk( Abc_Ntk_t * p, int fVerbose )
SeeAlso []
***********************************************************************/
void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj )
void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj, int fVerbose )
{
Abc_Obj_t * pFanout;
int i;
......@@ -323,12 +323,23 @@ void Abc_NodeInvUpdateFanPolarity( Abc_Obj_t * pObj )
Abc_ObjForEachFanout( pObj, pFanout, i )
{
if ( Abc_SclObjIsBufInv(pFanout) )
Abc_NodeInvUpdateFanPolarity( pFanout );
Abc_NodeInvUpdateFanPolarity( pFanout, fVerbose );
else
{
Abc_ObjFaninFlipPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) );
// if ( fVerbose )
// printf( "Flipping fanin %d of node %d.\n", Abc_NodeFindFanin(pFanout, pObj), Abc_ObjId(pFanout) );
}
}
}
void Abc_NodeInvUpdateObjFanoutPolarity( Abc_Obj_t * pObj, Abc_Obj_t * pFanout )
{
if ( Abc_SclObjIsBufInv(pFanout) )
Abc_NodeInvUpdateFanPolarity( pFanout, 1 );
else
Abc_ObjFaninFlipPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) );
// printf( "\n" );
}
int Abc_NodeCompareLevels( Abc_Obj_t ** pp1, Abc_Obj_t ** pp2 )
{
int Diff = Abc_ObjLevel(*pp1) - Abc_ObjLevel(*pp2);
......@@ -402,7 +413,7 @@ Abc_Obj_t * Abc_SclPerformBufferingOne( Abc_Obj_t * pObj, int Degree, int fUseIn
Abc_ObjAddFanin( pBuffer, pObj );
pBuffer->Level = Abc_SclComputeReverseLevel( pBuffer );
if ( fUseInvs )
Abc_NodeInvUpdateFanPolarity( pBuffer );
Abc_NodeInvUpdateFanPolarity( pBuffer, 0 );
return pBuffer;
}
void Abc_SclPerformBuffering_rec( Abc_Obj_t * pObj, int DegreeR, int Degree, int fUseInvs, int fVerbose )
......@@ -440,7 +451,7 @@ void Abc_SclPerformBuffering_rec( Abc_Obj_t * pObj, int DegreeR, int Degree, int
Abc_ObjAddFanin( pBuffer, pObj );
pBuffer->Level = Abc_SclComputeReverseLevel( pBuffer );
if ( fUseInvs )
Abc_NodeInvUpdateFanPolarity( pBuffer );
Abc_NodeInvUpdateFanPolarity( pBuffer, 0 );
}
// compute the new level of the node
pObj->Level = Abc_SclComputeReverseLevel( pObj );
......
......@@ -807,9 +807,25 @@ void Abc_SclLinkCells( SC_Lib * p )
SeeAlso []
***********************************************************************/
SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area )
SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pWLoadUsed )
{
SC_WireLoad * pWL = NULL;
int i;
// Get the actual table and reformat it for 'wire_cap' output:
assert( pWLoadUsed != NULL );
SC_LibForEachWireLoad( p, pWL, i )
if ( !strcmp(pWL->pName, pWLoadUsed) )
break;
if ( i == Vec_PtrSize(p->vWireLoads) )
{
Abc_Print( -1, "Cannot find wire load model \"%s\".\n", pWLoadUsed );
exit(1);
}
// printf( "Using wireload model \"%s\".\n", pWL->pName );
return pWL;
}
SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area )
{
char * pWLoadUsed = NULL;
int i;
if ( p->default_wire_load_sel && strlen(p->default_wire_load_sel) )
......@@ -839,18 +855,7 @@ SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area )
Abc_Print( 0, "No wire model given.\n" );
return NULL;
}
// Get the actual table and reformat it for 'wire_cap' output:
assert( pWLoadUsed != NULL );
SC_LibForEachWireLoad( p, pWL, i )
if ( !strcmp(pWL->pName, pWLoadUsed) )
break;
if ( i == Vec_PtrSize(p->vWireLoads) )
{
Abc_Print( -1, "Cannot find wire load model \"%s\".\n", pWLoadUsed );
exit(1);
}
// printf( "Using wireload model \"%s\".\n", pWL->pName );
return pWL;
return Abc_SclFetchWireLoadModel( p, pWLoadUsed );
}
/**Function*************************************************************
......
......@@ -71,6 +71,7 @@ struct SC_SizePars_
int DelayGap;
int TimeOut;
int BuffTreeEst; // ratio for buffer tree estimation
int BypassFreq; // frequency to try bypassing
int fUseDept;
int fDumpStats;
int fUseWireLoads;
......@@ -550,6 +551,7 @@ extern int Abc_SclClassCellNum( SC_Cell * pClass );
extern void Abc_SclLinkCells( SC_Lib * p );
extern void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain );
extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area );
extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName );
extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
ABC_NAMESPACE_HEADER_END
......
......@@ -37,7 +37,7 @@ ABC_NAMESPACE_IMPL_START
Description []
SideEffects []
SideEffects []`
SeeAlso []
......@@ -187,6 +187,23 @@ void Abc_SclUpdateLoad( SC_Man * p, Abc_Obj_t * pObj, SC_Cell * pOld, SC_Cell *
pLoad->fall += pPinNew->fall_cap - pPinOld->fall_cap;
}
}
void Abc_SclUpdateLoadSplit( SC_Man * p, Abc_Obj_t * pBuffer, Abc_Obj_t * pFanout )
{
SC_Pin * pPin;
SC_Pair * pLoad;
int iFanin = Abc_NodeFindFanin( pFanout, pBuffer );
assert( iFanin >= 0 );
assert( Abc_ObjFaninNum(pBuffer) == 1 );
pPin = SC_CellPin( Abc_SclObjCell(p, pFanout), iFanin );
// update load of the buffer
pLoad = Abc_SclObjLoad( p, pBuffer );
pLoad->rise -= pPin->rise_cap;
pLoad->fall -= pPin->fall_cap;
// update load of the fanin
pLoad = Abc_SclObjLoad( p, Abc_ObjFanin0(pBuffer) );
pLoad->rise += pPin->rise_cap;
pLoad->fall += pPin->fall_cap;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
......
......@@ -419,7 +419,7 @@ void Abc_SclManReadSlewAndLoad( SC_Man * p, Abc_Ntk_t * pNtk )
}
}
}
/**Function*************************************************************
Synopsis [Prepare timing manager.]
......@@ -443,7 +443,15 @@ SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, in
p->vGates = Abc_SclManFindGates( pLib, pNtk );
Abc_SclManReadSlewAndLoad( p, pNtk );
if ( fUseWireLoads )
p->pWLoadUsed = Abc_SclFindWireLoadModel( pLib, Abc_SclGetTotalArea(p) );
{
if ( pNtk->pWLoadUsed == NULL )
{
p->pWLoadUsed = Abc_SclFindWireLoadModel( pLib, Abc_SclGetTotalArea(p) );
pNtk->pWLoadUsed = Abc_UtilStrsav( p->pWLoadUsed->pName );
}
else
p->pWLoadUsed = Abc_SclFetchWireLoadModel( pLib, pNtk->pWLoadUsed );
}
Abc_SclTimeNtkRecompute( p, &p->SumArea0, &p->MaxDelay0, fDept, DUser );
p->SumArea = p->SumArea0;
return p;
......
......@@ -50,9 +50,11 @@ struct SC_Man_
Vec_Int_t * vGates; // mapping of objId into gateId
Vec_Int_t * vGatesBest; // best gate sizes found so far
Vec_Int_t * vUpdates; // sizing updates in this round
Vec_Int_t * vUpdates2; // sizing updates in this round
// timing information
SC_Pair * pLoads; // loads for each gate
SC_Pair * pLoads2; // loads for each gate
SC_Pair * pLoads3; // loads for each gate
SC_Pair * pDepts; // departures for each gate
SC_Pair * pTimes; // arrivals for each gate
SC_Pair * pSlews; // slews for each gate
......@@ -60,6 +62,7 @@ struct SC_Man_
SC_Pair * pSlews2; // slews for each gate
float * pSlack; // slacks for each gatt
float * pInDrive; // maximum input drive strength
Vec_Int_t * vBestFans; // best fanouts
Vec_Flt_t * vTimesOut; // output arrival times
Vec_Que_t * vQue; // outputs by their time
SC_WireLoad * pWLoadUsed; // name of the used WireLoad model
......@@ -101,6 +104,7 @@ static inline void Abc_SclObjSetCell( SC_Man * p, Abc_Obj_t * pObj, SC_Cell
static inline SC_Pair * Abc_SclObjLoad( SC_Man * p, Abc_Obj_t * pObj ) { return p->pLoads + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjLoad2( SC_Man * p, Abc_Obj_t * pObj ) { return p->pLoads2 + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjLoad3( SC_Man * p, Abc_Obj_t * pObj ) { return p->pLoads3 + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjDept( SC_Man * p, Abc_Obj_t * pObj ) { return p->pDepts + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjTime( SC_Man * p, Abc_Obj_t * pObj ) { return p->pTimes + Abc_ObjId(pObj); }
static inline SC_Pair * Abc_SclObjSlew( SC_Man * p, Abc_Obj_t * pObj ) { return p->pSlews + Abc_ObjId(pObj); }
......@@ -150,18 +154,21 @@ static inline SC_Man * Abc_SclManAlloc( SC_Lib * pLib, Abc_Ntk_t * pNtk )
p->nObjs = Abc_NtkObjNumMax(pNtk);
p->pLoads = ABC_CALLOC( SC_Pair, p->nObjs );
p->pLoads2 = ABC_CALLOC( SC_Pair, p->nObjs );
p->pLoads3 = ABC_CALLOC( SC_Pair, p->nObjs );
p->pDepts = ABC_CALLOC( SC_Pair, p->nObjs );
p->pTimes = ABC_CALLOC( SC_Pair, p->nObjs );
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->vBestFans = Vec_IntStart( p->nObjs );
p->vTimesOut = Vec_FltStart( Abc_NtkCoNum(pNtk) );
p->vQue = Vec_QueAlloc( Abc_NtkCoNum(pNtk) );
Vec_QueSetCosts( p->vQue, Vec_FltArrayP(p->vTimesOut) );
for ( i = 0; i < Abc_NtkCoNum(pNtk); i++ )
Vec_QuePush( p->vQue, i );
p->vUpdates = Vec_IntAlloc( 1000 );
p->vUpdates2 = Vec_IntAlloc( 1000 );
// intermediate data
p->vNode2Gain = Vec_FltStart( p->nObjs );
p->vNode2Gate = Vec_IntStart( p->nObjs );
......@@ -178,14 +185,17 @@ static inline void Abc_SclManFree( SC_Man * p )
Vec_IntFreeP( &p->vNode2Gate );
// intermediate data
Vec_IntFreeP( &p->vUpdates );
Vec_IntFreeP( &p->vUpdates2 );
Vec_IntFreeP( &p->vGatesBest );
// Vec_QuePrint( p->vQue );
Vec_QueCheck( p->vQue );
Vec_QueFreeP( &p->vQue );
Vec_FltFreeP( &p->vTimesOut );
Vec_IntFreeP( &p->vGates );
Vec_IntFreeP( &p->vBestFans );
ABC_FREE( p->pLoads );
ABC_FREE( p->pLoads2 );
ABC_FREE( p->pLoads3 );
ABC_FREE( p->pDepts );
ABC_FREE( p->pTimes );
ABC_FREE( p->pSlews );
......@@ -289,6 +299,23 @@ static inline void Abc_SclLoadRestore( SC_Man * p, Abc_Obj_t * pObj )
*Abc_SclObjLoad(p, pFanin) = *Abc_SclObjLoad2(p, pFanin);
}
static inline void Abc_SclLoadStore3( SC_Man * p, Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin;
int i;
*Abc_SclObjLoad3(p, pObj) = *Abc_SclObjLoad(p, pObj);
Abc_ObjForEachFanin( pObj, pFanin, i )
*Abc_SclObjLoad3(p, pFanin) = *Abc_SclObjLoad(p, pFanin);
}
static inline void Abc_SclLoadRestore3( SC_Man * p, Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin;
int i;
*Abc_SclObjLoad(p, pObj) = *Abc_SclObjLoad3(p, pObj);
Abc_ObjForEachFanin( pObj, pFanin, i )
*Abc_SclObjLoad(p, pFanin) = *Abc_SclObjLoad3(p, pFanin);
}
/**Function*************************************************************
Synopsis []
......@@ -394,6 +421,8 @@ static inline void Abc_SclDumpStats( SC_Man * p, char * pFileName, abctime Time
/*=== sclBuffer.c ===============================================================*/
extern int Abc_SclIsInv( Abc_Obj_t * pObj );
extern void Abc_NodeInvUpdateObjFanoutPolarity( Abc_Obj_t * pObj, Abc_Obj_t * pFanout );
extern Abc_Ntk_t * Abc_SclUnBufferPerform( Abc_Ntk_t * pNtk, int fVerbose );
extern Abc_Ntk_t * Abc_SclUnBufferPhase( Abc_Ntk_t * pNtk, int fVerbose );
extern Abc_Ntk_t * Abc_SclBufferPhase( Abc_Ntk_t * pNtk, int fVerbose );
......@@ -405,6 +434,7 @@ extern void Abc_SclDnsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_S
/*=== sclLoad.c ===============================================================*/
extern void Abc_SclComputeLoad( SC_Man * p );
extern void Abc_SclUpdateLoad( SC_Man * p, Abc_Obj_t * pObj, SC_Cell * pOld, SC_Cell * pNew );
extern void Abc_SclUpdateLoadSplit( SC_Man * p, Abc_Obj_t * pBuffer, Abc_Obj_t * pFanout );
/*=== sclSize.c ===============================================================*/
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 );
......
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