52 assert( Abc_ObjIsNode(pPivot) );
54 Vec_IntClear( vNodes );
57 if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) > 0 )
58 Vec_IntPush( vNodes, Abc_ObjId(pNext) );
59 Vec_IntPush( vNodes, Abc_ObjId(pPivot) );
61 if ( Abc_ObjIsNode(pNext) )
63 Vec_IntPush( vNodes, Abc_ObjId(pNext) );
65 if ( Abc_ObjIsNode(pNext2) )
66 Vec_IntPush( vNodes, Abc_ObjId(pNext2) );
68 Vec_IntUniqify( vNodes );
76 Vec_IntClear( vEvals );
82 Vec_IntPush( vEvals, Abc_ObjId(pObj) );
85 assert( Vec_IntSize(vEvals) > 0 );
105 SC_Cell * pCellOld, * pCellNew;
106 float dGain, dGainBest;
112 pCellOld = Abc_SclObjCell( pObj );
113 Abc_SclConeStore(
p, vNodes );
114 Abc_SclEvalStore(
p, vEvals );
115 Abc_SclLoadStore(
p, pObj );
118 dGainBest = -DelayGap;
121 if ( pCellNew->
area >= pCellOld->
area )
126 Abc_SclObjSetCell( pObj, pCellNew );
131 Abc_SclObjSetCell( pObj, pCellOld );
132 Abc_SclLoadRestore(
p, pObj );
134 dGain = Abc_SclEvalPerformLegal(
p, vEvals,
p->MaxDelay0 );
138 if ( dGainBest < dGain )
141 gateBest = pCellNew->
Id;
145 Abc_SclObjSetCell( pObj, pCellOld );
146 Abc_SclConeRestore(
p, vNodes );
147p->timeSize += Abc_Clock() - clk;
150 pCellNew = SC_LibCell(
p->pLib, gateBest );
151 Abc_SclObjSetCell( pObj, pCellNew );
152 p->SumArea += pCellNew->
area - pCellOld->
area;
157 Abc_NodeSetTravIdCurrent( pTemp );
181 assert( Vec_QueSize(
p->vNodeByGain) == 0 );
182 Vec_QueClear(
p->vNodeByGain );
184 if ( Abc_ObjFaninNum(pObj) > 0 )
186 Vec_FltWriteEntry(
p->vNode2Gain, Abc_ObjId(pObj), Abc_SclObjCell(pObj)->area );
187 Vec_QuePush(
p->vNodeByGain, Abc_ObjId(pObj) );
195 if ( Abc_NodeIsTravIdCurrent(pObj) )
214 printf(
"Total : " );
216 printf(
"%5d : ", Iter );
217 printf(
"Try =%6d ", nAttempts );
218 printf(
"Over =%6d ", nOverlaps );
219 printf(
"Fail =%6d ", nAttempts-nOverlaps-nChanges );
220 printf(
"Win =%6d ", nChanges );
222 printf(
"%.2f ",
p->SumArea );
223 printf(
"(%+5.1f %%) ", 100.0 * (
p->SumArea -
p->SumArea0)/
p->SumArea0 );
225 printf(
"%.2f ps ",
p->MaxDelay );
226 printf(
"(%+5.1f %%) ", 100.0 * (
p->MaxDelay -
p->MaxDelay0)/
p->MaxDelay0 );
227 printf(
"%8.2f sec ", 1.0*(Abc_Clock() -
p->timeTotal)/(CLOCKS_PER_SEC) );
228 printf(
"%c", fVerbose ?
'\n' :
'\r' );
246 Vec_Int_t * vNodes, * vEvals, * vTryLater;
252 printf(
"Parameters: " );
253 printf(
"Iters =%5d. ", pPars->
nIters );
254 printf(
"UseDept =%2d. ", pPars->
fUseDept );
256 printf(
"Target =%5d ps. ", pPars->
DelayUser );
257 printf(
"DelayGap =%3d ps. ", pPars->
DelayGap );
258 printf(
"Timeout =%4d sec", pPars->
TimeOut );
265 p->timeTotal = Abc_Clock();
266 assert(
p->vGatesBest == NULL );
267 p->vGatesBest = Vec_IntDup(
p->pNtk->vGates );
270 vNodes = Vec_IntAlloc( 1000 );
271 vEvals = Vec_IntAlloc( 1000 );
272 vTryLater = Vec_IntAlloc( 1000 );
273 for ( i = 0; i < pPars->
nIters; i++ )
276 int nAttemptAll = 0, nOverlapAll = 0, nChangesAll = 0;
278 while ( Vec_QueSize(
p->vNodeByGain) > 0 )
280 int nAttempt = 0, nOverlap = 0, nChanges = 0;
281 Vec_IntClear( vTryLater );
282 Abc_NtkIncrementTravId( pNtk );
283 while ( Vec_QueSize(
p->vNodeByGain) > 0 )
286 pObj = Abc_NtkObj(
p->pNtk, Vec_QuePop(
p->vNodeByGain) );
288 p->timeCone += Abc_Clock() - clk;
290 nOverlap++, Vec_IntPush( vTryLater, Abc_ObjId(pObj) );
296 Vec_QuePush(
p->vNodeByGain, Abc_ObjId(pObj) );
299 if ( Vec_IntSize(
p->vChanged) )
303 p->timeTime += Abc_Clock() - clk;
305 p->MaxDelay = Abc_SclReadMaxDelay(
p );
309 nAttemptAll += nAttempt; nOverlapAll += nOverlap; nChangesAll += nChanges;
310 if ( nRuntimeLimit && Abc_Clock() > nRuntimeLimit )
317 if ( nRuntimeLimit && Abc_Clock() > nRuntimeLimit )
319 if ( nAttemptAll == 0 )
322 Vec_IntFree( vNodes );
323 Vec_IntFree( vEvals );
324 Vec_IntFree( vTryLater );
329 p->timeTotal = Abc_Clock() -
p->timeTotal;
332 p->timeOther =
p->timeTotal -
p->timeCone -
p->timeSize -
p->timeTime;
333 ABC_PRTP(
"Runtime: Critical path",
p->timeCone,
p->timeTotal );
334 ABC_PRTP(
"Runtime: Sizing eval ",
p->timeSize,
p->timeTotal );
335 ABC_PRTP(
"Runtime: Timing update",
p->timeTime,
p->timeTotal );
336 ABC_PRTP(
"Runtime: Other ",
p->timeOther,
p->timeTotal );
337 ABC_PRTP(
"Runtime: TOTAL ",
p->timeTotal,
p->timeTotal );
340 Abc_SclDumpStats(
p,
"stats2.txt",
p->timeTotal );
341 if ( nRuntimeLimit && Abc_Clock() > nRuntimeLimit )
342 printf(
"Gate sizing timed out at %d seconds.\n", pPars->
TimeOut );
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL Abc_Ntk_t * Abc_NtkDupDfsNoBarBufs(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_PRTP(a, t, T)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_NAMESPACE_IMPL_START void Abc_SclFindWindow(Abc_Obj_t *pPivot, Vec_Int_t **pvNodes, Vec_Int_t **pvEvals)
DECLARATIONS ///.
void Abc_SclDnsizePrint(SC_Man *p, int Iter, int nAttempts, int nOverlaps, int nChanges, int fVerbose)
void Abc_NtkCollectNodesByArea(SC_Man *p, Abc_Ntk_t *pNtk)
int Abc_SclCheckOverlap(Abc_Ntk_t *pNtk, Vec_Int_t *vNodes)
void Abc_SclDnsizePerformInt(SC_Lib *pLib, Abc_Ntk_t *pNtk, SC_SizePars *pPars, void *pFuncFanin)
void Abc_SclDnsizePerform(SC_Lib *pLib, Abc_Ntk_t *pNtk, SC_SizePars *pPars, void *pFuncFanin)
int Abc_SclCheckImprovement(SC_Man *p, Abc_Obj_t *pObj, Vec_Int_t *vNodes, Vec_Int_t *vEvals, int Notches, int DelayGap)
struct SC_SizePars_ SC_SizePars
#define SC_RingForEachCellRev(pRing, pCell, i)
void Abc_SclUpdateLoad(SC_Man *p, Abc_Obj_t *pObj, SC_Cell *pOld, SC_Cell *pNew)
int Abc_SclTimeIncUpdate(SC_Man *p)
void Abc_SclTimeCone(SC_Man *p, Vec_Int_t *vCone)
void Abc_SclTimeIncInsert(SC_Man *p, Abc_Obj_t *pObj)
SC_Man * Abc_SclManStart(SC_Lib *pLib, Abc_Ntk_t *pNtk, int fUseWireLoads, int fDept, float DUser, int nTreeCRatio)
void Abc_SclTimeNtkRecompute(SC_Man *p, float *pArea, float *pDelay, int fReverse, float DUser)
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
void Abc_SclTransferGates(Abc_Ntk_t *pOld, Abc_Ntk_t *pNew)
typedefABC_NAMESPACE_HEADER_START struct SC_Man_ SC_Man
INCLUDES ///.