Commit f8410b53 by Alan Mishchenko

Improvements to buffering and sizing.

parent 2c7f3902
...@@ -442,6 +442,9 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At ...@@ -442,6 +442,9 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
#define Abc_NtkForEachObj( pNtk, pObj, i ) \ #define Abc_NtkForEachObj( pNtk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pObj) = Abc_NtkObj(pNtk, i)), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize((pNtk)->vObjs)) && (((pObj) = Abc_NtkObj(pNtk, i)), 1); i++ ) \
if ( (pObj) == NULL ) {} else if ( (pObj) == NULL ) {} else
#define Abc_NtkForEachObjReverse( pNtk, pNode, i ) \
for ( i = Vec_PtrSize((pNtk)->vObjs) - 1; (i >= 0) && (((pNode) = Abc_NtkObj(pNtk, i)), 1); i-- ) \
if ( (pNode) == NULL ) {} else
#define Abc_NtkForEachObjVec( vIds, pNtk, pObj, i ) \ #define Abc_NtkForEachObjVec( vIds, pNtk, pObj, i ) \
for ( i = 0; i < Vec_IntSize(vIds) && (((pObj) = Abc_NtkObj(pNtk, Vec_IntEntry(vIds,i))), 1); i++ ) \ for ( i = 0; i < Vec_IntSize(vIds) && (((pObj) = Abc_NtkObj(pNtk, Vec_IntEntry(vIds,i))), 1); i++ ) \
if ( (pObj) == NULL ) {} else if ( (pObj) == NULL ) {} else
......
...@@ -988,12 +988,12 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -988,12 +988,12 @@ void Abc_Init( Abc_Frame_t * pAbc )
Dar_LibStart(); Dar_LibStart();
} }
{ {
extern void Dau_DsdTest(); // extern void Dau_DsdTest();
Dau_DsdTest(); // Dau_DsdTest();
} }
if ( Sdm_ManCanRead() ) // if ( Sdm_ManCanRead() )
Sdm_ManRead(); // Sdm_ManRead();
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -946,11 +946,11 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -946,11 +946,11 @@ int Scl_CommandBufSize( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
int c; int c;
memset( pPars, 0, sizeof(SC_BusPars) ); memset( pPars, 0, sizeof(SC_BusPars) );
pPars->GainRatio = 200; pPars->GainRatio = 1000;
pPars->Slew = 100; pPars->Slew = 100;
pPars->nDegree = 8; pPars->nDegree = 10;
pPars->fSizeOnly = 0; pPars->fSizeOnly = 0;
pPars->fAddBufs = 0; pPars->fAddBufs = 1;
pPars->fBufPis = 0; pPars->fBufPis = 0;
pPars->fUseWireLoads = 1; pPars->fUseWireLoads = 1;
pPars->fVerbose = 0; pPars->fVerbose = 0;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "sclSize.h" #include "sclSize.h"
#include "map/mio/mio.h" #include "map/mio/mio.h"
#include "base/main/main.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
...@@ -34,6 +35,7 @@ struct Bus_Man_t_ ...@@ -34,6 +35,7 @@ struct Bus_Man_t_
// user data // user data
SC_BusPars * pPars; // parameters SC_BusPars * pPars; // parameters
Abc_Ntk_t * pNtk; // user's network Abc_Ntk_t * pNtk; // user's network
SC_Cell * pPiDrive; // PI driver
// library // library
SC_Lib * pLib; // cell library SC_Lib * pLib; // cell library
SC_Cell * pInv; // base interter (largest/average/???) SC_Cell * pInv; // base interter (largest/average/???)
...@@ -93,10 +95,10 @@ Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars ) ...@@ -93,10 +95,10 @@ Bus_Man_t * Bus_ManStart( Abc_Ntk_t * pNtk, SC_Lib * pLib, SC_BusPars * pPars )
} }
if ( p->pWLoadUsed ) if ( p->pWLoadUsed )
p->vWireCaps = Abc_SclFindWireCaps( p->pWLoadUsed ); p->vWireCaps = Abc_SclFindWireCaps( p->pWLoadUsed );
p->vCins = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 ); p->vCins = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
p->vETimes = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 ); p->vETimes = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
p->vLoads = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 ); p->vLoads = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
p->vDepts = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 1000 ); p->vDepts = Vec_FltStart( 2*Abc_NtkObjNumMax(pNtk) + 10000 );
p->vFanouts = Vec_PtrAlloc( 100 ); p->vFanouts = Vec_PtrAlloc( 100 );
pNtk->pBSMan = p; pNtk->pBSMan = p;
return p; return p;
...@@ -125,46 +127,28 @@ void Bus_ManStop( Bus_Man_t * p ) ...@@ -125,46 +127,28 @@ void Bus_ManStop( Bus_Man_t * p )
***********************************************************************/ ***********************************************************************/
void Bus_ManReadInOutLoads( Bus_Man_t * p ) void Bus_ManReadInOutLoads( Bus_Man_t * p )
{ {
Abc_Time_t * pTime; if ( Abc_FrameReadMaxLoad() )
Abc_Obj_t * pObj;
int i;
if ( p->pNtk->pManTime == NULL )
return;
// read input load
pTime = Abc_NtkReadDefaultInputDrive( p->pNtk );
if ( Abc_MaxFloat(pTime->Rise, pTime->Fall) != 0 )
{
printf( "Default input drive strength is specified (%.2f ff; %.2f ff).\n", pTime->Rise, pTime->Fall );
Abc_NtkForEachPi( p->pNtk, pObj, i )
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) );
}
if ( Abc_NodeReadInputDrive(p->pNtk, 0) != NULL )
{
printf( "Input drive strengths for some primary inputs are specified.\n" );
Abc_NtkForEachPi( p->pNtk, pObj, i )
{ {
pTime = Abc_NodeReadInputDrive(p->pNtk, i); Abc_Obj_t * pObj; int i;
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) ); float MaxLoad = Abc_FrameReadMaxLoad();
}
}
// read output load
pTime = Abc_NtkReadDefaultOutputLoad( p->pNtk );
if ( Abc_MaxFloat(pTime->Rise, pTime->Fall) != 0 )
{
printf( "Default output load is specified (%.2f ff; %.2f ff).\n", pTime->Rise, pTime->Fall );
Abc_NtkForEachPo( p->pNtk, pObj, i ) Abc_NtkForEachPo( p->pNtk, pObj, i )
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) ); Bus_SclObjSetCin( pObj, MaxLoad );
printf( "Default output load is specified (%f ff).\n", SC_LibCapFf(p->pLib, MaxLoad) );
} }
if ( Abc_NodeReadOutputLoad(p->pNtk, 0) != NULL ) if ( Abc_FrameReadDrivingCell() )
{ {
printf( "Output loads for some primary outputs are specified.\n" ); int iCell = Abc_SclCellFind( p->pLib, Abc_FrameReadDrivingCell() );
Abc_NtkForEachPo( p->pNtk, pObj, i ) if ( iCell == -1 )
printf( "Cannot find the default PI driving cell (%s) in the library.\n", Abc_FrameReadDrivingCell() );
else
{ {
pTime = Abc_NodeReadOutputLoad(p->pNtk, i); // printf( "Default PI driving cell is specified (%s).\n", Abc_FrameReadDrivingCell() );
Bus_SclObjSetCin( pObj, SC_LibCapFromFf(p->pLib, 0.5 * pTime->Rise + 0.5 * pTime->Fall) ); p->pPiDrive = SC_LibCell( p->pLib, iCell );
assert( p->pPiDrive != NULL );
assert( p->pPiDrive->n_inputs == 1 );
printf( "Default input driving cell is specified (%s).\n", p->pPiDrive->pName );
} }
} }
// read arrival/required times
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -205,7 +189,7 @@ void Abc_NtkComputeFanoutInfo( Abc_Obj_t * pObj, float Slew ) ...@@ -205,7 +189,7 @@ void Abc_NtkComputeFanoutInfo( Abc_Obj_t * pObj, float Slew )
Abc_ObjForEachFanout( pObj, pFanout, i ) Abc_ObjForEachFanout( pObj, pFanout, i )
if ( !Abc_ObjIsCo(pFanout) ) if ( !Abc_ObjIsCo(pFanout) )
{ {
int iFanin = Abc_NodeFindFanin(pFanout, pObj);; int iFanin = Abc_NodeFindFanin(pFanout, pObj);
Bus_SclObjSetETime( pFanout, Abc_NtkComputeEdgeDept(pFanout, iFanin, Slew) ); Bus_SclObjSetETime( pFanout, Abc_NtkComputeEdgeDept(pFanout, iFanin, Slew) );
Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), iFanin ) ); Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), iFanin ) );
} }
...@@ -252,7 +236,9 @@ void Abc_NtkPrintFanoutProfileVec( Abc_Obj_t * pObj, Vec_Ptr_t * vFanouts ) ...@@ -252,7 +236,9 @@ void Abc_NtkPrintFanoutProfileVec( Abc_Obj_t * pObj, Vec_Ptr_t * vFanouts )
Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i ) Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
{ {
printf( "%3d : time = %7.2f ps load = %7.2f ff ", i, Bus_SclObjETime(pFanout), Bus_SclObjCin(pFanout) ); printf( "%3d : time = %7.2f ps load = %7.2f ff ", i, Bus_SclObjETime(pFanout), Bus_SclObjCin(pFanout) );
printf( "%s\n", (pObj && Abc_ObjFanoutNum(pObj) == Vec_PtrSize(vFanouts) && Abc_ObjFaninPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) )) ? "*" : " " ); if ( pObj->pNtk->vPhases )
printf( "%s", (pObj && Abc_ObjFanoutNum(pObj) == Vec_PtrSize(vFanouts) && Abc_ObjFaninPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) )) ? "*" : " " );
printf( "\n" );
} }
printf( "\n" ); printf( "\n" );
} }
...@@ -400,15 +386,25 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -400,15 +386,25 @@ void Abc_SclBufSize( Bus_Man_t * p )
float Load, LoadNew, Cin, DeptMax = 0; float Load, LoadNew, Cin, DeptMax = 0;
int i, k, nObjOld = Abc_NtkObjNumMax(p->pNtk); int i, k, nObjOld = Abc_NtkObjNumMax(p->pNtk);
Abc_SclMioGates2SclGates( p->pLib, p->pNtk ); Abc_SclMioGates2SclGates( p->pLib, p->pNtk );
Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i ) Abc_NtkForEachObjReverse( p->pNtk, pObj, i )
{ {
if ( !((Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0) || (Abc_ObjIsCi(pObj) && p->pPiDrive)) )
continue;
// compute load // compute load
Abc_NtkComputeFanoutInfo( pObj, p->pPars->Slew ); Abc_NtkComputeFanoutInfo( pObj, p->pPars->Slew );
Load = Abc_NtkComputeNodeLoad( p, pObj ); Load = Abc_NtkComputeNodeLoad( p, pObj );
// consider the gate // consider the gate
if ( Abc_ObjIsCi(pObj) )
{
pCell = p->pPiDrive;
Cin = SC_CellPinCapAve( pCell );
}
else
{
pCell = Abc_SclObjCell( pObj ); pCell = Abc_SclObjCell( pObj );
Cin = SC_CellPinCapAve( pCell->pAve ); Cin = SC_CellPinCapAve( pCell->pAve );
// Cin = SC_CellPinCapAve( pCell->pRepr->pNext ); // Cin = SC_CellPinCapAve( pCell->pRepr->pNext );
}
// consider upsizing the gate // consider upsizing the gate
if ( !p->pPars->fSizeOnly && (Abc_ObjFanoutNum(pObj) > p->pPars->nDegree || Load > GainGate * Cin) ) if ( !p->pPars->fSizeOnly && (Abc_ObjFanoutNum(pObj) > p->pPars->nDegree || Load > GainGate * Cin) )
{ {
...@@ -427,7 +423,7 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -427,7 +423,7 @@ void Abc_SclBufSize( Bus_Man_t * p )
Bus_SclInsertFanout( p->vFanouts, pInv ); Bus_SclInsertFanout( p->vFanouts, pInv );
Load = Abc_NtkComputeFanoutLoad( p, p->vFanouts ); Load = Abc_NtkComputeFanoutLoad( p, p->vFanouts );
} }
while ( Vec_PtrSize(p->vFanouts) > p->pPars->nDegree || Load > GainGate * Cin ); while ( Vec_PtrSize(p->vFanouts) > p->pPars->nDegree || (Vec_PtrSize(p->vFanouts) > 1 && Load > GainGate * Cin) );
// update node fanouts // update node fanouts
Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanouts, pFanout, k ) Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanouts, pFanout, k )
if ( Abc_ObjFaninNum(pFanout) == 0 ) if ( Abc_ObjFaninNum(pFanout) == 0 )
...@@ -436,6 +432,8 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -436,6 +432,8 @@ void Abc_SclBufSize( Bus_Man_t * p )
LoadNew = Abc_NtkComputeNodeLoad( p, pObj ); LoadNew = Abc_NtkComputeNodeLoad( p, pObj );
assert( LoadNew - Load < 1 && Load - LoadNew < 1 ); assert( LoadNew - Load < 1 && Load - LoadNew < 1 );
} }
if ( Abc_ObjIsCi(pObj) )
continue;
Abc_NtkComputeNodeDeparture( pObj, p->pPars->Slew ); Abc_NtkComputeNodeDeparture( pObj, p->pPars->Slew );
// create cell // create cell
pCellNew = Abc_SclFindSmallestGate( pCell, Load / GainGate ); pCellNew = Abc_SclFindSmallestGate( pCell, Load / GainGate );
...@@ -444,12 +442,23 @@ void Abc_SclBufSize( Bus_Man_t * p ) ...@@ -444,12 +442,23 @@ void Abc_SclBufSize( Bus_Man_t * p )
Abc_SclOneNodePrint( p, pObj ); Abc_SclOneNodePrint( p, pObj );
assert( p->pPars->fSizeOnly || Abc_ObjFanoutNum(pObj) <= p->pPars->nDegree ); assert( p->pPars->fSizeOnly || Abc_ObjFanoutNum(pObj) <= p->pPars->nDegree );
} }
// compute departure time of the PI
Abc_NtkForEachCi( p->pNtk, pObj, i ) Abc_NtkForEachCi( p->pNtk, pObj, i )
DeptMax = Abc_MaxFloat( DeptMax, Abc_NtkComputeNodeDeparture(pObj, p->pPars->Slew) ); {
float DeptCur = Abc_NtkComputeNodeDeparture(pObj, p->pPars->Slew);
if ( p->pPiDrive )
{
float Load = Bus_SclObjLoad( pObj );
SC_Pair ArrOut, SlewOut, LoadIn = { Load, Load };
Scl_LibHandleInputDriver( p->pPiDrive, &LoadIn, &ArrOut, &SlewOut );
DeptCur += 0.5 * ArrOut.fall + 0.5 * ArrOut.rise;
}
DeptMax = Abc_MaxFloat( DeptMax, DeptCur );
}
Abc_SclSclGates2MioGates( p->pLib, p->pNtk ); Abc_SclSclGates2MioGates( p->pLib, p->pNtk );
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
{ {
printf( "WireLoads = %d. Degree = %d. Target gain =%5d Slew =%5d Inv = %6d Delay =%7.0f ps ", printf( "WireLoads = %d. Degree = %d. Target gain =%5d Slew =%5d Buf = %6d Delay =%7.0f ps ",
p->pPars->fUseWireLoads, p->pPars->nDegree, p->pPars->GainRatio, p->pPars->Slew, p->pPars->fUseWireLoads, p->pPars->nDegree, p->pPars->GainRatio, p->pPars->Slew,
Abc_NtkObjNumMax(p->pNtk) - nObjOld, SC_LibTimePs(p->pLib, DeptMax) ); Abc_NtkObjNumMax(p->pNtk) - nObjOld, SC_LibTimePs(p->pLib, DeptMax) );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
......
...@@ -123,7 +123,7 @@ static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise ...@@ -123,7 +123,7 @@ static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise
printf( "Cout =%6.1f ff ", Abc_SclObjLoadFf(p, pObj, fRise >= 0 ? fRise : 0) ); printf( "Cout =%6.1f ff ", Abc_SclObjLoadFf(p, pObj, fRise >= 0 ? fRise : 0) );
printf( "Cmax =%6.1f ff ", pCell ? SC_LibCapFf(p->pLib, SC_CellPin(pCell, pCell->n_inputs)->max_out_cap) : 0.0 ); printf( "Cmax =%6.1f ff ", pCell ? SC_LibCapFf(p->pLib, SC_CellPin(pCell, pCell->n_inputs)->max_out_cap) : 0.0 );
printf( "G =%5d ", pCell ? (int)(100.0 * Abc_SclObjLoadAve(p, pObj) / SC_CellPinCapAve(pCell)) : 0 ); printf( "G =%5d ", pCell ? (int)(100.0 * Abc_SclObjLoadAve(p, pObj) / SC_CellPinCapAve(pCell)) : 0 );
printf( "SL =%6.1f ps", Abc_SclObjSlackPs(p, pObj, p->MaxDelay0) ); // printf( "SL =%6.1f ps", Abc_SclObjSlackPs(p, pObj, p->MaxDelay0) );
printf( "\n" ); printf( "\n" );
} }
void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath ) void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
......
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