abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclUpsize.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [sclUpsize.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Standard-cell library representation.]
8 
9  Synopsis [Selective increase of gate sizes.]
10 
11  Author [Alan Mishchenko, Niklas Een]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - August 24, 2012.]
16 
17  Revision [$Id: sclUpsize.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "sclSize.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Collect TFO of nodes.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 void Abc_SclFindTFO_rec( Abc_Obj_t * pObj, Vec_Int_t * vNodes, Vec_Int_t * vCos )
46 {
47  Abc_Obj_t * pNext;
48  int i;
49  if ( Abc_NodeIsTravIdCurrent( pObj ) )
50  return;
52  if ( Abc_ObjIsCo(pObj) )
53  {
54  Vec_IntPush( vCos, Abc_ObjId(pObj) );
55  return;
56  }
57  assert( Abc_ObjIsNode(pObj) );
58  Abc_ObjForEachFanout( pObj, pNext, i )
59  Abc_SclFindTFO_rec( pNext, vNodes, vCos );
60  if ( Abc_ObjFaninNum(pObj) > 0 )
61  Vec_IntPush( vNodes, Abc_ObjId(pObj) );
62 }
64 {
65  Vec_Int_t * vNodes, * vCos;
66  Abc_Obj_t * pObj, * pFanin;
67  int i, k;
68  assert( Vec_IntSize(vPath) > 0 );
69  vCos = Vec_IntAlloc( 100 );
70  vNodes = Vec_IntAlloc( 100 );
71  // collect nodes in the TFO
73  Abc_NtkForEachObjVec( vPath, p, pObj, i )
74  Abc_ObjForEachFanin( pObj, pFanin, k )
75  if ( Abc_ObjIsNode(pFanin) )
76  Abc_SclFindTFO_rec( pFanin, vNodes, vCos );
77  // reverse order
78  Vec_IntReverseOrder( vNodes );
79 // Vec_IntSort( vNodes, 0 );
80 //Vec_IntPrint( vNodes );
81 //Vec_IntPrint( vCos );
82  Vec_IntAppend( vNodes, vCos );
83  Vec_IntFree( vCos );
84  return vNodes;
85 }
86 
87 /**Function*************************************************************
88 
89  Synopsis [Collect near-critical COs.]
90 
91  Description []
92 
93  SideEffects []
94 
95  SeeAlso []
96 
97 ***********************************************************************/
99 {
100  float fMaxArr = Abc_SclReadMaxDelay( p ) * (100.0 - Window) / 100.0;
101  Vec_Int_t * vPivots;
102  Abc_Obj_t * pObj;
103  int i;
104  vPivots = Vec_IntAlloc( 100 );
105  Abc_NtkForEachCo( p->pNtk, pObj, i )
106  if ( Abc_SclObjTimeMax(p, pObj) >= fMaxArr )
107  Vec_IntPush( vPivots, Abc_ObjId(pObj) );
108  assert( Vec_IntSize(vPivots) > 0 );
109  return vPivots;
110 }
111 
112 /**Function*************************************************************
113 
114  Synopsis [Collect near-critical internal nodes.]
115 
116  Description []
117 
118  SideEffects []
119 
120  SeeAlso []
121 
122 ***********************************************************************/
123 void Abc_SclFindCriticalNodeWindow_rec( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t * vPath, float fSlack, int fDept )
124 {
125  Abc_Obj_t * pNext;
126  float fArrMax, fSlackFan;
127  int i;
128  if ( Abc_ObjIsCi(pObj) )
129  return;
130  if ( Abc_NodeIsTravIdCurrent( pObj ) )
131  return;
132  Abc_NodeSetTravIdCurrent( pObj );
133  assert( Abc_ObjIsNode(pObj) );
134  // compute the max arrival time of the fanins
135  if ( fDept )
136 // fArrMax = p->pSlack[Abc_ObjId(pObj)];
137  fArrMax = Abc_SclObjGetSlack(p, pObj, p->MaxDelay);
138  else
139  fArrMax = Abc_SclGetMaxDelayNodeFanins( p, pObj );
140 // assert( fArrMax >= -1 );
141  fArrMax = Abc_MaxFloat( fArrMax, 0 );
142  // traverse all fanins whose arrival times are within a window
143  Abc_ObjForEachFanin( pObj, pNext, i )
144  {
145  if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) == 0 )
146  continue;
147  assert( Abc_ObjIsNode(pNext) );
148  if ( fDept )
149 // fSlackFan = fSlack - (p->pSlack[Abc_ObjId(pNext)] - fArrMax);
150  fSlackFan = fSlack - (Abc_SclObjGetSlack(p, pNext, p->MaxDelay) - fArrMax);
151  else
152  fSlackFan = fSlack - (fArrMax - Abc_SclObjTimeMax(p, pNext));
153  if ( fSlackFan >= 0 )
154  Abc_SclFindCriticalNodeWindow_rec( p, pNext, vPath, fSlackFan, fDept );
155  }
156  if ( Abc_ObjFaninNum(pObj) > 0 )
157  Vec_IntPush( vPath, Abc_ObjId(pObj) );
158 }
159 Vec_Int_t * Abc_SclFindCriticalNodeWindow( SC_Man * p, Vec_Int_t * vPathCos, int Window, int fDept )
160 {
161  float fMaxArr = Abc_SclReadMaxDelay( p );
162  float fSlackMax = fMaxArr * Window / 100.0;
163  Vec_Int_t * vPath = Vec_IntAlloc( 100 );
164  Abc_Obj_t * pObj;
165  int i;
166  Abc_NtkIncrementTravId( p->pNtk );
167  Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i )
168  {
169  float fSlackThis = fSlackMax - (fMaxArr - Abc_SclObjTimeMax(p, pObj));
170  if ( fSlackThis >= 0 )
171  Abc_SclFindCriticalNodeWindow_rec( p, Abc_ObjFanin0(pObj), vPath, fSlackThis, fDept );
172  }
173  // label critical nodes
174  Abc_NtkForEachObjVec( vPathCos, p->pNtk, pObj, i )
175  pObj->fMarkA = 1;
176  Abc_NtkForEachObjVec( vPath, p->pNtk, pObj, i )
177  pObj->fMarkA = 1;
178  return vPath;
179 }
181 {
182  Abc_Obj_t * pObj;
183  int i;
184  Abc_NtkForEachObjVec( vPath, p->pNtk, pObj, i )
185  pObj->fMarkA = 0;
186 }
188 {
189  int RetValue;
190  Vec_Int_t * vPathPos, * vPathNodes;
191  vPathPos = Abc_SclFindCriticalCoWindow( p, 5 );
192  vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, 5, 0 );
193  RetValue = Vec_IntSize(vPathNodes);
194  Abc_SclUnmarkCriticalNodeWindow( p, vPathNodes );
195  Abc_SclUnmarkCriticalNodeWindow( p, vPathPos );
196  Vec_IntFree( vPathPos );
197  Vec_IntFree( vPathNodes );
198  return RetValue;
199 }
200 
201 
202 /**Function*************************************************************
203 
204  Synopsis [Find the array of nodes to be updated.]
205 
206  Description []
207 
208  SideEffects []
209 
210  SeeAlso []
211 
212 ***********************************************************************/
213 void Abc_SclFindNodesToUpdate( Abc_Obj_t * pPivot, Vec_Int_t ** pvNodes, Vec_Int_t ** pvEvals, Abc_Obj_t * pExtra )
214 {
215  Abc_Ntk_t * p = Abc_ObjNtk(pPivot);
216  Abc_Obj_t * pObj, * pNext, * pNext2;
217  Vec_Int_t * vNodes = *pvNodes;
218  Vec_Int_t * vEvals = *pvEvals;
219  int i, k;
220  assert( Abc_ObjIsNode(pPivot) );
221  assert( pPivot->fMarkA );
222  // collect fanins, node, and fanouts
223  Vec_IntClear( vNodes );
224  Abc_ObjForEachFanin( pPivot, pNext, i )
225 // if ( Abc_ObjIsNode(pNext) && Abc_ObjFaninNum(pNext) > 0 )
226  if ( Abc_ObjIsCi(pNext) || Abc_ObjFaninNum(pNext) > 0 )
227  Vec_IntPush( vNodes, Abc_ObjId(pNext) );
228  Vec_IntPush( vNodes, Abc_ObjId(pPivot) );
229  if ( pExtra )
230  Vec_IntPush( vNodes, Abc_ObjId(pExtra) );
231  Abc_ObjForEachFanout( pPivot, pNext, i )
232  if ( Abc_ObjIsNode(pNext) && pNext->fMarkA )
233  {
234  Vec_IntPush( vNodes, Abc_ObjId(pNext) );
235  Abc_ObjForEachFanout( pNext, pNext2, k )
236  if ( Abc_ObjIsNode(pNext2) && pNext2->fMarkA )
237  Vec_IntPush( vNodes, Abc_ObjId(pNext2) );
238  }
239  Vec_IntUniqify( vNodes );
240  // label nodes
241  Abc_NtkForEachObjVec( vNodes, p, pObj, i )
242  {
243  assert( pObj->fMarkB == 0 );
244  pObj->fMarkB = 1;
245  }
246  // collect nodes visible from the critical paths
247  Vec_IntClear( vEvals );
248  Abc_NtkForEachObjVec( vNodes, p, pObj, i )
249  Abc_ObjForEachFanout( pObj, pNext, k )
250  if ( pNext->fMarkA && !pNext->fMarkB )
251 // if ( !pNext->fMarkB )
252  {
253  assert( pObj->fMarkB );
254  Vec_IntPush( vEvals, Abc_ObjId(pObj) );
255  break;
256  }
257  assert( Vec_IntSize(vEvals) > 0 );
258  // label nodes
259  Abc_NtkForEachObjVec( vNodes, p, pObj, i )
260  pObj->fMarkB = 0;
261 }
262 
263 
264 /**Function*************************************************************
265 
266  Synopsis []
267 
268  Description []
269 
270  SideEffects []
271 
272  SeeAlso []
273 
274 ***********************************************************************/
275 int Abc_SclFindBestCell( SC_Man * p, Abc_Obj_t * pObj, Vec_Int_t * vRecalcs, Vec_Int_t * vEvals, int Notches, int DelayGap, float * pGainBest )
276 {
277  SC_Cell * pCellOld, * pCellNew;
278  float dGain, dGainBest;
279  int k, gateBest, NoChange = 0;
280  // save old gate, timing, fanin load
281  pCellOld = Abc_SclObjCell( pObj );
282  Abc_SclConeStore( p, vRecalcs );
283  Abc_SclEvalStore( p, vEvals );
284  Abc_SclLoadStore( p, pObj );
285  // try different gate sizes for this node
286  gateBest = -1;
287  dGainBest = -DelayGap;
288  SC_RingForEachCell( pCellOld, pCellNew, k )
289  {
290  if ( pCellNew == pCellOld )
291  continue;
292  if ( k > Notches )
293  break;
294  // set new cell
295  Abc_SclObjSetCell( pObj, pCellNew );
296  Abc_SclUpdateLoad( p, pObj, pCellOld, pCellNew );
297  // recompute timing
298  Abc_SclTimeCone( p, vRecalcs );
299  // set old cell
300  Abc_SclObjSetCell( pObj, pCellOld );
301  Abc_SclLoadRestore( p, pObj );
302  // save best gain
303  dGain = Abc_SclEvalPerform( p, vEvals );
304  if ( dGainBest < dGain )
305  {
306  dGainBest = dGain;
307  gateBest = pCellNew->Id;
308  NoChange = 1;
309  }
310  else if ( NoChange )
311  NoChange++;
312  if ( NoChange == 4 )
313  break;
314 // printf( "%.2f ", dGain );
315  }
316 // printf( "Best = %.2f ", dGainBest );
317 // printf( "\n" );
318  // put back old cell and timing
319  Abc_SclObjSetCell( pObj, pCellOld );
320  Abc_SclConeRestore( p, vRecalcs );
321  *pGainBest = dGainBest;
322  return gateBest;
323 }
324 
325 /**Function*************************************************************
326 
327  Synopsis [Computes the set of gates to upsize.]
328 
329  Description []
330 
331  SideEffects []
332 
333  SeeAlso []
334 
335 ***********************************************************************/
336 int Abc_SclFindBypasses( SC_Man * p, Vec_Int_t * vPathNodes, int Ratio, int Notches, int iIter, int DelayGap, int fVeryVerbose )
337 {
338  SC_Cell * pCellOld, * pCellNew;
339  Vec_Ptr_t * vFanouts;
340  Vec_Int_t * vRecalcs, * vEvals;
341  Abc_Obj_t * pBuf, * pFanin, * pFanout, * pExtra;
342  int i, j, iNode, gateBest, gateBest2, fanBest, Counter = 0;
343  float dGainBest, dGainBest2;
344 
345  // compute savings due to bypassing buffers
346  vFanouts = Vec_PtrAlloc( 100 );
347  vRecalcs = Vec_IntAlloc( 100 );
348  vEvals = Vec_IntAlloc( 100 );
349  Vec_QueClear( p->vNodeByGain );
350  Abc_NtkForEachObjVec( vPathNodes, p->pNtk, pBuf, i )
351  {
352  assert( pBuf->fMarkB == 0 );
353  if ( Abc_ObjFaninNum(pBuf) != 1 )
354  continue;
355  pFanin = Abc_ObjFanin0(pBuf);
356  if ( !Abc_ObjIsNode(pFanin) )
357  continue;
358  pExtra = NULL;
359  if ( p->pNtk->vPhases == NULL )
360  {
361  if ( Abc_SclIsInv(pBuf) )
362  {
363  if ( !Abc_SclIsInv(pFanin) )
364  continue;
365  pFanin = Abc_ObjFanin0(pFanin);
366  if ( !Abc_ObjIsNode(pFanin) )
367  continue;
368  pExtra = pBuf;
369  // we make pBuf and pFanin are in the same phase and pFanin is a node
370  }
371  }
372  // here we have pBuf and its fanin pFanin, which is a logic node
373  // compute nodes to recalculate timing and nodes to evaluate afterwards
374  Abc_SclFindNodesToUpdate( pFanin, &vRecalcs, &vEvals, pExtra );
375  assert( Vec_IntSize(vEvals) > 0 );
376  // consider fanouts of this node
377  fanBest = -1;
378  gateBest2 = -1;
379  dGainBest2 = 0;
380  Abc_NodeCollectFanouts( pBuf, vFanouts );
381  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, j )
382  {
383  // skip COs
384  if ( Abc_ObjIsCo(pFanout) )
385  continue;
386  // skip non-critical fanouts
387  if ( !pFanout->fMarkA )
388  continue;
389  // skip if fanin already has fanout as a fanout
390  if ( Abc_NodeFindFanin(pFanout, pFanin) >= 0 )
391  continue;
392  // skip if fanin already has fanout as a fanout
393  if ( pExtra && Abc_NodeFindFanin(pFanout, pExtra) >= 0 )
394  continue;
395  // prepare
396  Abc_SclLoadStore3( p, pBuf );
397  Abc_SclUpdateLoadSplit( p, pBuf, pFanout );
398  Abc_ObjPatchFanin( pFanout, pBuf, pFanin );
399  // size the fanin
400  gateBest = Abc_SclFindBestCell( p, pFanin, vRecalcs, vEvals, Notches, DelayGap, &dGainBest );
401  // unprepare
402  Abc_SclLoadRestore3( p, pBuf );
403  Abc_ObjPatchFanin( pFanout, pFanin, pBuf );
404  if ( gateBest == -1 )
405  continue;
406  // compare gain
407  if ( dGainBest2 < dGainBest )
408  {
409  dGainBest2 = dGainBest;
410  gateBest2 = gateBest;
411  fanBest = Abc_ObjId(pFanout);
412  }
413  }
414  // remember savings
415  if ( gateBest2 >= 0 )
416  {
417  assert( dGainBest2 > 0.0 );
418  Vec_FltWriteEntry( p->vNode2Gain, Abc_ObjId(pBuf), dGainBest2 );
419  Vec_IntWriteEntry( p->vNode2Gate, Abc_ObjId(pBuf), gateBest2 );
420  Vec_QuePush( p->vNodeByGain, Abc_ObjId(pBuf) );
421  Vec_IntWriteEntry( p->vBestFans, Abc_ObjId(pBuf), fanBest );
422  }
423 // if ( ++Counter == 17 )
424 // break;
425  }
426  Vec_PtrFree( vFanouts );
427  Vec_IntFree( vRecalcs );
428  Vec_IntFree( vEvals );
429  if ( Vec_QueSize(p->vNodeByGain) == 0 )
430  return 0;
431  if ( fVeryVerbose )
432  printf( "\n" );
433 
434  // accept changes for that are half above the average and do not overlap
435  Counter = 0;
436  dGainBest2 = -1;
437  vFanouts = Vec_PtrAlloc( 100 );
438  while ( Vec_QueSize(p->vNodeByGain) )
439  {
440  iNode = Vec_QuePop(p->vNodeByGain);
441  pFanout = Abc_NtkObj( p->pNtk, Vec_IntEntry(p->vBestFans, iNode) );
442  pBuf = Abc_NtkObj( p->pNtk, iNode );
443  pFanin = Abc_ObjFanin0(pBuf);
444  if ( pFanout->fMarkB || pBuf->fMarkB )
445  continue;
446  if ( p->pNtk->vPhases == NULL )
447  {
448  // update fanin
449  if ( Abc_SclIsInv(pBuf) )
450  {
451  if ( !Abc_SclIsInv(pFanin) )
452  {
453  assert( 0 );
454  continue;
455  }
456  pFanin = Abc_ObjFanin0(pFanin);
457  if ( !Abc_ObjIsNode(pFanin) )
458  {
459  assert( 0 );
460  continue;
461  }
462  }
463  }
464  if ( pFanin->fMarkB )
465  continue;
466  pFanout->fMarkB = 1;
467  pBuf->fMarkB = 1;
468  pFanin->fMarkB = 1;
469  Vec_PtrPush( vFanouts, pFanout );
470  Vec_PtrPush( vFanouts, pBuf );
471  Vec_PtrPush( vFanouts, pFanin );
472  // remember gain
473  if ( dGainBest2 == -1 )
474  dGainBest2 = Vec_FltEntry(p->vNode2Gain, iNode);
475 // else if ( dGainBest2 > 2*Vec_FltEntry(p->vNode2Gain, iNode) )
476 // break;
477  // redirect
478  Abc_SclUpdateLoadSplit( p, pBuf, pFanout );
479  Abc_SclAddWireLoad( p, pBuf, 1 );
480  Abc_SclAddWireLoad( p, pFanin, 1 );
481  Abc_ObjPatchFanin( pFanout, pBuf, pFanin );
482  Abc_SclAddWireLoad( p, pBuf, 0 );
483  Abc_SclAddWireLoad( p, pFanin, 0 );
484  Abc_SclTimeIncUpdateLevel( pFanout );
485  // remember
486  Vec_IntPush( p->vUpdates2, Abc_ObjId(pFanout) );
487  Vec_IntPush( p->vUpdates2, Abc_ObjId(pFanin) );
488  Vec_IntPush( p->vUpdates2, Abc_ObjId(pBuf) );
489  // update cell
490  pCellOld = Abc_SclObjCell( pFanin );
491  pCellNew = SC_LibCell( p->pLib, Vec_IntEntry(p->vNode2Gate, iNode) );
492  p->SumArea += pCellNew->area - pCellOld->area;
493  Abc_SclObjSetCell( pFanin, pCellNew );
494  Abc_SclUpdateLoad( p, pFanin, pCellOld, pCellNew );
495  // record the update
496  Vec_IntPush( p->vUpdates, Abc_ObjId(pFanin) );
497  Vec_IntPush( p->vUpdates, pCellNew->Id );
498  Abc_SclTimeIncInsert( p, pFanout );
499  Abc_SclTimeIncInsert( p, pBuf );
500  Abc_SclTimeIncInsert( p, pFanin );
501  // remember when this node was upsized
502  Vec_IntWriteEntry( p->vNodeIter, Abc_ObjId(pFanout), -1 );
503  Vec_IntWriteEntry( p->vNodeIter, Abc_ObjId(pBuf), -1 );
504  Vec_IntWriteEntry( p->vNodeIter, Abc_ObjId(pFanin), -1 );
505  // update polarity
506  if ( p->pNtk->vPhases && Abc_SclIsInv(pBuf) )
507  Abc_NodeInvUpdateObjFanoutPolarity( pFanin, pFanout );
508  // report
509  if ( fVeryVerbose )
510  {
511  printf( "Node %6d Redir fanout %6d to fanin %6d. Gain = %7.1f ps. ",
512  Abc_ObjId(pBuf), Abc_ObjId(pFanout), Abc_ObjId(pFanin), Vec_FltEntry(p->vNode2Gain, iNode) );
513  printf( "Gate %12s (%2d/%2d) -> %12s (%2d/%2d) \n",
514  pCellOld->pName, pCellOld->Order, pCellOld->nGates,
515  pCellNew->pName, pCellNew->Order, pCellNew->nGates );
516  }
517 /*
518  // check if the node became useless
519  if ( Abc_ObjFanoutNum(pBuf) == 0 )
520  {
521  pCellOld = Abc_SclObjCell( pBuf );
522  p->SumArea -= pCellOld->area;
523  Abc_NtkDeleteObj_rec( pBuf, 1 );
524  printf( "Removed node %d.\n", iNode );
525  }
526 */
527  Counter++;
528  }
529  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, j )
530  pFanout->fMarkB = 0;
531  Vec_PtrFree( vFanouts );
532  return Counter;
533 }
534 
535 /**Function*************************************************************
536 
537  Synopsis [Check marked fanin/fanouts.]
538 
539  Description []
540 
541  SideEffects []
542 
543  SeeAlso []
544 
545 ***********************************************************************/
547 {
548  Abc_Obj_t * pNext;
549  int i;
550  if ( pObj->fMarkB )
551  return 1;
552  Abc_ObjForEachFanin( pObj, pNext, i )
553  if ( pNext->fMarkB )
554  return 1;
555  Abc_ObjForEachFanout( pObj, pNext, i )
556  if ( pNext->fMarkB )
557  return 1;
558  return 0;
559 }
560 void Abc_SclObjMarkFanFans( Abc_Obj_t * pObj, Vec_Ptr_t * vNodes )
561 {
562 // Abc_Obj_t * pNext;
563 // int i;
564  if ( pObj->fMarkB == 0 )
565  {
566  Vec_PtrPush( vNodes, pObj );
567  pObj->fMarkB = 1;
568  }
569 /*
570  Abc_ObjForEachFanin( pObj, pNext, i )
571  if ( pNext->fMarkB == 0 )
572  {
573  Vec_PtrPush( vNodes, pNext );
574  pNext->fMarkB = 1;
575  }
576  Abc_ObjForEachFanout( pObj, pNext, i )
577  if ( pNext->fMarkB == 0 )
578  {
579  Vec_PtrPush( vNodes, pNext );
580  pNext->fMarkB = 1;
581  }
582 */
583 }
584 
585 /**Function*************************************************************
586 
587  Synopsis [Computes the set of gates to upsize.]
588 
589  Description []
590 
591  SideEffects []
592 
593  SeeAlso []
594 
595 ***********************************************************************/
596 int Abc_SclFindUpsizes( SC_Man * p, Vec_Int_t * vPathNodes, int Ratio, int Notches, int iIter, int DelayGap, int fMoreConserf )
597 {
598  SC_Cell * pCellOld, * pCellNew;
599  Vec_Int_t * vRecalcs, * vEvals;
600  Vec_Ptr_t * vFanouts;
601  Abc_Obj_t * pObj;
602  float dGainBest, dGainBest2;
603  int i, gateBest, Limit, Counter, iIterLast;
604 
605  // compute savings due to upsizing each node
606  vRecalcs = Vec_IntAlloc( 100 );
607  vEvals = Vec_IntAlloc( 100 );
608  Vec_QueClear( p->vNodeByGain );
609  Abc_NtkForEachObjVec( vPathNodes, p->pNtk, pObj, i )
610  {
611  assert( pObj->fMarkB == 0 );
612  iIterLast = Vec_IntEntry(p->vNodeIter, Abc_ObjId(pObj));
613  if ( iIterLast >= 0 && iIterLast + 5 > iIter )
614  continue;
615  // compute nodes to recalculate timing and nodes to evaluate afterwards
616  Abc_SclFindNodesToUpdate( pObj, &vRecalcs, &vEvals, NULL );
617  assert( Vec_IntSize(vEvals) > 0 );
618  //printf( "%d -> %d\n", Vec_IntSize(vRecalcs), Vec_IntSize(vEvals) );
619  gateBest = Abc_SclFindBestCell( p, pObj, vRecalcs, vEvals, Notches, DelayGap, &dGainBest );
620  // remember savings
621  if ( gateBest >= 0 )
622  {
623  assert( dGainBest > 0.0 );
624  Vec_FltWriteEntry( p->vNode2Gain, Abc_ObjId(pObj), dGainBest );
625  Vec_IntWriteEntry( p->vNode2Gate, Abc_ObjId(pObj), gateBest );
626  Vec_QuePush( p->vNodeByGain, Abc_ObjId(pObj) );
627  }
628  }
629  Vec_IntFree( vRecalcs );
630  Vec_IntFree( vEvals );
631  if ( Vec_QueSize(p->vNodeByGain) == 0 )
632  return 0;
633 /*
634  Limit = Abc_MinInt( Vec_QueSize(p->vNodeByGain), Abc_MaxInt((int)(0.01 * Ratio * Vec_IntSize(vPathNodes)), 1) );
635  //printf( "\nSelecting %d out of %d\n", Limit, Vec_QueSize(p->vNodeByGain) );
636  for ( i = 0; i < Limit; i++ )
637  {
638  // get the object
639  pObj = Abc_NtkObj( p->pNtk, Vec_QuePop(p->vNodeByGain) );
640  assert( pObj->fMarkA );
641  // find old and new gates
642  pCellOld = Abc_SclObjCell( pObj );
643  pCellNew = SC_LibCell( p->pLib, Vec_IntEntry(p->vNode2Gate, Abc_ObjId(pObj)) );
644  assert( pCellNew != NULL );
645  //printf( "%6d %20s -> %20s ", Abc_ObjId(pObj), pCellOld->pName, pCellNew->pName );
646  //printf( "gain is %f\n", Vec_FltEntry(p->vNode2Gain, Abc_ObjId(pObj)) );
647  // update gate
648  Abc_SclUpdateLoad( p, pObj, pCellOld, pCellNew );
649  p->SumArea += pCellNew->area - pCellOld->area;
650  Abc_SclObjSetCell( pObj, pCellNew );
651  // record the update
652  Vec_IntPush( p->vUpdates, Abc_ObjId(pObj) );
653  Vec_IntPush( p->vUpdates, pCellNew->Id );
654  Abc_SclTimeIncInsert( p, pObj );
655  // remember when this node was upsized
656  Vec_IntWriteEntry( p->vNodeIter, Abc_ObjId(pObj), iIter );
657  }
658 return Limit;
659 */
660 
661  Limit = Abc_MinInt( Vec_QueSize(p->vNodeByGain), Abc_MaxInt((int)(0.01 * Ratio * Vec_IntSize(vPathNodes)), 1) );
662  dGainBest2 = -1;
663  Counter = 0;
664  vFanouts = Vec_PtrAlloc( 100 );
665  while ( Vec_QueSize(p->vNodeByGain) )
666  {
667  int iNode = Vec_QuePop(p->vNodeByGain);
668  Abc_Obj_t * pObj = Abc_NtkObj( p->pNtk, iNode );
669  assert( pObj->fMarkA );
670  if ( Abc_SclObjCheckMarkedFanFans( pObj ) )
671  continue;
672  Abc_SclObjMarkFanFans( pObj, vFanouts );
673  // remember gain
674  if ( dGainBest2 == -1 )
675  dGainBest2 = Vec_FltEntry(p->vNode2Gain, iNode);
676 // else if ( dGainBest2 > 3*Vec_FltEntry(p->vNode2Gain, iNode) )
677 // break;
678 // printf( "%.1f ", Vec_FltEntry(p->vNode2Gain, iNode) );
679 
680  // find old and new gates
681  pCellOld = Abc_SclObjCell( pObj );
682  pCellNew = SC_LibCell( p->pLib, Vec_IntEntry(p->vNode2Gate, Abc_ObjId(pObj)) );
683  assert( pCellNew != NULL );
684  //printf( "%6d %20s -> %20s ", Abc_ObjId(pObj), pCellOld->pName, pCellNew->pName );
685  //printf( "gain is %f\n", Vec_FltEntry(p->vNode2Gain, Abc_ObjId(pObj)) );
686 // if ( pCellOld->Order > 0 )
687 // printf( "%.2f %d -> %d(%d) ", Vec_FltEntry(p->vNode2Gain, iNode), pCellOld->Order, pCellNew->Order, pCellNew->nGates );
688  // update gate
689  p->SumArea += pCellNew->area - pCellOld->area;
690  Abc_SclObjSetCell( pObj, pCellNew );
691  Abc_SclUpdateLoad( p, pObj, pCellOld, pCellNew );
692  // record the update
693  Vec_IntPush( p->vUpdates, Abc_ObjId(pObj) );
694  Vec_IntPush( p->vUpdates, pCellNew->Id );
695  Abc_SclTimeIncInsert( p, pObj );
696  // remember when this node was upsized
697  Vec_IntWriteEntry( p->vNodeIter, Abc_ObjId(pObj), iIter );
698  Counter++;
699  if ( Counter == Limit )
700  break;
701  }
702 // printf( "\n" );
703 
704  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pObj, i )
705  pObj->fMarkB = 0;
706  Vec_PtrFree( vFanouts );
707  return Counter;
708 }
709 void Abc_SclApplyUpdateToBest( Vec_Int_t * vGatesBest, Vec_Int_t * vGates, Vec_Int_t * vUpdate )
710 {
711  int i, ObjId, GateId, GateId2;
712  Vec_IntForEachEntryDouble( vUpdate, ObjId, GateId, i )
713  Vec_IntWriteEntry( vGatesBest, ObjId, GateId );
714  Vec_IntClear( vUpdate );
715  Vec_IntForEachEntryTwo( vGatesBest, vGates, GateId, GateId2, i )
716  assert( GateId == GateId2 );
717 // Vec_IntClear( vGatesBest );
718 // Vec_IntAppend( vGatesBest, vGates );
719 }
721 {
722  int i;
723  assert( Vec_IntSize(vTrans) % 3 == 0 );
724  for ( i = Vec_IntSize(vTrans)/3 - 1; i >= 0; i-- )
725  {
726  Abc_Obj_t * pFanout = Abc_NtkObj( pNtk, Vec_IntEntry(vTrans, 3*i+0) );
727  Abc_Obj_t * pFanin = Abc_NtkObj( pNtk, Vec_IntEntry(vTrans, 3*i+1) );
728  Abc_Obj_t * pObj = Abc_NtkObj( pNtk, Vec_IntEntry(vTrans, 3*i+2) );
729  // we do not update load here because times will be recomputed
730  Abc_ObjPatchFanin( pFanout, pFanin, pObj );
731  Abc_SclTimeIncUpdateLevel( pFanout );
732 // printf( "Node %6d Redir fanout %6d from fanin %6d. \n",
733 // Abc_ObjId(pObj), Abc_ObjId(pFanout), Abc_ObjId(pFanin) );
734  // update polarity
735  if ( pNtk->vPhases && Abc_SclIsInv(pObj) )
736  Abc_NodeInvUpdateObjFanoutPolarity( pObj, pFanout );
737  }
738 }
739 
740 /**Function*************************************************************
741 
742  Synopsis []
743 
744  Description []
745 
746  SideEffects []
747 
748  SeeAlso []
749 
750 ***********************************************************************/
752 {
753  float fDiff = (float)0.001;
754  int k;
755  Abc_Obj_t * pObj;
756 
757  SC_Pair * pTimes = ABC_ALLOC( SC_Pair, p->nObjs );
758  SC_Pair * pSlews = ABC_ALLOC( SC_Pair, p->nObjs );
759  SC_Pair * pLoads = ABC_ALLOC( SC_Pair, p->nObjs );
760 
761  memcpy( pTimes, p->pTimes, sizeof(SC_Pair) * p->nObjs );
762  memcpy( pSlews, p->pSlews, sizeof(SC_Pair) * p->nObjs );
763  memcpy( pLoads, p->pLoads, sizeof(SC_Pair) * p->nObjs );
764 
765  Abc_SclTimeNtkRecompute( p, NULL, NULL, 0, 0 );
766 
767  Abc_NtkForEachNode( pNtk, pObj, k )
768  {
769  if ( Abc_AbsFloat(p->pLoads[k].rise - pLoads[k].rise) > fDiff )
770  printf( "%6d : load rise differs %12.6f %f %f\n", k, p->pLoads[k].rise-pLoads[k].rise, p->pLoads[k].rise, pLoads[k].rise );
771  if ( Abc_AbsFloat(p->pLoads[k].fall - pLoads[k].fall) > fDiff )
772  printf( "%6d : load fall differs %12.6f %f %f\n", k, p->pLoads[k].fall-pLoads[k].fall, p->pLoads[k].fall, pLoads[k].fall );
773 
774  if ( Abc_AbsFloat(p->pSlews[k].rise - pSlews[k].rise) > fDiff )
775  printf( "%6d : slew rise differs %12.6f %f %f\n", k, p->pSlews[k].rise-pSlews[k].rise, p->pSlews[k].rise, pSlews[k].rise );
776  if ( Abc_AbsFloat(p->pSlews[k].fall - pSlews[k].fall) > fDiff )
777  printf( "%6d : slew fall differs %12.6f %f %f\n", k, p->pSlews[k].fall-pSlews[k].fall, p->pSlews[k].fall, pSlews[k].fall );
778 
779  if ( Abc_AbsFloat(p->pTimes[k].rise - pTimes[k].rise) > fDiff )
780  printf( "%6d : time rise differs %12.6f %f %f\n", k, p->pTimes[k].rise-pTimes[k].rise, p->pTimes[k].rise, pTimes[k].rise );
781  if ( Abc_AbsFloat(p->pTimes[k].fall - pTimes[k].fall) > fDiff )
782  printf( "%6d : time fall differs %12.6f %f %f\n", k, p->pTimes[k].fall-pTimes[k].fall, p->pTimes[k].fall, pTimes[k].fall );
783  }
784 
785 /*
786 if ( memcmp( pTimes, p->pTimes, sizeof(SC_Pair) * p->nObjs ) )
787  printf( "Times differ!\n" );
788 if ( memcmp( pSlews, p->pSlews, sizeof(SC_Pair) * p->nObjs ) )
789  printf( "Slews differ!\n" );
790 if ( memcmp( pLoads, p->pLoads, sizeof(SC_Pair) * p->nObjs ) )
791  printf( "Loads differ!\n" );
792 */
793 
794  ABC_FREE( pTimes );
795  ABC_FREE( pSlews );
796  ABC_FREE( pLoads );
797 }
798 
799 /**Function*************************************************************
800 
801  Synopsis [Print cumulative statistics.]
802 
803  Description []
804 
805  SideEffects []
806 
807  SeeAlso []
808 
809 ***********************************************************************/
810 void Abc_SclUpsizePrint( SC_Man * p, int Iter, int win, int nPathPos, int nPathNodes, int nUpsizes, int nTFOs, int fVerbose )
811 {
812  printf( "%4d ", Iter );
813  printf( "Win:%3d. ", win );
814  printf( "PO:%6d. ", nPathPos );
815  printf( "Path:%7d. ", nPathNodes );
816  printf( "Gate:%5d. ", nUpsizes );
817  printf( "TFO:%7d. ", nTFOs );
818  printf( "A: " );
819  printf( "%.2f ", p->SumArea );
820  printf( "(%+5.1f %%) ", 100.0 * (p->SumArea - p->SumArea0)/ p->SumArea0 );
821  printf( "D: " );
822  printf( "%.2f ps ", p->MaxDelay );
823  printf( "(%+5.1f %%) ", 100.0 * (p->MaxDelay - p->MaxDelay0)/ p->MaxDelay0 );
824  printf( "B: " );
825  printf( "%.2f ps ", p->BestDelay );
826  printf( "(%+5.1f %%)", 100.0 * (p->BestDelay - p->MaxDelay0)/ p->MaxDelay0 );
827  printf( "%8.2f sec ", 1.0*(Abc_Clock() - p->timeTotal)/(CLOCKS_PER_SEC) );
828  printf( "%c", fVerbose ? '\n' : '\r' );
829 }
830 
831 /**Function*************************************************************
832 
833  Synopsis []
834 
835  Description []
836 
837  SideEffects []
838 
839  SeeAlso []
840 
841 ***********************************************************************/
843 {
844  SC_Cell * pCell;
845  Abc_Obj_t * pObj;
846  int i;
847  Abc_NtkForEachNodeNotBarBuf( pNtk, pObj, i )
848  if ( Abc_ObjFanoutNum(pObj) == 0 )
849  {
850  pCell = Abc_SclObjCell( pObj );
851  p->SumArea -= pCell->area;
852  Abc_NtkDeleteObj_rec( pObj, 1 );
853 // printf( "Removed node %d.\n", i );
854  }
855 }
856 
857 /**Function*************************************************************
858 
859  Synopsis []
860 
861  Description []
862 
863  SideEffects []
864 
865  SeeAlso []
866 
867 ***********************************************************************/
868 void Abc_SclUpsizePerform( SC_Lib * pLib, Abc_Ntk_t * pNtk, SC_SizePars * pPars )
869 {
870  SC_Man * p;
871  Vec_Int_t * vPathPos = NULL; // critical POs
872  Vec_Int_t * vPathNodes = NULL; // critical nodes and PIs
873  abctime clk, nRuntimeLimit = pPars->TimeOut ? pPars->TimeOut * CLOCKS_PER_SEC + Abc_Clock() : 0;
874  int i = 0, win, nUpsizes = -1, nFramesNoChange = 0, nConeSize = 0;
875  int nAllPos, nAllNodes, nAllTfos, nAllUpsizes;
876  if ( pPars->fVerbose )
877  {
878  printf( "Parameters: " );
879  printf( "Iters =%5d. ", pPars->nIters );
880  printf( "Time win =%3d %%. ", pPars->Window );
881  printf( "Update ratio =%3d %%. ", pPars->Ratio );
882  printf( "UseDept =%2d. ", pPars->fUseDept );
883  printf( "UseWL =%2d. ", pPars->fUseWireLoads );
884  printf( "Target =%5d ps. ", pPars->DelayUser );
885  printf( "DelayGap =%3d ps. ", pPars->DelayGap );
886  printf( "Timeout =%4d sec", pPars->TimeOut );
887  printf( "\n" );
888  }
889  // increase window for larger networks
890  if ( pPars->Window == 1 )
891  pPars->Window += (Abc_NtkNodeNum(pNtk) > 40000);
892  // prepare the manager; collect init stats
893  p = Abc_SclManStart( pLib, pNtk, pPars->fUseWireLoads, pPars->fUseDept, 0, pPars->BuffTreeEst );
894  p->timeTotal = Abc_Clock();
895  assert( p->vGatesBest == NULL );
896  p->vGatesBest = Vec_IntDup( p->pNtk->vGates );
897  p->BestDelay = p->MaxDelay0;
898  // perform upsizing
899  nAllPos = nAllNodes = nAllTfos = nAllUpsizes = 0;
900  if ( p->BestDelay <= pPars->DelayUser )
901  printf( "Current delay (%.2f ps) does not exceed the target delay (%.2f ps). Upsizing is not performed.\n", p->BestDelay, (float)pPars->DelayUser );
902  else
903  for ( i = 0; i < pPars->nIters; i++ )
904  {
905  for ( win = pPars->Window + ((i % 7) == 6); win <= 100; win *= 2 )
906  {
907  // detect critical path
908  clk = Abc_Clock();
909  vPathPos = Abc_SclFindCriticalCoWindow( p, win );
910  vPathNodes = Abc_SclFindCriticalNodeWindow( p, vPathPos, win, pPars->fUseDept );
911  p->timeCone += Abc_Clock() - clk;
912 
913  // selectively upsize the nodes
914  clk = Abc_Clock();
915  if ( pPars->BypassFreq && i && (i % pPars->BypassFreq) == 0 )
916  nUpsizes = Abc_SclFindBypasses( p, vPathNodes, pPars->Ratio, pPars->Notches, i, pPars->DelayGap, pPars->fVeryVerbose );
917  else
918  nUpsizes = Abc_SclFindUpsizes( p, vPathNodes, pPars->Ratio, pPars->Notches, i, pPars->DelayGap, (pPars->BypassFreq > 0) );
919  p->timeSize += Abc_Clock() - clk;
920 
921  // unmark critical path
922  clk = Abc_Clock();
923  Abc_SclUnmarkCriticalNodeWindow( p, vPathNodes );
924  Abc_SclUnmarkCriticalNodeWindow( p, vPathPos );
925  p->timeCone += Abc_Clock() - clk;
926  if ( nUpsizes > 0 )
927  break;
928  Vec_IntFree( vPathPos );
929  Vec_IntFree( vPathNodes );
930  }
931  if ( nUpsizes == 0 )
932  break;
933 
934  // update timing information
935  clk = Abc_Clock();
936  if ( pPars->fUseDept )
937  {
938  if ( Vec_IntSize(p->vChanged) && !(pPars->BypassFreq && i && (i % pPars->BypassFreq) == 0) )
939  nConeSize = Abc_SclTimeIncUpdate( p );
940  else
941  Abc_SclTimeNtkRecompute( p, NULL, NULL, pPars->fUseDept, 0 );
942  }
943  else
944  {
945  Vec_Int_t * vTFO = Abc_SclFindTFO( p->pNtk, vPathNodes );
946  Abc_SclTimeCone( p, vTFO );
947  nConeSize = Vec_IntSize( vTFO );
948  Vec_IntFree( vTFO );
949  }
950  p->timeTime += Abc_Clock() - clk;
951 // Abc_SclUpsizePrintDiffs( p, pLib, pNtk );
952 
953  // save the best network
954  p->MaxDelay = Abc_SclReadMaxDelay( p );
955  if ( p->BestDelay > p->MaxDelay )
956  {
957  p->BestDelay = p->MaxDelay;
958  Abc_SclApplyUpdateToBest( p->vGatesBest, p->pNtk->vGates, p->vUpdates );
959  Vec_IntClear( p->vUpdates2 );
960  nFramesNoChange = 0;
961  }
962  else
963  nFramesNoChange++;
964 
965  // report and cleanup
966  Abc_SclUpsizePrint( p, i, win, Vec_IntSize(vPathPos), Vec_IntSize(vPathNodes), nUpsizes, nConeSize, pPars->fVeryVerbose || (pPars->fVerbose && nFramesNoChange == 0) ); //|| (i == nIters-1) );
967  nAllPos += Vec_IntSize(vPathPos);
968  nAllNodes += Vec_IntSize(vPathNodes);
969  nAllTfos += nConeSize;
970  nAllUpsizes += nUpsizes;
971  Vec_IntFree( vPathPos );
972  Vec_IntFree( vPathNodes );
973  // check timeout
974  if ( nRuntimeLimit && Abc_Clock() > nRuntimeLimit )
975  break;
976  // check no change
977  if ( nFramesNoChange > pPars->nIterNoChange )
978  break;
979  // check best delay
980  if ( p->BestDelay <= pPars->DelayUser )
981  break;
982  }
983  // update for best gates and recompute timing
984  ABC_SWAP( Vec_Int_t *, p->vGatesBest, p->pNtk->vGates );
985  if ( pPars->BypassFreq != 0 )
986  Abc_SclUndoRecentChanges( p->pNtk, p->vUpdates2 );
987  if ( pPars->BypassFreq != 0 )
988  Abc_SclUpsizeRemoveDangling( p, pNtk );
989  Abc_SclTimeNtkRecompute( p, &p->SumArea, &p->MaxDelay, 0, 0 );
990  if ( pPars->fVerbose )
991  Abc_SclUpsizePrint( p, i, pPars->Window, nAllPos/(i?i:1), nAllNodes/(i?i:1), nAllUpsizes/(i?i:1), nAllTfos/(i?i:1), 1 );
992  else
993  printf( " \r" );
994  // report runtime
995  p->timeTotal = Abc_Clock() - p->timeTotal;
996  if ( pPars->fVerbose )
997  {
998  p->timeOther = p->timeTotal - p->timeCone - p->timeSize - p->timeTime;
999  ABC_PRTP( "Runtime: Critical path", p->timeCone, p->timeTotal );
1000  ABC_PRTP( "Runtime: Sizing eval ", p->timeSize, p->timeTotal );
1001  ABC_PRTP( "Runtime: Timing update", p->timeTime, p->timeTotal );
1002  ABC_PRTP( "Runtime: Other ", p->timeOther, p->timeTotal );
1003  ABC_PRTP( "Runtime: TOTAL ", p->timeTotal, p->timeTotal );
1004  }
1005  if ( pPars->fDumpStats )
1006  Abc_SclDumpStats( p, "stats2.txt", p->timeTotal );
1007  if ( nRuntimeLimit && Abc_Clock() > nRuntimeLimit )
1008  printf( "Gate sizing timed out at %d seconds.\n", pPars->TimeOut );
1009 
1010  // save the result and quit
1011  Abc_SclSclGates2MioGates( pLib, pNtk ); // updates gate pointers
1012  Abc_SclManFree( p );
1013 // Abc_NtkCleanMarkAB( pNtk );
1014 }
1015 
1016 ////////////////////////////////////////////////////////////////////////
1017 /// END OF FILE ///
1018 ////////////////////////////////////////////////////////////////////////
1019 
1020 
1022 
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static float Abc_SclReadMaxDelay(SC_Man *p)
Definition: sclSize.h:474
void Abc_SclUpsizePrint(SC_Man *p, int Iter, int win, int nPathPos, int nPathNodes, int nUpsizes, int nTFOs, int fVerbose)
Definition: sclUpsize.c:810
void Abc_SclTimeNtkRecompute(SC_Man *p, float *pArea, float *pDelay, int fReverse, float DUser)
Definition: sclSize.c:400
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int nGates
Definition: sclLib.h:199
static float Abc_SclObjGetSlack(SC_Man *p, Abc_Obj_t *pObj, float D)
Definition: sclSize.h:125
static void Abc_SclLoadStore3(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:313
int Abc_SclIsInv(Abc_Obj_t *pObj)
Definition: sclBuffer.c:116
#define Abc_NtkForEachNodeNotBarBuf(pNtk, pNode, i)
Definition: abc.h:464
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
unsigned fMarkA
Definition: abc.h:134
static void Abc_SclConeStore(SC_Man *p, Vec_Int_t *vCone)
Definition: sclSize.h:339
Vec_Int_t * Abc_SclFindCriticalNodeWindow(SC_Man *p, Vec_Int_t *vPathCos, int Window, int fDept)
Definition: sclUpsize.c:159
void Abc_SclTimeIncInsert(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.c:562
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
static float Abc_AbsFloat(float a)
Definition: abc_global.h:242
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int DelayGap
Definition: sclLib.h:78
int Order
Definition: sclLib.h:198
void Abc_SclFindCriticalNodeWindow_rec(SC_Man *p, Abc_Obj_t *pObj, Vec_Int_t *vPath, float fSlack, int fDept)
Definition: sclUpsize.c:123
void Abc_NodeInvUpdateObjFanoutPolarity(Abc_Obj_t *pObj, Abc_Obj_t *pFanout)
Definition: sclBuffer.c:334
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static void Abc_SclConeRestore(SC_Man *p, Vec_Int_t *vCone)
Definition: sclSize.h:352
int TimeOut
Definition: sclLib.h:79
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcUtil.c:758
static void Abc_SclObjSetCell(Abc_Obj_t *p, SC_Cell *pCell)
Definition: sclSize.h:111
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
void Abc_SclApplyUpdateToBest(Vec_Int_t *vGatesBest, Vec_Int_t *vGates, Vec_Int_t *vUpdate)
Definition: sclUpsize.c:709
int fVeryVerbose
Definition: sclLib.h:86
ABC_DLL void Abc_NtkDeleteObj_rec(Abc_Obj_t *pObj, int fOnlyNodes)
Definition: abcObj.c:273
void Abc_SclFindNodesToUpdate(Abc_Obj_t *pPivot, Vec_Int_t **pvNodes, Vec_Int_t **pvEvals, Abc_Obj_t *pExtra)
Definition: sclUpsize.c:213
char * memcpy()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int Abc_SclObjCheckMarkedFanFans(Abc_Obj_t *pObj)
Definition: sclUpsize.c:546
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
void Abc_SclUpsizePrintDiffs(SC_Man *p, SC_Lib *pLib, Abc_Ntk_t *pNtk)
Definition: sclUpsize.c:751
static int Vec_QuePop(Vec_Que_t *p)
Definition: vecQue.h:234
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
typedefABC_NAMESPACE_HEADER_START struct SC_Man_ SC_Man
INCLUDES ///.
Definition: sclSize.h:44
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
void Abc_SclTimeIncUpdateLevel(Abc_Obj_t *pObj)
Definition: sclSize.c:576
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
int fVerbose
Definition: sclLib.h:85
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
Vec_Int_t * Abc_SclFindCriticalCoWindow(SC_Man *p, int Window)
Definition: sclUpsize.c:98
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
void Abc_SclUpsizeRemoveDangling(SC_Man *p, Abc_Ntk_t *pNtk)
Definition: sclUpsize.c:842
int Abc_SclTimeIncUpdate(SC_Man *p)
Definition: sclSize.c:540
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static void Abc_SclLoadStore(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:290
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
static void Vec_QueClear(Vec_Que_t *p)
Definition: vecQue.h:110
static int Vec_QueSize(Vec_Que_t *p)
Definition: vecQue.h:134
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Abc_SclLoadRestore(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:301
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
int fUseWireLoads
Definition: sclLib.h:84
static void Abc_SclManFree(SC_Man *p)
Definition: sclSize.h:192
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
static void Abc_SclDumpStats(SC_Man *p, char *pFileName, abctime Time)
Definition: sclSize.h:510
float area
Definition: sclLib.h:188
void Abc_SclUnmarkCriticalNodeWindow(SC_Man *p, Vec_Int_t *vPath)
Definition: sclUpsize.c:180
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int nIterNoChange
Definition: sclLib.h:73
float rise
Definition: sclLib.h:65
ABC_NAMESPACE_IMPL_START void Abc_SclFindTFO_rec(Abc_Obj_t *pObj, Vec_Int_t *vNodes, Vec_Int_t *vCos)
DECLARATIONS ///.
Definition: sclUpsize.c:45
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition: abc.h:452
float fall
Definition: sclLib.h:66
void Abc_SclUpsizePerform(SC_Lib *pLib, Abc_Ntk_t *pNtk, SC_SizePars *pPars)
Definition: sclUpsize.c:868
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void Abc_SclUpdateLoadSplit(SC_Man *p, Abc_Obj_t *pBuffer, Abc_Obj_t *pFanout)
Definition: sclLoad.c:212
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void Abc_SclUndoRecentChanges(Abc_Ntk_t *pNtk, Vec_Int_t *vTrans)
Definition: sclUpsize.c:720
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)
Definition: vecInt.h:64
int Id
Definition: sclLib.h:184
int Abc_SclFindUpsizes(SC_Man *p, Vec_Int_t *vPathNodes, int Ratio, int Notches, int iIter, int DelayGap, int fMoreConserf)
Definition: sclUpsize.c:596
static int Vec_IntUniqify(Vec_Int_t *p)
Definition: vecInt.h:1314
Vec_Int_t * vPhases
Definition: abc.h:208
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
char * pName
Definition: sclLib.h:183
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
static int Counter
void Abc_SclObjMarkFanFans(Abc_Obj_t *pObj, Vec_Ptr_t *vNodes)
Definition: sclUpsize.c:560
int DelayUser
Definition: sclLib.h:77
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
void Abc_SclSclGates2MioGates(SC_Lib *pLib, Abc_Ntk_t *p)
Definition: sclUtil.c:73
static void Abc_SclEvalStore(SC_Man *p, Vec_Int_t *vCone)
Definition: sclSize.h:365
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
int Notches
Definition: sclLib.h:76
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int Abc_SclFindBestCell(SC_Man *p, Abc_Obj_t *pObj, Vec_Int_t *vRecalcs, Vec_Int_t *vEvals, int Notches, int DelayGap, float *pGainBest)
Definition: sclUpsize.c:275
void Abc_SclTimeCone(SC_Man *p, Vec_Int_t *vCone)
Definition: sclSize.c:383
int fUseDept
Definition: sclLib.h:82
int BypassFreq
Definition: sclLib.h:81
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
unsigned fMarkB
Definition: abc.h:135
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static void Abc_SclLoadRestore3(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:326
static float Abc_SclEvalPerform(SC_Man *p, Vec_Int_t *vCone)
Definition: sclSize.h:376
int Window
Definition: sclLib.h:74
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Abc_SclCountNearCriticalNodes(SC_Man *p)
Definition: sclUpsize.c:187
void Abc_SclAddWireLoad(SC_Man *p, Abc_Obj_t *pObj, int fSubtr)
Definition: sclLoad.c:100
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
Vec_Int_t * Abc_SclFindTFO(Abc_Ntk_t *p, Vec_Int_t *vPath)
Definition: sclUpsize.c:63
static float Abc_SclGetMaxDelayNodeFanins(SC_Man *p, Abc_Obj_t *pNode)
Definition: sclSize.h:464
int nIters
Definition: sclLib.h:72
#define assert(ex)
Definition: util_old.h:213
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
static float Abc_SclObjTimeMax(SC_Man *p, Abc_Obj_t *pObj)
Definition: sclSize.h:121
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcUtil.c:1607
int BuffTreeEst
Definition: sclLib.h:80
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
int Ratio
Definition: sclLib.h:75
int fDumpStats
Definition: sclLib.h:83
static void Vec_QuePush(Vec_Que_t *p, int v)
Definition: vecQue.h:221
int Abc_SclFindBypasses(SC_Man *p, Vec_Int_t *vPathNodes, int Ratio, int Notches, int iIter, int DelayGap, int fVeryVerbose)
Definition: sclUpsize.c:336
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
void Abc_SclUpdateLoad(SC_Man *p, Abc_Obj_t *pObj, SC_Cell *pOld, SC_Cell *pNew)
Definition: sclLoad.c:199
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static SC_Cell * Abc_SclObjCell(Abc_Obj_t *p)
Definition: sclSize.h:110
SC_Man * Abc_SclManStart(SC_Lib *pLib, Abc_Ntk_t *pNtk, int fUseWireLoads, int fDept, float DUser, int nTreeCRatio)
Definition: sclSize.c:633