ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sclSize.c
Go to the documentation of this file.
1
20
21#include "sclSize.h"
22#include "map/mio/mio.h"
23#include "misc/vec/vecWec.h"
24#include "base/main/main.h"
25
26#ifdef WIN32
27#include <windows.h>
28#endif
29
31
32
36
40
53{
54 Abc_Obj_t * pObj, * pPivot = NULL;
55 float fMaxArr = 0;
56 int i;
57 assert( Abc_NtkPoNum(p->pNtk) > 0 );
58 Abc_NtkForEachCo( p->pNtk, pObj, i )
59 {
60 SC_Pair * pArr = Abc_SclObjTime( p, pObj );
61 if ( fMaxArr < pArr->rise ) fMaxArr = pArr->rise, *pfRise = 1, pPivot = pObj;
62 if ( fMaxArr < pArr->fall ) fMaxArr = pArr->fall, *pfRise = 0, pPivot = pObj;
63 }
64 if ( fMaxArr == 0 )
65 pPivot = Abc_NtkPo(p->pNtk, 0);
66 assert( pPivot != NULL );
67 return pPivot;
68}
69// assumes that slacks are not available (uses arrival times)
71{
72 Abc_Obj_t * pFanin, * pPivot = NULL;
73 float fMaxArr = 0;
74 int i;
75 Abc_ObjForEachFanin( pNode, pFanin, i )
76 {
77 SC_Pair * pArr = Abc_SclObjTime( p, pFanin );
78 if ( fMaxArr < pArr->rise ) fMaxArr = pArr->rise, *pfRise = 1, pPivot = pFanin;
79 if ( fMaxArr < pArr->fall ) fMaxArr = pArr->fall, *pfRise = 0, pPivot = pFanin;
80 }
81 return pPivot;
82}
83// assumes that slack are available
85{
86 Abc_Obj_t * pFanin, * pPivot = NULL;
87 float fMinSlack = ABC_INFINITY;
88 SC_Pair * pArr;
89 int i;
90 *pfRise = 0;
91 // find min-slack node
92 Abc_ObjForEachFanin( pNode, pFanin, i )
93 if ( fMinSlack > Abc_SclObjGetSlack( p, pFanin, p->MaxDelay0 ) )
94 {
95 fMinSlack = Abc_SclObjGetSlack( p, pFanin, p->MaxDelay0 );
96 pPivot = pFanin;
97 }
98 if ( pPivot == NULL )
99 return NULL;
100 // find its leading phase
101 pArr = Abc_SclObjTime( p, pPivot );
102 *pfRise = (pArr->rise >= pArr->fall);
103 return pPivot;
104}
105
117static inline void Abc_SclTimeNodePrint( SC_Man * p, Abc_Obj_t * pObj, int fRise, int Length, float maxDelay )
118{
119 SC_Cell * pCell = Abc_ObjIsNode(pObj) ? Abc_SclObjCell(pObj) : NULL;
120 printf( "%8d : ", Abc_ObjId(pObj) );
121 printf( "%d ", Abc_ObjFaninNum(pObj) );
122 printf( "%4d ", Abc_ObjFanoutNum(pObj) );
123 printf( "%-*s ", Length, pCell ? pCell->pName : "pi" );
124 printf( "A =%7.2f ", pCell ? pCell->area : 0.0 );
125 printf( "D%s =", fRise ? "r" : "f" );
126 printf( "%6.1f", Abc_SclObjTimeMax(p, pObj) );
127 printf( "%7.1f ps ", -Abc_AbsFloat(Abc_SclObjTimeOne(p, pObj, 0) - Abc_SclObjTimeOne(p, pObj, 1)) );
128 printf( "S =%6.1f ps ", Abc_SclObjSlewMax(p, pObj) );
129 printf( "Cin =%5.1f ff ", pCell ? SC_CellPinCapAve(pCell) : 0.0 );
130 printf( "Cout =%6.1f ff ", Abc_SclObjLoadMax(p, pObj) );
131 printf( "Cmax =%6.1f ff ", pCell ? SC_CellPin(pCell, pCell->n_inputs)->max_out_cap : 0.0 );
132 printf( "G =%5d ", pCell ? (int)(100.0 * Abc_SclObjLoadAve(p, pObj) / SC_CellPinCapAve(pCell)) : 0 );
133// printf( "SL =%6.1f ps", Abc_SclObjSlackMax(p, pObj, p->MaxDelay0) );
134 printf( "\n" );
135}
136void Abc_SclTimeNtkPrint( SC_Man * p, int fShowAll, int fPrintPath )
137{
138 int fReversePath = 1;
139 int i, nLength = 0, fRise = 0;
140 Abc_Obj_t * pObj, * pPivot = Abc_SclFindCriticalCo( p, &fRise );
141 float maxDelay = Abc_SclObjTimeOne( p, pPivot, fRise );
142 p->ReportDelay = maxDelay;
143 // used for Floyds cycle detection algorithm
144 unsigned int tortoiseIndex = 0;
145 int tortoiseStep = 0;
146
147#ifdef WIN32
148 printf( "WireLoad = \"%s\" ", p->pWLoadUsed ? p->pWLoadUsed->pName : "none" );
149 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 14 ); // yellow
150 printf( "Gates =%7d ", Abc_NtkNodeNum(p->pNtk) );
151 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 7 ); // normal
152 printf( "(%5.1f %%) ", 100.0 * Abc_SclGetBufInvCount(p->pNtk) / Abc_NtkNodeNum(p->pNtk) );
153 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 10 ); // green
154 printf( "Cap =%5.1f ff ", p->EstLoadAve );
155 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 7 ); // normal
156 printf( "(%5.1f %%) ", Abc_SclGetAverageSize(p->pNtk) );
157 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 11 ); // blue
158 printf( "Area =%12.2f ", Abc_SclGetTotalArea(p->pNtk) );
159 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 7 ); // normal
160 printf( "(%5.1f %%) ", 100.0 * Abc_SclCountMinSize(p->pLib, p->pNtk, 0) / Abc_NtkNodeNum(p->pNtk) );
161 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 13 ); // magenta
162 printf( "Delay =%9.2f ps ", maxDelay );
163 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 7 ); // normal
164 printf( "(%5.1f %%) ", 100.0 * Abc_SclCountNearCriticalNodes(p) / Abc_NtkNodeNum(p->pNtk) );
165 printf( " \n" );
166#else
167 Abc_Print( 1, "WireLoad = \"%s\" ", p->pWLoadUsed ? p->pWLoadUsed->pName : "none" );
168 Abc_Print( 1, "%sGates =%7d%s ", "\033[1;33m", Abc_NtkNodeNum(p->pNtk), "\033[0m" ); // yellow
169 Abc_Print( 1, "(%5.1f %%) ", 100.0 * Abc_SclGetBufInvCount(p->pNtk) / Abc_NtkNodeNum(p->pNtk) );
170 Abc_Print( 1, "%sCap =%5.1f ff%s ", "\033[1;32m", p->EstLoadAve, "\033[0m" ); // green
171 Abc_Print( 1, "(%5.1f %%) ", Abc_SclGetAverageSize(p->pNtk) );
172 Abc_Print( 1, "%sArea =%12.2f%s ", "\033[1;36m", Abc_SclGetTotalArea(p->pNtk), "\033[0m" ); // blue
173 Abc_Print( 1, "(%5.1f %%) ", 100.0 * Abc_SclCountMinSize(p->pLib, p->pNtk, 0) / Abc_NtkNodeNum(p->pNtk) );
174 Abc_Print( 1, "%sDelay =%9.2f ps%s ", "\033[1;35m", maxDelay, "\033[0m" ); // magenta
175 Abc_Print( 1, "(%5.1f %%) ", 100.0 * Abc_SclCountNearCriticalNodes(p) / Abc_NtkNodeNum(p->pNtk) );
176 Abc_Print( 1, " \n" );
177#endif
178
179 if ( fShowAll )
180 {
181// printf( "Timing information for all nodes: \n" );
182 // find the longest cell name
183 Abc_NtkForEachNodeReverse( p->pNtk, pObj, i )
184 if ( Abc_ObjFaninNum(pObj) > 0 )
185 nLength = Abc_MaxInt( nLength, strlen(Abc_SclObjCell(pObj)->pName) );
186 // print timing
187 Abc_NtkForEachNodeReverse( p->pNtk, pObj, i )
188 if ( Abc_ObjFaninNum(pObj) > 0 )
189 Abc_SclTimeNodePrint( p, pObj, -1, nLength, maxDelay );
190 }
191 if ( fPrintPath )
192 {
193 Abc_Obj_t * pTemp, * pPrev = NULL;
194 int iStart = -1, iEnd = -1;
195 Vec_Ptr_t * vPath;
196// printf( "Critical path: \n" );
197 // find the longest cell name
198 pObj = Abc_ObjFanin0(pPivot);
199 i = 0;
200 while ( pObj && Abc_ObjIsNode(pObj) )
201 {
202 i++;
203 nLength = Abc_MaxInt( nLength, Abc_SclObjCell(pObj) ? strlen(Abc_SclObjCell(pObj)->pName) : 2 /* strlen("pi") */ );
204 pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj );
205 }
206
207 // print timing
208 if ( !fReversePath )
209 {
210 // print timing
211 pObj = Abc_ObjFanin0(pPivot);
212 while ( pObj )//&& Abc_ObjIsNode(pObj) )
213 {
214 printf( "Path%3d --", i-- );
215 Abc_SclTimeNodePrint( p, pObj, fRise, nLength, maxDelay );
216 pPrev = pObj;
217 pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj );
218 }
219 }
220 else
221 {
222 // collect path nodes
223 vPath = Vec_PtrAlloc( 100 );
224 Vec_PtrPush( vPath, pPivot );
225 pObj = Abc_ObjFanin0(pPivot);
226 while ( pObj )//&& Abc_ObjIsNode(pObj) )
227 {
228 Vec_PtrPush( vPath, pObj );
229 pPrev = pObj;
230 pObj = Abc_SclFindMostCriticalFanin( p, &fRise, pObj );
231
232 // move the tortoise at half the speed (trailing)
233 tortoiseStep = (tortoiseStep + 1) % 2;
234 tortoiseIndex += tortoiseStep;
235 // if they see the same element, we are in a loop
236 if(vPath->pArray[tortoiseIndex] == pObj) {
237 break;
238 }
239 }
240 Vec_PtrForEachEntryReverse( Abc_Obj_t *, vPath, pObj, i )
241 {
242 printf( "Path%3d --", Vec_PtrSize(vPath)-1-i );
243 Abc_SclTimeNodePrint( p, pObj, fRise, nLength, maxDelay );
244 if ( i == 1 )
245 break;
246 }
247 Vec_PtrFree( vPath );
248 }
249 // print start-point and end-point
250 Abc_NtkForEachPi( p->pNtk, pTemp, iStart )
251 if ( pTemp == pPrev )
252 break;
253 Abc_NtkForEachPo( p->pNtk, pTemp, iEnd )
254 if ( pTemp == pPivot )
255 break;
256 printf( "Start-point = pi%0*d. End-point = po%0*d.\n",
257 Abc_Base10Log( Abc_NtkPiNum(p->pNtk) ), iStart,
258 Abc_Base10Log( Abc_NtkPoNum(p->pNtk) ), iEnd );
259 }
260}
261
273static inline void Abc_SclTimeFanin( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin, int k )
274{
275 SC_Pair * pArrIn = Abc_SclObjTime( p, pFanin );
276 SC_Pair * pSlewIn = Abc_SclObjSlew( p, pFanin );
277 SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
278 SC_Pair * pArrOut = Abc_SclObjTime( p, pObj ); // modified
279 SC_Pair * pSlewOut = Abc_SclObjSlew( p, pObj ); // modified
280 if ( p->pFuncFanin ) pLoad->fall += p->pFuncFanin(p, pObj, pFanin, k, 0);
281 if ( p->pFuncFanin ) pLoad->rise += p->pFuncFanin(p, pObj, pFanin, k, 1);
282 Scl_LibPinArrival( pTime, pArrIn, pSlewIn, pLoad, pArrOut, pSlewOut );
283}
284static inline void Abc_SclDeptFanin( SC_Man * p, SC_Timing * pTime, Abc_Obj_t * pObj, Abc_Obj_t * pFanin, int k )
285{
286 SC_Pair * pDepIn = Abc_SclObjDept( p, pFanin ); // modified
287 SC_Pair * pSlewIn = Abc_SclObjSlew( p, pFanin );
288 SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
289 SC_Pair * pDepOut = Abc_SclObjDept( p, pObj );
290 if ( p->pFuncFanin ) pLoad->fall += p->pFuncFanin(p, pObj, pFanin, k, 0);
291 if ( p->pFuncFanin ) pLoad->rise += p->pFuncFanin(p, pObj, pFanin, k, 1);
292 Scl_LibPinDeparture( pTime, pDepIn, pSlewIn, pLoad, pDepOut );
293}
294static inline void Abc_SclDeptObj( SC_Man * p, Abc_Obj_t * pObj )
295{
296 SC_Timing * pTime;
297 Abc_Obj_t * pFanout;
298 int i;
299 SC_PairClean( Abc_SclObjDept(p, pObj) );
300 Abc_ObjForEachFanout( pObj, pFanout, i )
301 {
302 if ( Abc_ObjIsCo(pFanout) || Abc_ObjIsLatch(pFanout) )
303 continue;
304 pTime = Scl_CellPinTime( Abc_SclObjCell(pFanout), Abc_NodeFindFanin(pFanout, pObj) );
305 Abc_SclDeptFanin( p, pTime, pFanout, pObj, Abc_NodeFindFanin(pFanout, pObj) );
306 }
307}
308static inline float Abc_SclObjLoadValue( SC_Man * p, Abc_Obj_t * pObj )
309{
310// float Value = Abc_MaxFloat(pLoad->fall, pLoad->rise) / (p->EstLoadAve * p->EstLoadMax);
311 return (0.5 * Abc_SclObjLoad(p, pObj)->fall + 0.5 * Abc_SclObjLoad(p, pObj)->rise) / (p->EstLoadAve * p->EstLoadMax);
312}
313static inline void Abc_SclTimeCi( SC_Man * p, Abc_Obj_t * pObj )
314{
315 if ( p->pPiDrive != NULL )
316 {
317 SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
318 SC_Pair * pTime = Abc_SclObjTime( p, pObj );
319 SC_Pair * pSlew = Abc_SclObjSlew( p, pObj );
320 Scl_LibHandleInputDriver( p->pPiDrive, pLoad, pTime, pSlew );
321 }
322}
323void Abc_SclTimeNode( SC_Man * p, Abc_Obj_t * pObj, int fDept )
324{
325 SC_Timing * pTime;
326 SC_Cell * pCell;
327 int k;
328 SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
329 float LoadRise = pLoad->rise;
330 float LoadFall = pLoad->fall;
331 float DeptRise = 0;
332 float DeptFall = 0;
333 float Value = p->EstLoadMax ? Abc_SclObjLoadValue( p, pObj ) : 0;
334 Abc_Obj_t * pFanin;
335 if ( Abc_ObjIsCi(pObj) )
336 {
337 assert( !fDept );
338 Abc_SclTimeCi( p, pObj );
339 return;
340 }
341 if ( Abc_ObjIsCo(pObj) )
342 {
343 if ( !fDept )
344 {
345 Abc_SclObjDupFanin( p, pObj );
346 Vec_FltWriteEntry( p->vTimesOut, pObj->iData, Abc_SclObjTimeMax(p, pObj) );
347 Vec_QueUpdate( p->vQue, pObj->iData );
348 }
349 return;
350 }
351 assert( Abc_ObjIsNode(pObj) );
352// if ( !(Abc_ObjFaninNum(pObj) == 1 && Abc_ObjIsPi(Abc_ObjFanin0(pObj))) && p->EstLoadMax && Value > 1 )
353 if ( p->EstLoadMax && Value > 1 )
354 {
355 pLoad->rise = p->EstLoadAve * p->EstLoadMax;
356 pLoad->fall = p->EstLoadAve * p->EstLoadMax;
357 if ( fDept )
358 {
359 SC_Pair * pDepOut = Abc_SclObjDept( p, pObj );
360 float EstDelta = p->EstLinear * log( Value );
361 DeptRise = pDepOut->rise;
362 DeptFall = pDepOut->fall;
363 pDepOut->rise += EstDelta;
364 pDepOut->fall += EstDelta;
365 }
366 p->nEstNodes++;
367 }
368 // get the library cell
369 pCell = Abc_SclObjCell( pObj );
370 // compute for each fanin
371 Abc_ObjForEachFanin( pObj, pFanin, k )
372 {
373 pTime = Scl_CellPinTime( pCell, k );
374 if ( fDept )
375 Abc_SclDeptFanin( p, pTime, pObj, pFanin, k );
376 else
377 Abc_SclTimeFanin( p, pTime, pObj, pFanin, k );
378 }
379 if ( p->EstLoadMax && Value > 1 )
380 {
381 pLoad->rise = LoadRise;
382 pLoad->fall = LoadFall;
383 if ( fDept )
384 {
385 SC_Pair * pDepOut = Abc_SclObjDept( p, pObj );
386 pDepOut->rise = DeptRise;
387 pDepOut->fall = DeptFall;
388 }
389 else
390 {
391 SC_Pair * pArrOut = Abc_SclObjTime( p, pObj );
392 float EstDelta = p->EstLinear * log( Value );
393 pArrOut->rise += EstDelta;
394 pArrOut->fall += EstDelta;
395 }
396 }
397}
399{
400 int fVerbose = 0;
401 Abc_Obj_t * pObj;
402 int i;
403 Abc_SclConeClean( p, vCone );
404 Abc_NtkForEachObjVec( vCone, p->pNtk, pObj, i )
405 {
406 if ( fVerbose && Abc_ObjIsNode(pObj) )
407 printf( " Updating node %d with gate %s\n", Abc_ObjId(pObj), Abc_SclObjCell(pObj)->pName );
408 if ( fVerbose && Abc_ObjIsNode(pObj) )
409 printf( " before (%6.1f ps %6.1f ps) ", Abc_SclObjTimeOne(p, pObj, 1), Abc_SclObjTimeOne(p, pObj, 0) );
410 Abc_SclTimeNode( p, pObj, 0 );
411 if ( fVerbose && Abc_ObjIsNode(pObj) )
412 printf( "after (%6.1f ps %6.1f ps)\n", Abc_SclObjTimeOne(p, pObj, 1), Abc_SclObjTimeOne(p, pObj, 0) );
413 }
414}
415void Abc_SclTimeNtkRecompute( SC_Man * p, float * pArea, float * pDelay, int fReverse, float DUser )
416{
417 Abc_Obj_t * pObj;
418 float D;
419 int i;
421 Abc_SclManCleanTime( p );
422 p->nEstNodes = 0;
423 Abc_NtkForEachCi( p->pNtk, pObj, i )
424 Abc_SclTimeNode( p, pObj, 0 );
425 Abc_NtkForEachNode1( p->pNtk, pObj, i )
426 Abc_SclTimeNode( p, pObj, 0 );
427 Abc_NtkForEachCo( p->pNtk, pObj, i )
428 Abc_SclTimeNode( p, pObj, 0 );
429 D = Abc_SclReadMaxDelay( p );
430 if ( fReverse && DUser > 0 && D < DUser )
431 D = DUser;
432 if ( pArea )
433 *pArea = Abc_SclGetTotalArea(p->pNtk);
434 if ( pDelay )
435 *pDelay = D;
436 if ( fReverse )
437 {
438 p->nEstNodes = 0;
439 Abc_NtkForEachNodeReverse1( p->pNtk, pObj, i )
440 Abc_SclTimeNode( p, pObj, 1 );
441 }
442}
443
455static inline void Abc_SclTimeIncUpdateClean( SC_Man * p )
456{
457 Vec_Int_t * vLevel;
458 Abc_Obj_t * pObj;
459 int i, k;
460 Vec_WecForEachLevel( p->vLevels, vLevel, i )
461 {
462 Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
463 {
464 assert( pObj->fMarkC == 1 );
465 pObj->fMarkC = 0;
466 }
467 Vec_IntClear( vLevel );
468 }
469}
470static inline void Abc_SclTimeIncAddNode( SC_Man * p, Abc_Obj_t * pObj )
471{
472 assert( !Abc_ObjIsLatch(pObj) );
473 assert( pObj->fMarkC == 0 );
474 pObj->fMarkC = 1;
475 Vec_IntPush( Vec_WecEntry(p->vLevels, Abc_ObjLevel(pObj)), Abc_ObjId(pObj) );
476 p->nIncUpdates++;
477}
478static inline void Abc_SclTimeIncAddFanins( SC_Man * p, Abc_Obj_t * pObj )
479{
480 Abc_Obj_t * pFanin;
481 int i;
482 Abc_ObjForEachFanin( pObj, pFanin, i )
483// if ( !pFanin->fMarkC && Abc_ObjIsNode(pFanin) )
484 if ( !pFanin->fMarkC && !Abc_ObjIsLatch(pFanin) )
485 Abc_SclTimeIncAddNode( p, pFanin );
486}
487static inline void Abc_SclTimeIncAddFanouts( SC_Man * p, Abc_Obj_t * pObj )
488{
489 Abc_Obj_t * pFanout;
490 int i;
491 Abc_ObjForEachFanout( pObj, pFanout, i )
492 if ( !pFanout->fMarkC && !Abc_ObjIsLatch(pFanout) )
493 Abc_SclTimeIncAddNode( p, pFanout );
494}
495static inline void Abc_SclTimeIncUpdateArrival( SC_Man * p )
496{
497 Vec_Int_t * vLevel;
498 SC_Pair ArrOut, SlewOut;
499 SC_Pair * pArrOut, *pSlewOut;
500 Abc_Obj_t * pObj;
501 float E = (float)0.1;
502 int i, k;
503 Vec_WecForEachLevel( p->vLevels, vLevel, i )
504 {
505 Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
506 {
507 if ( Abc_ObjIsCo(pObj) )
508 {
509 Abc_SclObjDupFanin( p, pObj );
510 Vec_FltWriteEntry( p->vTimesOut, pObj->iData, Abc_SclObjTimeMax(p, pObj) );
511 Vec_QueUpdate( p->vQue, pObj->iData );
512 continue;
513 }
514 pArrOut = Abc_SclObjTime( p, pObj );
515 pSlewOut = Abc_SclObjSlew( p, pObj );
516 SC_PairMove( &ArrOut, pArrOut );
517 SC_PairMove( &SlewOut, pSlewOut );
518 Abc_SclTimeNode( p, pObj, 0 );
519// if ( !SC_PairEqual(&ArrOut, pArrOut) || !SC_PairEqual(&SlewOut, pSlewOut) )
520 if ( !SC_PairEqualE(&ArrOut, pArrOut, E) || !SC_PairEqualE(&SlewOut, pSlewOut, E) )
521 Abc_SclTimeIncAddFanouts( p, pObj );
522 }
523 }
524 p->MaxDelay = Abc_SclReadMaxDelay( p );
525}
526static inline void Abc_SclTimeIncUpdateDeparture( SC_Man * p )
527{
528 Vec_Int_t * vLevel;
529 SC_Pair DepOut, * pDepOut;
530 Abc_Obj_t * pObj;
531 float E = (float)0.1;
532 int i, k;
533 Vec_WecForEachLevelReverse( p->vLevels, vLevel, i )
534 {
535 Abc_NtkForEachObjVec( vLevel, p->pNtk, pObj, k )
536 {
537 pDepOut = Abc_SclObjDept( p, pObj );
538 SC_PairMove( &DepOut, pDepOut );
539 Abc_SclDeptObj( p, pObj );
540// if ( !SC_PairEqual(&DepOut, pDepOut) )
541 if ( !SC_PairEqualE(&DepOut, pDepOut, E) )
542 Abc_SclTimeIncAddFanins( p, pObj );
543 }
544 }
545 p->MaxDelay = Abc_SclReadMaxDelay( p );
546}
548{
549 Abc_Obj_t * pObj;
550 int i;
551 Abc_NtkForEachObj( pNtk, pObj, i )
552 if ( (int)pObj->Level != Abc_ObjLevelNew(pObj) )
553 printf( "Level of node %d is out of date!\n", i );
554}
556{
557 Abc_Obj_t * pObj;
558 int i, RetValue;
559 if ( Vec_IntSize(p->vChanged) == 0 )
560 return 0;
561// Abc_SclTimeIncCheckLevel( p->pNtk );
562 Abc_NtkForEachObjVec( p->vChanged, p->pNtk, pObj, i )
563 {
564 Abc_SclTimeIncAddFanins( p, pObj );
565 if ( pObj->fMarkC )
566 continue;
567 Abc_SclTimeIncAddNode( p, pObj );
568 }
569 Vec_IntClear( p->vChanged );
570 Abc_SclTimeIncUpdateArrival( p );
571 Abc_SclTimeIncUpdateDeparture( p );
572 Abc_SclTimeIncUpdateClean( p );
573 RetValue = p->nIncUpdates;
574 p->nIncUpdates = 0;
575 return RetValue;
576}
578{
579 Vec_IntPush( p->vChanged, Abc_ObjId(pObj) );
580}
582{
583 Abc_Obj_t * pFanout;
584 int i, LevelNew = Abc_ObjLevelNew(pObj);
585 if ( LevelNew == (int)pObj->Level && Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0 )
586 return;
587 pObj->Level = LevelNew;
588 Abc_ObjForEachFanout( pObj, pFanout, i )
590}
595
596
597
610{
611 if ( Abc_FrameReadMaxLoad() )
612 {
613 Abc_Obj_t * pObj; int i;
614 float MaxLoad = Abc_FrameReadMaxLoad();
615// printf( "Default output load is specified (%.2f ff).\n", MaxLoad );
616 Abc_NtkForEachPo( pNtk, pObj, i )
617 {
618 SC_Pair * pLoad = Abc_SclObjLoad( p, pObj );
619 pLoad->rise = pLoad->fall = MaxLoad;
620 }
621 }
623 {
624 int iCell = Abc_SclCellFind( p->pLib, Abc_FrameReadDrivingCell() );
625 if ( iCell == -1 )
626 printf( "Cannot find the default PI driving cell (%s) in the library.\n", Abc_FrameReadDrivingCell() );
627 else
628 {
629// printf( "Default PI driving cell is specified (%s).\n", Abc_FrameReadDrivingCell() );
630 p->pPiDrive = SC_LibCell( p->pLib, iCell );
631 assert( p->pPiDrive != NULL );
632 assert( p->pPiDrive->n_inputs == 1 );
633 }
634 }
635}
636
648SC_Man * Abc_SclManStart( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fUseWireLoads, int fDept, float DUser, int nTreeCRatio )
649{
650 SC_Man * p = Abc_SclManAlloc( pLib, pNtk );
651 if ( nTreeCRatio )
652 {
653 p->EstLoadMax = 0.01 * nTreeCRatio; // max ratio of Cout/Cave when the estimation is used
654 p->EstLinear = 100; // linear coefficient
655 }
656 Abc_SclMioGates2SclGates( pLib, pNtk );
658 if ( fUseWireLoads )
659 {
660 if ( pNtk->pWLoadUsed == NULL )
661 {
662 p->pWLoadUsed = Abc_SclFindWireLoadModel( pLib, Abc_SclGetTotalArea(p->pNtk) );
663 if ( p->pWLoadUsed )
664 pNtk->pWLoadUsed = Abc_UtilStrsav( p->pWLoadUsed->pName );
665 }
666 else
667 p->pWLoadUsed = Abc_SclFetchWireLoadModel( pLib, pNtk->pWLoadUsed );
668 }
669 Abc_SclTimeNtkRecompute( p, &p->SumArea0, &p->MaxDelay0, fDept, DUser );
670 p->SumArea = p->SumArea0;
671 p->MaxDelay = p->MaxDelay0;
672 return p;
673}
674
686void Abc_SclTimePerformInt( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats )
687{
688 SC_Man * p;
689 p = Abc_SclManStart( pLib, pNtk, fUseWireLoads, 1, 0, nTreeCRatio );
690 Abc_SclTimeNtkPrint( p, fShowAll, fPrintPath );
691 if ( fDumpStats )
692 Abc_SclDumpStats( p, "stats.txt", 0 );
693 Abc_SclManFree( p );
694}
695
707void Abc_SclTimePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats )
708{
709 Abc_Ntk_t * pNtkNew = pNtk;
710 if ( pNtk->nBarBufs2 > 0 )
711 pNtkNew = Abc_NtkDupDfsNoBarBufs( pNtk );
712 Abc_SclTimePerformInt( pLib, pNtkNew, nTreeCRatio, fUseWireLoads, fShowAll, fPrintPath, fDumpStats );
713 if ( pNtk->nBarBufs2 > 0 )
714 Abc_NtkDelete( pNtkNew );
715}
716
717
718
731{
732 Abc_Obj_t * pTemp;
733 int i;
734 Abc_ObjForEachFanin( pObj, pTemp, i )
735 if ( Abc_NodeFindFanin( pFanin, pTemp ) >= 0 )
736 {
737 printf( "Node %d and its fanin %d have common fanin %d.\n", Abc_ObjId(pObj), Abc_ObjId(pFanin), Abc_ObjId(pTemp) );
738
739 printf( "%-16s : ", Mio_GateReadName((Mio_Gate_t *)pObj->pData) );
740 Abc_ObjPrint( stdout, pObj );
741
742 printf( "%-16s : ", Mio_GateReadName((Mio_Gate_t *)pFanin->pData) );
743 Abc_ObjPrint( stdout, pFanin );
744
745 if ( pTemp->pData )
746 printf( "%-16s : ", Mio_GateReadName((Mio_Gate_t *)pTemp->pData) );
747 Abc_ObjPrint( stdout, pTemp );
748 return 1;
749 }
750 return 0;
751}
753{
754 Abc_Obj_t * pObj, * pFanin;
755 int i, k;
756 Abc_NtkForEachNode( pNtk, pObj, i )
757 Abc_ObjForEachFanin( pObj, pFanin, k )
758 if ( Abc_ObjIsNode(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
759 Abc_SclCheckCommonInputs( pObj, pFanin );
760}
761
773static inline int Abc_ObjIsBuffer( Abc_Obj_t * pObj ) { return Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) == 1; }
775{
776 Abc_Obj_t * pFanout;
777 int i;
778 Abc_ObjForEachFanout( pObj, pFanout, i )
779 if ( Abc_ObjIsBuffer(pFanout) )
780 return 1;
781 return 0;
782}
784{
785 Abc_Obj_t * pFanout;
786 int i, Counter = 0;
787 Abc_ObjForEachFanout( pObj, pFanout, i )
788 if ( Abc_ObjIsBuffer(pFanout) )
789 Counter += Abc_SclCountBufferFanoutsInt( pFanout );
790 return Counter + Abc_ObjIsBuffer(pObj);
791}
793{
794 return Abc_SclCountBufferFanoutsInt(pObj) - Abc_ObjIsBuffer(pObj);
795}
797{
798 Abc_Obj_t * pFanout;
799 int i, Counter = 0;
800 if ( !Abc_ObjIsBuffer(pObj) )
801 return 1;
802 Abc_ObjForEachFanout( pObj, pFanout, i )
803 Counter += Abc_SclCountNonBufferFanoutsInt( pFanout );
804 return Counter;
805}
807{
808 Abc_Obj_t * pFanout;
809 int i, Counter = 0;
810 Abc_ObjForEachFanout( pObj, pFanout, i )
811 Counter += Abc_SclCountNonBufferFanoutsInt( pFanout );
812 return Counter;
813}
815{
816 Abc_Obj_t * pFanout;
817 float Delay = 0;
818 int i;
819 if ( !Abc_ObjIsBuffer(pObj) )
820 return Abc_SclObjTimeMax(p, pObj);
821 Abc_ObjForEachFanout( pObj, pFanout, i )
822 Delay += Abc_SclCountNonBufferDelayInt( p, pFanout );
823 return Delay;
824}
826{
827 Abc_Obj_t * pFanout;
828 float Delay = 0;
829 int i;
830 Abc_ObjForEachFanout( pObj, pFanout, i )
831 Delay += Abc_SclCountNonBufferDelayInt( p, pFanout );
832 return Delay;
833}
835{
836 Abc_Obj_t * pFanout;
837 float Load = 0;
838 int i;
839 if ( !Abc_ObjIsBuffer(pObj) )
840 return 0;
841 Abc_ObjForEachFanout( pObj, pFanout, i )
842 Load += Abc_SclCountNonBufferLoadInt( p, pFanout );
843 Load += 0.5 * Abc_SclObjLoad(p, pObj)->rise + 0.5 * Abc_SclObjLoad(p, pObj)->fall;
844 Load -= 0.5 * SC_CellPin(Abc_SclObjCell(pObj), 0)->rise_cap + 0.5 * SC_CellPin(Abc_SclObjCell(pObj), 0)->fall_cap;
845 return Load;
846}
848{
849 Abc_Obj_t * pFanout;
850 float Load = 0;
851 int i;
852 Abc_ObjForEachFanout( pObj, pFanout, i )
853 Load += Abc_SclCountNonBufferLoadInt( p, pFanout );
854 Load += 0.5 * Abc_SclObjLoad(p, pObj)->rise + 0.5 * Abc_SclObjLoad(p, pObj)->fall;
855 return Load;
856}
857void Abc_SclPrintBuffersOne( SC_Man * p, Abc_Obj_t * pObj, int nOffset )
858{
859 int i;
860 for ( i = 0; i < nOffset; i++ )
861 printf( " " );
862 printf( "%6d: %-16s (%2d:%3d:%3d) ",
863 Abc_ObjId(pObj),
864 Abc_ObjIsPi(pObj) ? "pi" : Mio_GateReadName((Mio_Gate_t *)pObj->pData),
865 Abc_ObjFanoutNum(pObj),
868 for ( ; i < 4; i++ )
869 printf( " " );
870 printf( "a =%5.2f ", Abc_ObjIsPi(pObj) ? 0 : Abc_SclObjCell(pObj)->area );
871 printf( "d = (" );
872 printf( "%6.0f ps; ", Abc_SclObjTimeOne(p, pObj, 1) );
873 printf( "%6.0f ps) ", Abc_SclObjTimeOne(p, pObj, 0) );
874 printf( "l =%5.0f ff ", Abc_SclObjLoadMax(p, pObj) );
875 printf( "s =%5.0f ps ", Abc_SclObjSlewMax(p, pObj) );
876 printf( "sl =%5.0f ps ", Abc_SclObjSlackMax(p, pObj, p->MaxDelay0) );
877 if ( nOffset == 0 )
878 {
879 printf( "L =%5.0f ff ", Abc_SclCountNonBufferLoad(p, pObj) );
880 printf( "Lx =%5.0f ff ", 100.0*Abc_SclCountNonBufferLoad(p, pObj)/p->EstLoadAve );
881 printf( "Dx =%5.0f ps ", Abc_SclCountNonBufferDelay(p, pObj)/Abc_SclCountNonBufferFanouts(pObj) - Abc_SclObjTimeOne(p, pObj, 1) );
882 printf( "Cx =%5.0f ps", (Abc_SclCountNonBufferDelay(p, pObj)/Abc_SclCountNonBufferFanouts(pObj) - Abc_SclObjTimeOne(p, pObj, 1))/log(Abc_SclCountNonBufferLoad(p, pObj)/p->EstLoadAve) );
883 }
884 printf( "\n" );
885}
886void Abc_SclPrintBuffersInt( SC_Man * p, Abc_Obj_t * pObj, int nOffset )
887{
888 Abc_Obj_t * pFanout;
889 int i;
890 Abc_SclPrintBuffersOne( p, pObj, nOffset );
891 assert( Abc_ObjIsBuffer(pObj) );
892 Abc_ObjForEachFanout( pObj, pFanout, i )
893 if ( Abc_ObjIsBuffer(pFanout) )
894 Abc_SclPrintBuffersInt( p, pFanout, nOffset + 1 );
895}
897{
898 Abc_Obj_t * pObj, * pFanout;
899 int i, k;
900 Abc_NtkForEachObj( pNtk, pObj, i )
901 {
902 if ( !Abc_ObjIsBuffer(pObj) && Abc_SclCountBufferFanouts(pObj) > 3 )
903 {
904 Abc_SclPrintBuffersOne( p, pObj, 0 );
905 Abc_ObjForEachFanout( pObj, pFanout, k )
906 if ( Abc_ObjIsBuffer(pFanout) )
907 Abc_SclPrintBuffersInt( p, pFanout, 1 );
908 printf( "\n" );
909 }
910 }
911}
912void Abc_SclPrintBuffers( SC_Lib * pLib, Abc_Ntk_t * pNtk, int fVerbose )
913{
914 int fUseWireLoads = 0;
915 SC_Man * p;
916 assert( Abc_NtkIsMappedLogic(pNtk) );
917 p = Abc_SclManStart( pLib, pNtk, fUseWireLoads, 1, 0, 10000 );
918 Abc_SclPrintBufferTrees( p, pNtk );
919// Abc_SclPrintFaninPairs( p, pNtk );
920 Abc_SclManFree( p );
921}
922
923
927
928
930
931
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
ABC_DLL Abc_Ntk_t * Abc_NtkDupDfsNoBarBufs(Abc_Ntk_t *pNtk)
Definition abcNtk.c:578
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
ABC_DLL void Abc_ObjPrint(FILE *pFile, Abc_Obj_t *pObj)
Definition abcPrint.c:1674
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachNodeReverse(pNtk, pNode, i)
Definition abc.h:476
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
#define Abc_NtkForEachNode1(pNtk, pNode, i)
Definition abc.h:470
ABC_DLL int Abc_ObjLevelNew(Abc_Obj_t *pObj)
Definition abcTiming.c:1170
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition abc.h:455
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition abcUtil.c:791
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define Abc_NtkForEachNodeReverse1(pNtk, pNode, i)
Definition abc.h:479
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL float Abc_FrameReadMaxLoad()
Definition mainFrame.c:117
ABC_DLL char * Abc_FrameReadDrivingCell()
Definition mainFrame.c:116
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition mioApi.c:169
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
struct SC_Timing_ SC_Timing
Definition sclLib.h:124
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pName)
Definition sclLibUtil.c:365
struct SC_Lib_ SC_Lib
Definition sclLib.h:128
struct SC_Pair_ SC_Pair
Definition sclLib.h:69
SC_WireLoad * Abc_SclFindWireLoadModel(SC_Lib *p, float Area)
Definition sclLibUtil.c:382
struct SC_Cell_ SC_Cell
Definition sclLib.h:127
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition sclLibUtil.c:81
void Abc_SclComputeLoad(SC_Man *p)
Definition sclLoad.c:108
void Abc_SclTimeNode(SC_Man *p, Abc_Obj_t *pObj, int fDept)
Definition sclSize.c:323
int Abc_SclTimeIncUpdate(SC_Man *p)
Definition sclSize.c:555
void Abc_SclTimeIncUpdateLevel_rec(Abc_Obj_t *pObj)
Definition sclSize.c:581
void Abc_SclPrintBuffers(SC_Lib *pLib, Abc_Ntk_t *pNtk, int fVerbose)
Definition sclSize.c:912
ABC_NAMESPACE_IMPL_START Abc_Obj_t * Abc_SclFindCriticalCo(SC_Man *p, int *pfRise)
DECLARATIONS ///.
Definition sclSize.c:52
void Abc_SclTimeCone(SC_Man *p, Vec_Int_t *vCone)
Definition sclSize.c:398
int Abc_SclCountBufferFanouts(Abc_Obj_t *pObj)
Definition sclSize.c:792
void Abc_SclTimeIncInsert(SC_Man *p, Abc_Obj_t *pObj)
Definition sclSize.c:577
void Abc_SclPrintFaninPairs(SC_Man *p, Abc_Ntk_t *pNtk)
Definition sclSize.c:752
void Abc_SclTimePerformInt(SC_Lib *pLib, Abc_Ntk_t *pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats)
Definition sclSize.c:686
int Abc_SclCheckCommonInputs(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition sclSize.c:730
int Abc_SclCountNonBufferFanouts(Abc_Obj_t *pObj)
Definition sclSize.c:806
int Abc_SclCountNonBufferFanoutsInt(Abc_Obj_t *pObj)
Definition sclSize.c:796
int Abc_SclCountBufferFanoutsInt(Abc_Obj_t *pObj)
Definition sclSize.c:783
void Abc_SclTimePerform(SC_Lib *pLib, Abc_Ntk_t *pNtk, int nTreeCRatio, int fUseWireLoads, int fShowAll, int fPrintPath, int fDumpStats)
Definition sclSize.c:707
void Abc_SclPrintBuffersOne(SC_Man *p, Abc_Obj_t *pObj, int nOffset)
Definition sclSize.c:857
void Abc_SclPrintBuffersInt(SC_Man *p, Abc_Obj_t *pObj, int nOffset)
Definition sclSize.c:886
int Abc_SclHasBufferFanout(Abc_Obj_t *pObj)
Definition sclSize.c:774
float Abc_SclCountNonBufferDelayInt(SC_Man *p, Abc_Obj_t *pObj)
Definition sclSize.c:814
void Abc_SclPrintBufferTrees(SC_Man *p, Abc_Ntk_t *pNtk)
Definition sclSize.c:896
void Abc_SclTimeIncUpdateLevel(Abc_Obj_t *pObj)
Definition sclSize.c:591
float Abc_SclCountNonBufferDelay(SC_Man *p, Abc_Obj_t *pObj)
Definition sclSize.c:825
Abc_Obj_t * Abc_SclFindMostCriticalFanin2(SC_Man *p, int *pfRise, Abc_Obj_t *pNode)
Definition sclSize.c:70
float Abc_SclCountNonBufferLoad(SC_Man *p, Abc_Obj_t *pObj)
Definition sclSize.c:847
float Abc_SclCountNonBufferLoadInt(SC_Man *p, Abc_Obj_t *pObj)
Definition sclSize.c:834
Abc_Obj_t * Abc_SclFindMostCriticalFanin(SC_Man *p, int *pfRise, Abc_Obj_t *pNode)
Definition sclSize.c:84
void Abc_SclTimeIncCheckLevel(Abc_Ntk_t *pNtk)
Definition sclSize.c:547
SC_Man * Abc_SclManStart(SC_Lib *pLib, Abc_Ntk_t *pNtk, int fUseWireLoads, int fDept, float DUser, int nTreeCRatio)
Definition sclSize.c:648
void Abc_SclTimeNtkPrint(SC_Man *p, int fShowAll, int fPrintPath)
Definition sclSize.c:136
void Abc_SclManReadSlewAndLoad(SC_Man *p, Abc_Ntk_t *pNtk)
Definition sclSize.c:609
void Abc_SclTimeNtkRecompute(SC_Man *p, float *pArea, float *pDelay, int fReverse, float DUser)
Definition sclSize.c:415
void Abc_SclMioGates2SclGates(SC_Lib *pLib, Abc_Ntk_t *p)
DECLARATIONS ///.
Definition sclUtil.c:47
int Abc_SclCountMinSize(SC_Lib *pLib, Abc_Ntk_t *p, int fUseMax)
Definition sclUtil.c:222
int Abc_SclCountNearCriticalNodes(SC_Man *p)
Definition sclUpsize.c:187
typedefABC_NAMESPACE_HEADER_START struct SC_Man_ SC_Man
INCLUDES ///.
Definition sclSize.h:44
char * pWLoadUsed
Definition abc.h:209
int nBarBufs2
Definition abc.h:175
void * pData
Definition abc.h:145
unsigned fMarkC
Definition abc.h:136
int iData
Definition abc.h:146
unsigned Level
Definition abc.h:142
float area
Definition sclLib.h:207
char * pName
Definition sclLib.h:202
int n_inputs
Definition sclLib.h:213
float fall
Definition sclLib.h:73
float rise
Definition sclLib.h:72
#define assert(ex)
Definition util_old.h:213
int strlen()
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
#define Vec_WecForEachLevelReverse(vGlob, vVec, i)
Definition vecWec.h:65