54static inline float Bus_SclObjCin(
Abc_Obj_t *
p ) {
return Vec_FltEntry( Bus_SclObjMan(
p)->vCins, Abc_ObjId(
p) ); }
55static inline void Bus_SclObjSetCin(
Abc_Obj_t *
p,
float cap ) { Vec_FltWriteEntry( Bus_SclObjMan(
p)->vCins, Abc_ObjId(
p), cap ); }
56static inline float Bus_SclObjETime(
Abc_Obj_t *
p ) {
return Vec_FltEntry( Bus_SclObjMan(
p)->vETimes, Abc_ObjId(
p) ); }
57static inline void Bus_SclObjSetETime(
Abc_Obj_t *
p,
float time ) { Vec_FltWriteEntry( Bus_SclObjMan(
p)->vETimes, Abc_ObjId(
p), time ); }
58static inline float Bus_SclObjLoad(
Abc_Obj_t *
p ) {
return Vec_FltEntry( Bus_SclObjMan(
p)->vLoads, Abc_ObjId(
p) ); }
59static inline void Bus_SclObjSetLoad(
Abc_Obj_t *
p,
float cap ) { Vec_FltWriteEntry( Bus_SclObjMan(
p)->vLoads, Abc_ObjId(
p), cap ); }
60static inline float Bus_SclObjDept(
Abc_Obj_t *
p ) {
return Vec_FltEntry( Bus_SclObjMan(
p)->vDepts, Abc_ObjId(
p) ); }
61static inline void Bus_SclObjUpdateDept(
Abc_Obj_t *
p,
float time ) {
float *q = Vec_FltEntryP( Bus_SclObjMan(
p)->vDepts, Abc_ObjId(
p) );
if (*q < time) *q = time; }
92 pNtk->
pWLoadUsed = Abc_UtilStrsav(
p->pWLoadUsed->pName );
99 p->vFanouts = Vec_PtrAlloc( 100 );
100 p->vCins = Vec_FltAlloc( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
101 p->vETimes = Vec_FltAlloc( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
102 p->vLoads = Vec_FltAlloc( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
103 p->vDepts = Vec_FltAlloc( 2*Abc_NtkObjNumMax(pNtk) + 1000 );
104 Vec_FltFill(
p->vCins, Abc_NtkObjNumMax(pNtk), 0 );
105 Vec_FltFill(
p->vETimes, Abc_NtkObjNumMax(pNtk), 0 );
106 Vec_FltFill(
p->vLoads, Abc_NtkObjNumMax(pNtk), 0 );
107 Vec_FltFill(
p->vDepts, Abc_NtkObjNumMax(pNtk), 0 );
113 Vec_PtrFreeP( &
p->vFanouts );
114 Vec_FltFreeP( &
p->vWireCaps );
115 Vec_FltFreeP( &
p->vCins );
116 Vec_FltFreeP( &
p->vETimes );
117 Vec_FltFreeP( &
p->vLoads );
118 Vec_FltFreeP( &
p->vDepts );
140 Bus_SclObjSetCin( pObj, MaxLoad );
151 p->pPiDrive = SC_LibCell(
p->pLib, iCell );
153 assert(
p->pPiDrive->n_inputs == 1 );
170static inline float Abc_NtkComputeEdgeDept(
Abc_Obj_t * pFanout,
int iFanin,
float Slew )
172 float Load = Bus_SclObjLoad( pFanout );
173 float Dept = Bus_SclObjDept( pFanout );
174 float Edge = Scl_LibPinArrivalEstimate( Abc_SclObjCell(pFanout), iFanin, Slew, Load );
182 assert( Bus_SclObjDept(pObj) == 0 );
185 if ( Abc_ObjIsBarBuf(pFanout) )
186 Bus_SclObjUpdateDept( pObj, Bus_SclObjDept(pFanout) );
187 else if ( !Abc_ObjIsCo(pFanout) )
188 Bus_SclObjUpdateDept( pObj, Abc_NtkComputeEdgeDept(pFanout,
Abc_NodeFindFanin(pFanout, pObj), Slew) );
190 return Bus_SclObjDept( pObj );
198 if ( Abc_ObjIsBarBuf(pFanout) )
200 Bus_SclObjSetETime( pFanout, Bus_SclObjDept(pFanout) );
201 Bus_SclObjSetCin( pFanout, Bus_SclObjLoad(pFanout) );
203 else if ( !Abc_ObjIsCo(pFanout) )
206 Bus_SclObjSetETime( pFanout, Abc_NtkComputeEdgeDept(pFanout, iFanin, Slew) );
207 Bus_SclObjSetCin( pFanout, SC_CellPinCap( Abc_SclObjCell(pFanout), iFanin ) );
216 assert( Bus_SclObjLoad(pObj) == 0 );
219 Load += Bus_SclObjCin( pFanout );
220 Bus_SclObjSetLoad( pObj, Load );
230 Load += Bus_SclObjCin( pFanout );
237 printf(
"Obj %6d fanouts (%d):\n", Abc_ObjId(pObj), Abc_ObjFanoutNum(pObj) );
240 printf(
"%3d : time = %7.2f ps load = %7.2f ff ", i, Bus_SclObjETime(pFanout), Bus_SclObjCin(pFanout) );
241 printf(
"%s\n", Abc_ObjFaninPhase( pFanout,
Abc_NodeFindFanin(pFanout, pObj) ) ?
"*" :
" " );
249 printf(
"Fanout profile (%d):\n", Vec_PtrSize(vFanouts) );
252 printf(
"%3d : time = %7.2f ps load = %7.2f ff ", i, Bus_SclObjETime(pFanout), Bus_SclObjCin(pFanout) );
254 printf(
"%s", (pObj && Abc_ObjFanoutNum(pObj) == Vec_PtrSize(vFanouts) && Abc_ObjFaninPhase( pFanout,
Abc_NodeFindFanin(pFanout, pObj) )) ?
"*" :
" " );
274 if ( Bus_SclObjETime(*pp1) < Bus_SclObjETime(*pp2) - Espilon )
276 if ( Bus_SclObjETime(*pp1) > Bus_SclObjETime(*pp2) + Espilon )
278 if ( Bus_SclObjCin(*pp1) > Bus_SclObjCin(*pp2) )
280 if ( Bus_SclObjCin(*pp1) < Bus_SclObjCin(*pp2) )
289 for ( i = k = 0; i < Vec_PtrSize(vFanouts); i++ )
290 if ( Vec_PtrEntry(vFanouts, i) != NULL )
291 Vec_PtrWriteEntry( vFanouts, k++, Vec_PtrEntry(vFanouts, i) );
292 Vec_PtrShrink( vFanouts, k );
294 Vec_PtrPush( vFanouts, pObj );
295 for ( i = Vec_PtrSize(vFanouts) - 1; i > 0; i-- )
297 pCur = (
Abc_Obj_t *)Vec_PtrEntry(vFanouts, i-1);
298 pObj = (
Abc_Obj_t *)Vec_PtrEntry(vFanouts, i);
301 ABC_SWAP(
void *, Vec_PtrArray(vFanouts)[i-1], Vec_PtrArray(vFanouts)[i] );
308 for ( i = 0; i < Vec_PtrSize(vFanouts) - 1; i++ )
310 pObj = (
Abc_Obj_t *)Vec_PtrEntry(vFanouts, i);
311 pNext = (
Abc_Obj_t *)Vec_PtrEntry(vFanouts, i+1);
314 printf(
"Fanouts %d and %d are out of order.\n", i, i+1 );
334 SC_Cell * pCell = Abc_SclObjCell(pObj);
335 printf(
"%s%7d : ", (Abc_ObjFaninNum(pObj) == 0) ?
" Inv" :
"Node", Abc_ObjId(pObj) );
336 printf(
"%d/%2d ", Abc_ObjFaninNum(pObj) ? Abc_ObjFaninNum(pObj) : 1, Abc_ObjFanoutNum(pObj) );
337 printf(
"%12s ", pCell->
pName );
338 printf(
"(%2d/%2d) ", pCell->
Order, pCell->
nGates );
339 printf(
"gain =%5d ", (
int)(100.0 * Bus_SclObjLoad(pObj) / SC_CellPinCapAve(pCell)) );
340 printf(
"dept =%7.0f ps ", Bus_SclObjDept(pObj) );
347 float Target = SC_CellPinCap(
p->pInv, 0) * Gain;
348 float LoadWirePrev, LoadWireThis, Load = 0;
349 int Limit = Abc_MinInt(
p->pPars->nDegree, Vec_PtrSize(vFanouts) );
356 Load += Bus_SclObjCin( pFanout ) - LoadWirePrev + LoadWireThis;
364 if (
p->pPars->fAddBufs )
368 assert( (
int)Abc_ObjId(pInv) == Vec_FltSize(
p->vCins) );
369 Vec_FltPush(
p->vCins, 0 );
370 Vec_FltPush(
p->vETimes, 0 );
371 Vec_FltPush(
p->vLoads, 0 );
372 Vec_FltPush(
p->vDepts, 0 );
373 Limit = Abc_MinInt( Abc_MaxInt(iStop, 2), Vec_PtrSize(vFanouts) );
376 Vec_PtrWriteEntry( vFanouts, i, NULL );
377 if ( Abc_ObjFaninNum(pFanout) == 0 )
384 Vec_IntSetEntry(
p->pNtk->vGates, Abc_ObjId(pInv), pCellNew->
Id );
389 Bus_SclObjSetCin( pInv, SC_CellPinCap(pCellNew, 0) );
390 Bus_SclObjSetETime( pInv, Abc_NtkComputeEdgeDept(pInv, 0,
p->pPars->Slew) );
401 int i, k, nObjsOld = Abc_NtkObjNumMax(
p->pNtk);
402 float GainGate, GainInv, Load, Cin, DeptMax = 0;
403 GainGate =
p->pPars->fAddBufs ? (float)pow( (
double)Gain, (
double)2.0 ) : Gain;
404 GainInv =
p->pPars->fAddBufs ? (float)pow( (
double)Gain, (
double)2.0 ) : Gain;
407 if ( !((Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0) || (Abc_ObjIsCi(pObj) &&
p->pPiDrive)) )
409 if ( 2 * nObjsOld < Abc_NtkObjNumMax(
p->pNtk) )
411 printf(
"Buffering could not be completed because the gain value (%d) is too low.\n",
p->pPars->GainRatio );
418 if ( Abc_ObjIsCi(pObj) || Abc_ObjIsBarBuf(pObj) )
423 Cin = pCell ? SC_CellPinCapAve(pCell) : Load;
427 pCell = Abc_SclObjCell( pObj );
428 Cin = SC_CellPinCapAve( pCell->
pAve );
432 if ( !
p->pPars->fSizeOnly && (Abc_ObjFanoutNum(pObj) >
p->pPars->nDegree || Load > GainGate * Cin) )
441 if (
p->pPars->fVeryVerbose )
444 if (
p->pPars->fVeryVerbose )
449 while ( Vec_PtrSize(
p->vFanouts) >
p->pPars->nDegree || (Vec_PtrSize(
p->vFanouts) > 1 && Load > GainGate * Cin) );
452 if ( Abc_ObjFaninNum(pFanout) == 0 )
454 Bus_SclObjSetLoad( pObj, 0 );
457 if ( Abc_ObjIsCi(pObj) )
460 if ( Abc_ObjIsBarBuf(pObj) )
464 Abc_SclObjSetCell( pObj, pCellNew );
465 if (
p->pPars->fVeryVerbose )
467 assert(
p->pPars->fSizeOnly || Abc_ObjFanoutNum(pObj) <=
p->pPars->nDegree );
476 float Load = Bus_SclObjLoad( pObj );
477 SC_Pair ArrOut, SlewOut, LoadIn = { Load, Load };
478 Scl_LibHandleInputDriver(
p->pPiDrive, &LoadIn, &ArrOut, &SlewOut );
479 DeptCur += 0.5 * ArrOut.
fall + 0.5 * ArrOut.
rise;
481 DeptMax = Abc_MaxFloat( DeptMax, DeptCur );
483 if (
p->pPars->fVerbose )
485 printf(
"WireLoads = %d Degree = %d Target slew =%4d ps Gain2 =%5d Buf = %6d Delay =%7.0f ps ",
486 p->pPars->fUseWireLoads,
p->pPars->nDegree,
p->pPars->Slew,
p->pPars->GainRatio,
487 Abc_NtkObjNumMax(
p->pNtk) - nObjsOld, DeptMax );
488 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
505 Vec_IntFillExtra( pNtk->
vPhases, Abc_NtkObjNumMax(pNtk), 0 );
ABC_DLL Abc_Ntk_t * Abc_NtkDupDfs(Abc_Ntk_t *pNtk)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
struct Abc_Ntk_t_ Abc_Ntk_t
#define Abc_NtkForEachObjReverse(pNtk, pNode, i)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
ABC_DLL int Abc_NtkGetFanoutMax(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
#define ABC_SWAP(Type, a, b)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL float Abc_FrameReadMaxLoad()
ABC_DLL char * Abc_FrameReadDrivingCell()
void Bus_SclCheckSortedFanout(Vec_Ptr_t *vFanouts)
Abc_Ntk_t * Abc_SclBufferingPerform(Abc_Ntk_t *pNtk, SC_Lib *pLib, SC_BusPars *pPars)
void Bus_ManStop(Bus_Man_t *p)
typedefABC_NAMESPACE_IMPL_START struct Bus_Man_t_ Bus_Man_t
DECLARATIONS ///.
int Bus_SclCompareFanouts(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
void Abc_NtkPrintFanoutProfileVec(Abc_Obj_t *pObj, Vec_Ptr_t *vFanouts)
void Abc_NtkComputeFanoutInfo(Abc_Obj_t *pObj, float Slew)
void Bus_SclInsertFanout(Vec_Ptr_t *vFanouts, Abc_Obj_t *pObj)
Abc_Obj_t * Abc_SclAddOneInv(Bus_Man_t *p, Abc_Obj_t *pObj, Vec_Ptr_t *vFanouts, float Gain)
Bus_Man_t * Bus_ManStart(Abc_Ntk_t *pNtk, SC_Lib *pLib, SC_BusPars *pPars)
FUNCTION DEFINITIONS ///.
void Bus_ManReadInOutLoads(Bus_Man_t *p)
float Abc_NtkComputeNodeDeparture(Abc_Obj_t *pObj, float Slew)
float Abc_NtkComputeNodeLoad(Bus_Man_t *p, Abc_Obj_t *pObj)
float Abc_NtkComputeFanoutLoad(Bus_Man_t *p, Vec_Ptr_t *vFanouts)
void Abc_SclOneNodePrint(Bus_Man_t *p, Abc_Obj_t *pObj)
void Abc_NtkPrintFanoutProfile(Abc_Obj_t *pObj)
void Abc_SclBufSize(Bus_Man_t *p, float Gain)
void Abc_NodeInvUpdateFanPolarity(Abc_Obj_t *pObj)
int Abc_SclIsInv(Abc_Obj_t *pObj)
int Abc_SclCheckNtk(Abc_Ntk_t *p, int fVerbose)
void Abc_SclReportDupFanins(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pName)
SC_WireLoad * Abc_SclFindWireLoadModel(SC_Lib *p, float Area)
struct SC_BusPars_ SC_BusPars
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
SC_Cell * Abc_SclFindSmallestGate(SC_Cell *p, float CinMin)
struct SC_WireLoad_ SC_WireLoad
STRUCTURE DEFINITIONS ///.
int Abc_SclCellFind(SC_Lib *p, char *pName)
float Abc_SclFindWireLoad(Vec_Flt_t *vWireCaps, int nFans)
ABC_NAMESPACE_IMPL_START Vec_Flt_t * Abc_SclFindWireCaps(SC_WireLoad *pWL, int nFanoutMax)
DECLARATIONS ///.
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
void Abc_SclMioGates2SclGates(SC_Lib *pLib, Abc_Ntk_t *p)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.