abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclBuffer.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [sclBuffer.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Standard-cell library representation.]
8 
9  Synopsis [Buffering algorithms.]
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: sclBuffer.c,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "sclSize.h"
22 #include "map/mio/mio.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 #define BUF_SCALE 1000
32 
33 typedef struct Buf_Man_t_ Buf_Man_t;
34 struct Buf_Man_t_
35 {
36  // parameters
37  int nFanMin; // the smallest fanout count to consider
38  int nFanMax; // the largest fanout count allowed off CP
39  int fBufPis; // enables buffing of the combinational inputs
40  // internal deta
41  Abc_Ntk_t * pNtk; // logic network
42  Vec_Int_t * vOffsets; // offsets into edge delays
43  Vec_Int_t * vEdges; // edge delays
44  Vec_Int_t * vArr; // arrival times
45  Vec_Int_t * vDep; // departure times
46  Vec_Flt_t * vCounts; // fanout counts
47  Vec_Que_t * vQue; // queue by fanout count
48  int nObjStart; // the number of starting objects
49  int nObjAlloc; // the number of allocated objects
50  int DelayMax; // maximum delay (percentage of inverter delay)
51  float DelayInv; // inverter delay
52  // sorting fanouts
53  Vec_Int_t * vOrder; // ordering of fanouts
54  Vec_Int_t * vDelays; // fanout delays
55  Vec_Int_t * vNonCrit; // non-critical fanouts
56  Vec_Int_t * vTfCone; // TFI/TFO cone of the node including the node
57  Vec_Ptr_t * vFanouts; // temp storage for fanouts
58  // statistics
59  int nSeparate;
61  int nBranch0;
62  int nBranch1;
64 };
65 
66 static inline int Abc_BufNodeArr( Buf_Man_t * p, Abc_Obj_t * pObj ) { return Vec_IntEntry( p->vArr, Abc_ObjId(pObj) ); }
67 static inline int Abc_BufNodeDep( Buf_Man_t * p, Abc_Obj_t * pObj ) { return Vec_IntEntry( p->vDep, Abc_ObjId(pObj) ); }
68 static inline void Abc_BufSetNodeArr( Buf_Man_t * p, Abc_Obj_t * pObj, int f ) { Vec_IntWriteEntry( p->vArr, Abc_ObjId(pObj), f ); }
69 static inline void Abc_BufSetNodeDep( Buf_Man_t * p, Abc_Obj_t * pObj, int f ) { Vec_IntWriteEntry( p->vDep, Abc_ObjId(pObj), f ); }
70 static inline int Abc_BufEdgeDelay( Buf_Man_t * p, Abc_Obj_t * pObj, int i ) { return Vec_IntEntry( p->vEdges, Vec_IntEntry(p->vOffsets, Abc_ObjId(pObj)) + i ); }
71 static inline void Abc_BufSetEdgeDelay( Buf_Man_t * p, Abc_Obj_t * pObj, int i, int f ) { Vec_IntWriteEntry( p->vEdges, Vec_IntEntry(p->vOffsets, Abc_ObjId(pObj)) + i, f ); }
72 static inline int Abc_BufNodeSlack( Buf_Man_t * p, Abc_Obj_t * pObj ) { return p->DelayMax - Abc_BufNodeArr(p, pObj) - Abc_BufNodeDep(p, pObj); }
73 static inline int Abc_BufEdgeSlack( Buf_Man_t * p, Abc_Obj_t * pObj, Abc_Obj_t * pFan ) { return p->DelayMax - Abc_BufNodeArr(p, pObj) - Abc_BufNodeDep(p, pFan) - Abc_BufEdgeDelay(p, pFan, Abc_NodeFindFanin(pFan, pObj)); }
74 
75 ////////////////////////////////////////////////////////////////////////
76 /// FUNCTION DEFINITIONS ///
77 ////////////////////////////////////////////////////////////////////////
78 
79 /**Function*************************************************************
80 
81  Synopsis [Make sure fanins of gates are not duplicated.]
82 
83  Description []
84 
85  SideEffects []
86 
87  SeeAlso []
88 
89 ***********************************************************************/
91 {
92  Abc_Obj_t * pObj, * pFanin, * pFanin2;
93  int i, k, k2;
94  Abc_NtkForEachNode( pNtk, pObj, i )
95  Abc_ObjForEachFanin( pObj, pFanin, k )
96  Abc_ObjForEachFanin( pObj, pFanin2, k2 )
97  if ( k != k2 && pFanin == pFanin2 )
98  printf( "Node %d has dup fanin %d.\n", i, Abc_ObjId(pFanin) );
99 }
100 
101 /**Function*************************************************************
102 
103  Synopsis [Removes buffers and inverters.]
104 
105  Description []
106 
107  SideEffects []
108 
109  SeeAlso []
110 
111 ***********************************************************************/
112 static inline int Abc_SclObjIsBufInv( Abc_Obj_t * pObj )
113 {
114  return Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) == 1;
115 }
116 int Abc_SclIsInv( Abc_Obj_t * pObj )
117 {
118  assert( Abc_ObjIsNode(pObj) );
119  return Mio_GateReadTruth((Mio_Gate_t *)pObj->pData) == ABC_CONST(0x5555555555555555);
120 }
122 {
123  int iLit;
124  if ( !Abc_SclObjIsBufInv(pObj) )
125  return Abc_Var2Lit( Abc_ObjId(pObj), 0 );
126  iLit = Abc_SclGetRealFaninLit( Abc_ObjFanin0(pObj) );
127  return Abc_LitNotCond( iLit, Abc_SclIsInv(pObj) );
128 }
129 Abc_Ntk_t * Abc_SclUnBufferPerform( Abc_Ntk_t * pNtk, int fVerbose )
130 {
131  Vec_Int_t * vLits;
132  Abc_Obj_t * pObj, * pFanin, * pFaninNew;
133  int i, k, iLit, nNodesOld = Abc_NtkObjNumMax(pNtk);
134  // assign inverters
135  vLits = Vec_IntStartFull( Abc_NtkObjNumMax(pNtk) );
136  Abc_NtkForEachNode( pNtk, pObj, i )
137  if ( Abc_SclIsInv(pObj) && !Abc_SclObjIsBufInv(Abc_ObjFanin0(pObj)) )
138  Vec_IntWriteEntry( vLits, Abc_ObjFaninId0(pObj), Abc_ObjId(pObj) );
139  // transfer fanins
140  Abc_NtkForEachNodeCo( pNtk, pObj, i )
141  {
142  if ( i >= nNodesOld )
143  break;
144  Abc_ObjForEachFanin( pObj, pFanin, k )
145  {
146  if ( !Abc_SclObjIsBufInv(pFanin) )
147  continue;
148  iLit = Abc_SclGetRealFaninLit( pFanin );
149  pFaninNew = Abc_NtkObj( pNtk, Abc_Lit2Var(iLit) );
150  if ( Abc_LitIsCompl(iLit) )
151  {
152  if ( Vec_IntEntry( vLits, Abc_Lit2Var(iLit) ) == -1 )
153  {
154  pFaninNew = Abc_NtkCreateNodeInv( pNtk, pFaninNew );
155  Vec_IntWriteEntry( vLits, Abc_Lit2Var(iLit), Abc_ObjId(pFaninNew) );
156  }
157  else
158  pFaninNew = Abc_NtkObj( pNtk, Vec_IntEntry( vLits, Abc_Lit2Var(iLit) ) );
159  assert( Abc_ObjFaninNum(pFaninNew) == 1 );
160  }
161  if ( pFanin != pFaninNew )
162  Abc_ObjPatchFanin( pObj, pFanin, pFaninNew );
163  }
164  }
165  Vec_IntFree( vLits );
166  // duplicate network in topo order
167  return Abc_NtkDupDfs( pNtk );
168 }
169 
170 /**Function*************************************************************
171 
172  Synopsis [Removes buffers and inverters.]
173 
174  Description []
175 
176  SideEffects []
177 
178  SeeAlso []
179 
180 ***********************************************************************/
182 {
183  Vec_Int_t * vPhLevel;
184  Abc_Obj_t * pObj, * pFanin;
185  int i, k, Max = 0, MaxAll = 0;
186  vPhLevel = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
187  Abc_NtkForEachNodeCo( pNtk, pObj, i )
188  {
189  Max = 0;
190  Abc_ObjForEachFanin( pObj, pFanin, k )
191  Max = Abc_MaxInt( Max, Vec_IntEntry(vPhLevel, Abc_ObjId(pFanin)) + Abc_ObjFaninPhase(pObj, k) );
192  Vec_IntWriteEntry( vPhLevel, i, Max );
193  MaxAll = Abc_MaxInt( MaxAll, Max );
194  }
195  Vec_IntFree( vPhLevel );
196  return MaxAll;
197 }
198 Abc_Ntk_t * Abc_SclBufferPhase( Abc_Ntk_t * pNtk, int fVerbose )
199 {
200  Abc_Ntk_t * pNtkNew;
201  Vec_Int_t * vInvs;
202  Abc_Obj_t * pObj, * pFanin, * pFaninNew;
203  int nNodesOld = Abc_NtkObjNumMax(pNtk);
204  int i, k, Counter = 0, Counter2 = 0, Total = 0;
205  assert( pNtk->vPhases != NULL );
206  vInvs = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
207  Abc_NtkForEachNodeCo( pNtk, pObj, i )
208  {
209  if ( i >= nNodesOld )
210  break;
211  Abc_ObjForEachFanin( pObj, pFanin, k )
212  {
213  Total++;
214  if ( !Abc_ObjFaninPhase(pObj, k) )
215  continue;
216  if ( Vec_IntEntry(vInvs, Abc_ObjId(pFanin)) == 0 || Abc_ObjIsCi(pFanin) ) // allow PIs to have high fanout - to be fixed later
217  {
218  pFaninNew = Abc_NtkCreateNodeInv( pNtk, pFanin );
219  Vec_IntWriteEntry( vInvs, Abc_ObjId(pFanin), Abc_ObjId(pFaninNew) );
220  Counter++;
221  }
222  pFaninNew = Abc_NtkObj( pNtk, Vec_IntEntry(vInvs, Abc_ObjId(pFanin)) );
223  Abc_ObjPatchFanin( pObj, pFanin, pFaninNew );
224  Counter2++;
225  }
226  }
227  if ( fVerbose )
228  printf( "Added %d inverters (%.2f %% fanins) (%.2f %% compl fanins).\n",
229  Counter, 100.0 * Counter / Total, 100.0 * Counter2 / Total );
230  Vec_IntFree( vInvs );
231  Vec_IntFillExtra( pNtk->vPhases, Abc_NtkObjNumMax(pNtk), 0 );
232  // duplicate network in topo order
233  vInvs = pNtk->vPhases;
234  pNtk->vPhases = NULL;
235  pNtkNew = Abc_NtkDupDfs( pNtk );
236  pNtk->vPhases = vInvs;
237  return pNtkNew;
238 }
239 Abc_Ntk_t * Abc_SclUnBufferPhase( Abc_Ntk_t * pNtk, int fVerbose )
240 {
241  Abc_Ntk_t * pNtkNew;
242  Abc_Obj_t * pObj, * pFanin, * pFaninNew;
243  int i, k, iLit, Counter = 0, Total = 0;
244  assert( pNtk->vPhases == NULL );
245  pNtk->vPhases = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
246  Abc_NtkForEachNodeCo( pNtk, pObj, i )
247  {
248  if ( Abc_SclObjIsBufInv(pObj) )
249  continue;
250  Abc_ObjForEachFanin( pObj, pFanin, k )
251  {
252  Total++;
253  iLit = Abc_SclGetRealFaninLit( pFanin );
254  pFaninNew = Abc_NtkObj( pNtk, Abc_Lit2Var(iLit) );
255  if ( pFaninNew == pFanin )
256  continue;
257  // skip fanins which are already fanins of the node
258  if ( Abc_NodeFindFanin( pObj, pFaninNew ) >= 0 )
259  continue;
260  Abc_ObjPatchFanin( pObj, pFanin, pFaninNew );
261  if ( Abc_LitIsCompl(iLit) )
262  Abc_ObjFaninFlipPhase( pObj, k ), Counter++;
263  }
264  }
265  if ( fVerbose )
266  printf( "Saved %d (%.2f %%) fanin phase bits. ", Counter, 100.0 * Counter / Total );
267  // duplicate network in topo order
268  pNtkNew = Abc_NtkDupDfs( pNtk );
269  if ( fVerbose )
270  printf( "Max depth = %d.\n", Abc_SclCountMaxPhases(pNtkNew) );
271  Abc_SclReportDupFanins( pNtkNew );
272  return pNtkNew;
273 }
274 
275 /**Function*************************************************************
276 
277  Synopsis [Make sure the network is in topo order without dangling nodes.]
278 
279  Description [Returns 1 iff the network is fine.]
280 
281  SideEffects []
282 
283  SeeAlso []
284 
285 ***********************************************************************/
286 int Abc_SclCheckNtk( Abc_Ntk_t * p, int fVerbose )
287 {
288  Abc_Obj_t * pObj, * pFanin;
289  int i, k, fFlag = 1;
291  Abc_NtkForEachCi( p, pObj, i )
292  Abc_NodeSetTravIdCurrent( pObj );
293  Abc_NtkForEachNode( p, pObj, i )
294  {
295  Abc_ObjForEachFanin( pObj, pFanin, k )
296  if ( !Abc_NodeIsTravIdCurrent( pFanin ) )
297  printf( "obj %d and its fanin %d are not in the topo order\n", Abc_ObjId(pObj), Abc_ObjId(pFanin) ), fFlag = 0;
298  Abc_NodeSetTravIdCurrent( pObj );
299  if ( Abc_ObjFanoutNum(pObj) == 0 )
300  printf( "node %d has no fanout\n", Abc_ObjId(pObj) ), fFlag = 0;
301  if ( !fFlag )
302  break;
303  }
304  if ( fFlag && fVerbose )
305  printf( "The network is in topo order and no dangling nodes.\n" );
306  return fFlag;
307 }
308 
309 /**Function*************************************************************
310 
311  Synopsis [Performs buffering of the mapped network (old code).]
312 
313  Description []
314 
315  SideEffects []
316 
317  SeeAlso []
318 
319 ***********************************************************************/
321 {
322  Abc_Obj_t * pFanout;
323  int i;
324  assert( Abc_ObjFaninNum(pObj) == 0 || Abc_SclObjIsBufInv(pObj) );
325  Abc_ObjForEachFanout( pObj, pFanout, i )
326  {
327  assert( Abc_ObjFaninNum(pFanout) > 0 );
328  if ( Abc_SclObjIsBufInv(pFanout) )
329  Abc_NodeInvUpdateFanPolarity( pFanout );
330  else
331  Abc_ObjFaninFlipPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) );
332  }
333 }
335 {
336  if ( Abc_SclObjIsBufInv(pFanout) )
337  Abc_NodeInvUpdateFanPolarity( pFanout );
338  else
339  Abc_ObjFaninFlipPhase( pFanout, Abc_NodeFindFanin(pFanout, pObj) );
340 }
342 {
343  int Diff = Abc_ObjLevel(*pp1) - Abc_ObjLevel(*pp2);
344  if ( Diff < 0 )
345  return -1;
346  if ( Diff > 0 )
347  return 1;
348  Diff = (*pp1)->Id - (*pp2)->Id; // needed to make qsort() platform-infependent
349  if ( Diff < 0 )
350  return -1;
351  if ( Diff > 0 )
352  return 1;
353  return 0;
354 }
356 {
357  Abc_Obj_t * pFanout;
358  int i, Level = 0;
359  Abc_ObjForEachFanout( pObj, pFanout, i )
360  Level = Abc_MaxInt( Level, pFanout->Level );
361  return Level + 1;
362 }
363 Abc_Obj_t * Abc_SclPerformBufferingOne( Abc_Obj_t * pObj, int Degree, int fUseInvs, int fVerbose )
364 {
365  Vec_Ptr_t * vFanouts;
366  Abc_Obj_t * pBuffer, * pFanout;
367  int i, Degree0 = Degree;
368  assert( Abc_ObjFanoutNum(pObj) > Degree );
369  // collect fanouts and sort by reverse level
370  vFanouts = Vec_PtrAlloc( Abc_ObjFanoutNum(pObj) );
371  Abc_NodeCollectFanouts( pObj, vFanouts );
372  Vec_PtrSort( vFanouts, (int (*)(void))Abc_NodeCompareLevels );
373  // select the first Degree fanouts
374  if ( fUseInvs )
375  pBuffer = Abc_NtkCreateNodeInv( pObj->pNtk, NULL );
376  else
377  pBuffer = Abc_NtkCreateNodeBuf( pObj->pNtk, NULL );
378  // check if it is possible to not increase level
379  if ( Vec_PtrSize(vFanouts) < 2 * Degree )
380  {
381  Abc_Obj_t * pFanPrev = (Abc_Obj_t *)Vec_PtrEntry(vFanouts, Vec_PtrSize(vFanouts)-1-Degree);
382  Abc_Obj_t * pFanThis = (Abc_Obj_t *)Vec_PtrEntry(vFanouts, Degree-1);
383  Abc_Obj_t * pFanLast = (Abc_Obj_t *)Vec_PtrEntryLast(vFanouts);
384  if ( Abc_ObjLevel(pFanThis) == Abc_ObjLevel(pFanLast) &&
385  Abc_ObjLevel(pFanPrev) < Abc_ObjLevel(pFanThis) )
386  {
387  // find the first one whose level is the same as last
388  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
389  if ( Abc_ObjLevel(pFanout) == Abc_ObjLevel(pFanLast) )
390  break;
391  assert( i < Vec_PtrSize(vFanouts) );
392  if ( i > 1 )
393  Degree = i;
394  }
395  // make the last two more well-balanced
396  if ( Degree == Degree0 && Degree > Vec_PtrSize(vFanouts) - Degree )
397  Degree = Vec_PtrSize(vFanouts)/2 + (Vec_PtrSize(vFanouts) & 1);
398  assert( Degree <= Degree0 );
399  }
400  // select fanouts
401  Vec_PtrForEachEntryStop( Abc_Obj_t *, vFanouts, pFanout, i, Degree )
402  Abc_ObjPatchFanin( pFanout, pObj, pBuffer );
403  if ( fVerbose )
404  {
405  printf( "%5d : ", Abc_ObjId(pObj) );
406  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
407  printf( "%d%s ", Abc_ObjLevel(pFanout), i == Degree-1 ? " " : "" );
408  printf( "\n" );
409  }
410  Vec_PtrFree( vFanouts );
411  Abc_ObjAddFanin( pBuffer, pObj );
412  pBuffer->Level = Abc_SclComputeReverseLevel( pBuffer );
413  if ( fUseInvs )
414  Abc_NodeInvUpdateFanPolarity( pBuffer );
415  return pBuffer;
416 }
417 void Abc_SclPerformBuffering_rec( Abc_Obj_t * pObj, int DegreeR, int Degree, int fUseInvs, int fVerbose )
418 {
419  Vec_Ptr_t * vFanouts;
420  Abc_Obj_t * pBuffer;
421  Abc_Obj_t * pFanout;
422  int i, nOldFanNum;
423  if ( Abc_NodeIsTravIdCurrent( pObj ) )
424  return;
425  Abc_NodeSetTravIdCurrent( pObj );
426  pObj->Level = 0;
427  if ( Abc_ObjIsCo(pObj) )
428  return;
429  assert( Abc_ObjIsCi(pObj) || Abc_ObjIsNode(pObj) );
430  // buffer fanouts and collect reverse levels
431  Abc_ObjForEachFanout( pObj, pFanout, i )
432  Abc_SclPerformBuffering_rec( pFanout, DegreeR, Degree, fUseInvs, fVerbose );
433  // perform buffering as long as needed
434  nOldFanNum = Abc_ObjFanoutNum(pObj);
435  while ( Abc_ObjFanoutNum(pObj) > Degree )
436  Abc_SclPerformBufferingOne( pObj, Degree, fUseInvs, fVerbose );
437  // add yet another level of buffers
438  if ( DegreeR && nOldFanNum > DegreeR )
439  {
440  if ( fUseInvs )
441  pBuffer = Abc_NtkCreateNodeInv( pObj->pNtk, NULL );
442  else
443  pBuffer = Abc_NtkCreateNodeBuf( pObj->pNtk, NULL );
444  vFanouts = Vec_PtrAlloc( Abc_ObjFanoutNum(pObj) );
445  Abc_NodeCollectFanouts( pObj, vFanouts );
446  Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, i )
447  Abc_ObjPatchFanin( pFanout, pObj, pBuffer );
448  Vec_PtrFree( vFanouts );
449  Abc_ObjAddFanin( pBuffer, pObj );
450  pBuffer->Level = Abc_SclComputeReverseLevel( pBuffer );
451  if ( fUseInvs )
452  Abc_NodeInvUpdateFanPolarity( pBuffer );
453  }
454  // compute the new level of the node
455  pObj->Level = Abc_SclComputeReverseLevel( pObj );
456 }
457 Abc_Ntk_t * Abc_SclPerformBuffering( Abc_Ntk_t * p, int DegreeR, int Degree, int fUseInvs, int fVerbose )
458 {
459  Vec_Int_t * vCiLevs;
460  Abc_Ntk_t * pNew;
461  Abc_Obj_t * pObj;
462  int i;
464  if ( fUseInvs )
465  {
466  printf( "Warning!!! Using inverters instead of buffers.\n" );
467  if ( p->vPhases == NULL )
468  printf( "The phases are not given. The result will not verify.\n" );
469  }
470  // remember CI levels
471  vCiLevs = Vec_IntAlloc( Abc_NtkCiNum(p) );
472  Abc_NtkForEachCi( p, pObj, i )
473  Vec_IntPush( vCiLevs, Abc_ObjLevel(pObj) );
474  // perform buffering
476  Abc_NtkForEachCi( p, pObj, i )
477  Abc_SclPerformBuffering_rec( pObj, DegreeR, Degree, fUseInvs, fVerbose );
478  // recompute logic levels
479  Abc_NtkForEachCi( p, pObj, i )
480  pObj->Level = Vec_IntEntry( vCiLevs, i );
481  Abc_NtkForEachNode( p, pObj, i )
482  Abc_ObjLevelNew( pObj );
483  Vec_IntFree( vCiLevs );
484  // if phases are present
485  if ( p->vPhases )
487  // duplication in topo order
488  pNew = Abc_NtkDupDfs( p );
489  Abc_SclCheckNtk( pNew, fVerbose );
490 // Abc_NtkDelete( pNew );
491  return pNew;
492 }
493 
494 
495 
496 /**Function*************************************************************
497 
498  Synopsis []
499 
500  Description []
501 
502  SideEffects []
503 
504  SeeAlso []
505 
506 ***********************************************************************/
508 {
509  Abc_Obj_t * pFanin;
510  int i;
511  float DelayF, Delay = -ABC_INFINITY;
512  Abc_ObjForEachFanin( pObj, pFanin, i )
513  {
514  if ( Vec_IntEntry(p->vOffsets, Abc_ObjId(pObj)) == -ABC_INFINITY )
515  continue;
516  DelayF = Abc_BufNodeArr(p, pFanin) + Abc_BufEdgeDelay(p, pObj, i);
517  if ( Delay < DelayF )
518  Delay = DelayF;
519  }
520  Abc_BufSetNodeArr( p, pObj, Delay );
521  return Delay;
522 }
524 {
525  Abc_Obj_t * pFanout;
526  int i;
527  float DelayF, Delay = -ABC_INFINITY;
528  Abc_ObjForEachFanout( pObj, pFanout, i )
529  {
530  if ( Vec_IntEntry(p->vOffsets, Abc_ObjId(pFanout)) == -ABC_INFINITY )
531  continue;
532  DelayF = Abc_BufNodeDep(p, pFanout) + Abc_BufEdgeDelay(p, pFanout, Abc_NodeFindFanin(pFanout, pObj));
533  if ( Delay < DelayF )
534  Delay = DelayF;
535  }
536  Abc_BufSetNodeDep( p, pObj, Delay );
537  return Delay;
538 }
540 {
541  Abc_Obj_t * pObj;
542  int i;
543  p->DelayMax = 0;
544  Abc_NtkForEachCo( p->pNtk, pObj, i )
546 }
548 {
549  int k;
550  Mio_Gate_t * pGate = Abc_ObjIsCo(pObj) ? NULL : (Mio_Gate_t *)pObj->pData;
552  for ( k = 0; k < Abc_ObjFaninNum(pObj); k++ )
553  Vec_IntPush( p->vEdges, pGate ? (int)(1.0 * BUF_SCALE * Mio_GateReadPinDelay(pGate, k) / p->DelayInv) : 0 );
554 }
556 {
557  if ( Abc_ObjFanoutNum(pObj) < p->nFanMin || (!p->fBufPis && Abc_ObjIsCi(pObj)) )
558  return;
560  if ( Vec_QueIsMember(p->vQue, Abc_ObjId(pObj)) )
561  Vec_QueUpdate( p->vQue, Abc_ObjId(pObj) );
562  else
563  Vec_QuePush( p->vQue, Abc_ObjId(pObj) );
564 }
565 
566 
567 /**Function*************************************************************
568 
569  Synopsis []
570 
571  Description []
572 
573  SideEffects []
574 
575  SeeAlso []
576 
577 ***********************************************************************/
579 {
580  Abc_Obj_t * pNext;
581  int i;
582  if ( Abc_NodeIsTravIdCurrent( pNode ) )
583  return;
584  Abc_NodeSetTravIdCurrent( pNode );
585  if ( Abc_ObjIsCo(pNode) )
586  return;
587  assert( Abc_ObjIsCi(pNode) || Abc_ObjIsNode(pNode) );
588  Abc_ObjForEachFanout( pNode, pNext, i )
589  Abc_BufCollectTfoCone_rec( pNext, vNodes );
590  if ( Abc_ObjIsNode(pNode) )
591  Vec_IntPush( vNodes, Abc_ObjId(pNode) );
592 }
594 {
595  Vec_IntClear( p->vTfCone );
598 }
600 {
601  Abc_Obj_t * pNext;
602  int i, Delay;
603 // assert( Abc_ObjIsNode(pObj) );
604  Abc_BufCollectTfoCone( p, pObj );
606  Abc_NtkForEachObjVec( p->vTfCone, p->pNtk, pNext, i )
607  {
608  Delay = Abc_BufComputeArr( p, pNext );
609  p->DelayMax = Abc_MaxInt( p->DelayMax, Delay );
610  }
611 }
612 
613 /**Function*************************************************************
614 
615  Synopsis []
616 
617  Description []
618 
619  SideEffects []
620 
621  SeeAlso []
622 
623 ***********************************************************************/
625 {
626  Abc_Obj_t * pNext;
627  int i;
628  if ( Abc_NodeIsTravIdCurrent( pNode ) )
629  return;
630  Abc_NodeSetTravIdCurrent( pNode );
631  if ( Abc_ObjIsCi(pNode) )
632  return;
633  assert( Abc_ObjIsNode(pNode) );
634  Abc_ObjForEachFanin( pNode, pNext, i )
635  Abc_BufCollectTfiCone_rec( pNext, vNodes );
636  Vec_IntPush( vNodes, Abc_ObjId(pNode) );
637 }
639 {
640  Vec_IntClear( p->vTfCone );
643 }
645 {
646  Abc_Obj_t * pNext;
647  int i, Delay;
648 // assert( Abc_ObjIsNode(pObj) );
649  Abc_BufCollectTfiCone( p, pObj );
651  Abc_NtkForEachObjVec( p->vTfCone, p->pNtk, pNext, i )
652  {
653  Delay = Abc_BufComputeDep( p, pNext );
654  p->DelayMax = Abc_MaxInt( p->DelayMax, Delay );
655  }
656 }
657 
658 /**Function*************************************************************
659 
660  Synopsis []
661 
662  Description []
663 
664  SideEffects []
665 
666  SeeAlso []
667 
668 ***********************************************************************/
669 Buf_Man_t * Buf_ManStart( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis )
670 {
671  Buf_Man_t * p;
672  Abc_Obj_t * pObj;
673  Vec_Ptr_t * vNodes;
674  int i;
675  p = ABC_CALLOC( Buf_Man_t, 1 );
676  p->pNtk = pNtk;
677  p->nFanMin = FanMin;
678  p->nFanMax = FanMax;
679  p->fBufPis = fBufPis;
680  // allocate arrays
682  p->nObjAlloc = (6 * Abc_NtkObjNumMax(p->pNtk) / 3) + 100;
683  p->vOffsets = Vec_IntAlloc( p->nObjAlloc );
684  p->vArr = Vec_IntAlloc( p->nObjAlloc );
685  p->vDep = Vec_IntAlloc( p->nObjAlloc );
686  p->vCounts = Vec_FltAlloc( p->nObjAlloc );
687  p->vQue = Vec_QueAlloc( p->nObjAlloc );
689  Vec_IntFill( p->vArr, p->nObjAlloc, 0 );
690  Vec_IntFill( p->vDep, p->nObjAlloc, 0 );
693  // collect edge delays
695  p->vEdges = Vec_IntAlloc( 1000 );
696  // create edges
697  vNodes = Abc_NtkDfs( p->pNtk, 0 );
698  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
699  Abc_BufCreateEdges( p, pObj );
700  Abc_NtkForEachCo( p->pNtk, pObj, i )
701  Abc_BufCreateEdges( p, pObj );
702  // derive delays
703  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
704  Abc_BufComputeArr( p, pObj );
705  Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pObj, i )
706  Abc_BufComputeDep( p, pObj );
707  Abc_BufUpdateGlobal( p );
708 // Abc_NtkForEachNode( p->pNtk, pObj, i )
709 // printf( "%4d : %4d %4d\n", i, Abc_BufNodeArr(p, pObj), Abc_BufNodeDep(p, pObj) );
710  // create fanout queue
711 // Abc_NtkForEachCi( p->pNtk, pObj, i )
712 // Abc_BufAddToQue( p, pObj );
713  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
714  Abc_BufAddToQue( p, pObj );
715  Vec_PtrFree( vNodes );
716  p->vDelays = Vec_IntAlloc( 100 );
717  p->vOrder = Vec_IntAlloc( 100 );
718  p->vNonCrit = Vec_IntAlloc( 100 );
719  p->vTfCone = Vec_IntAlloc( 100 );
720  p->vFanouts = Vec_PtrAlloc( 100 );
721  return p;
722 }
724 {
725  printf( "Sep = %d. Dup = %d. Br0 = %d. Br1 = %d. BrC = %d. ",
726  p->nSeparate, p->nDuplicate, p->nBranch0, p->nBranch1, p->nBranchCrit );
727  printf( "Orig = %d. Add = %d. Rem = %d.\n",
729  p->nObjAlloc - Abc_NtkObjNumMax(p->pNtk) );
730  Vec_PtrFree( p->vFanouts );
731  Vec_IntFree( p->vTfCone );
732  Vec_IntFree( p->vNonCrit );
733  Vec_IntFree( p->vDelays );
734  Vec_IntFree( p->vOrder );
735  Vec_IntFree( p->vOffsets );
736  Vec_IntFree( p->vEdges );
737  Vec_IntFree( p->vArr );
738  Vec_IntFree( p->vDep );
739 // Vec_QueCheck( p->vQue );
740  Vec_QueFree( p->vQue );
741  Vec_FltFree( p->vCounts );
742  ABC_FREE( p );
743 }
744 
745 /**Function*************************************************************
746 
747  Synopsis []
748 
749  Description []
750 
751  SideEffects []
752 
753  SeeAlso []
754 
755 ***********************************************************************/
757 {
758  Abc_Obj_t * pObj, * pFanout;
759  int i, Slack, * pOrder;
760  Vec_IntClear( p->vDelays );
761  pObj = Abc_NtkObj( p->pNtk, iPivot );
762  Abc_ObjForEachFanout( pObj, pFanout, i )
763  {
764  Slack = Abc_BufEdgeSlack(p, pObj, pFanout);
765  assert( Slack >= 0 );
766  Vec_IntPush( p->vDelays, Abc_MaxInt(0, Slack) );
767  }
768  pOrder = Abc_QuickSortCost( Vec_IntArray(p->vDelays), Vec_IntSize(p->vDelays), 0 );
769  Vec_IntClear( p->vOrder );
770  for ( i = 0; i < Vec_IntSize(p->vDelays); i++ )
771  Vec_IntPush( p->vOrder, Abc_ObjId(Abc_ObjFanout(pObj, pOrder[i])) );
772  ABC_FREE( pOrder );
773 // for ( i = 0; i < Vec_IntSize(p->vDelays); i++ )
774 // printf( "%5d - %5d ", Vec_IntEntry(p->vOrder, i), Abc_BufEdgeSlack(p, pObj, Abc_NtkObj(p->pNtk, Vec_IntEntry(p->vOrder, i))) );
775  return p->vOrder;
776 }
777 void Abc_BufPrintOne( Buf_Man_t * p, int iPivot )
778 {
779  Abc_Obj_t * pObj, * pFanout;
780  Vec_Int_t * vOrder;
781  int i, Slack;
782  pObj = Abc_NtkObj( p->pNtk, iPivot );
783  vOrder = Abc_BufSortByDelay( p, iPivot );
784  printf( "Node %5d Fi = %d Fo = %3d Lev = %3d : {", iPivot, Abc_ObjFaninNum(pObj), Abc_ObjFanoutNum(pObj), Abc_ObjLevel(pObj) );
785  Abc_NtkForEachObjVec( vOrder, p->pNtk, pFanout, i )
786  {
787  Slack = Abc_BufEdgeSlack( p, pObj, pFanout );
788  printf( " %d(%d)", Abc_ObjId(pFanout), Slack );
789  }
790  printf( " }\n" );
791 }
792 
793 /**Function*************************************************************
794 
795  Synopsis []
796 
797  Description []
798 
799  SideEffects []
800 
801  SeeAlso []
802 
803 ***********************************************************************/
805 {
806  Abc_Obj_t * pObj, * pInv;
807  int i, Counter = 0;
808  Abc_NtkForEachNode( pNtk, pObj, i )
809  {
810  if ( !Abc_NodeIsBuf(pObj) )
811  continue;
812  assert( pObj->pData == Mio_LibraryReadBuf((Mio_Library_t *)pNtk->pManFunc) );
814  pInv = Abc_NtkCreateNodeInv( pNtk, Abc_ObjFanin0(pObj) );
815  Abc_ObjPatchFanin( pObj, Abc_ObjFanin0(pObj), pInv );
816  Counter++;
817  }
818  printf( "Replaced %d buffers by invertor pairs.\n", Counter );
819 }
820 
821 /**Function*************************************************************
822 
823  Synopsis []
824 
825  Description []
826 
827  SideEffects []
828 
829  SeeAlso []
830 
831 ***********************************************************************/
832 int Abc_BufComputeAverage( Buf_Man_t * p, int iPivot, Vec_Int_t * vOrder )
833 {
834  Abc_Obj_t * pObj, * pFanout;
835  int i, Average = 0;
836  pObj = Abc_NtkObj( p->pNtk, iPivot );
837  Abc_NtkForEachObjVec( vOrder, p->pNtk, pFanout, i )
838  Average += Abc_BufEdgeSlack( p, pObj, pFanout );
839  return Average / Vec_IntSize(vOrder);
840 }
842 {
843  return (Abc_ObjIsNode(pObj) && Abc_NodeIsBuf(pObj)) ? Abc_BufFindNonBuffDriver(p, Abc_ObjFanin0(pObj)) : pObj;
844 }
845 
846 /**Function*************************************************************
847 
848  Synopsis []
849 
850  Description []
851 
852  SideEffects []
853 
854  SeeAlso []
855 
856 ***********************************************************************/
858 {
859  Abc_Obj_t * pFanout;
860  int i;
861  Vec_IntClear( p->vNonCrit );
862  Abc_ObjForEachFanout( pObj, pFanout, i )
863  if ( Abc_BufEdgeSlack( p, pObj, pFanout ) > 7*BUF_SCALE/2 )
864  Vec_IntPush( p->vNonCrit, Abc_ObjId(pFanout) );
865  return Vec_IntSize(p->vNonCrit);
866 }
867 void Abc_BufPerformOne( Buf_Man_t * p, int iPivot, int fSkipDup, int fVerbose )
868 {
869  Abc_Obj_t * pObj, * pFanout;
870  int i, j, nCrit, nNonCrit;
871 // int DelayMax = p->DelayMax;
872  assert( Abc_NtkObjNumMax(p->pNtk) + 30 < p->nObjAlloc );
873  pObj = Abc_NtkObj( p->pNtk, iPivot );
874 // assert( Vec_FltEntry(p->vCounts, iPivot) == (float)Abc_ObjFanoutNum(pObj) );
875  nNonCrit = Abc_BufCountNonCritical( p, pObj );
876  nCrit = Abc_ObjFanoutNum(pObj) - nNonCrit;
877 if ( fVerbose )
878 {
879 //Abc_BufPrintOne( p, iPivot );
880 printf( "ObjId = %6d : %-10s FI = %d. FO =%4d. Crit =%4d. ",
881  Abc_ObjId(pObj), Mio_GateReadName((Mio_Gate_t *)pObj->pData), Abc_ObjFaninNum(pObj), Abc_ObjFanoutNum(pObj), nCrit );
882 }
883  // consider three cases
884  if ( nCrit > 0 && nNonCrit > 1 )
885  {
886  // (1) both critical and non-critical are present - split them by adding buffer
887  Abc_Obj_t * pBuffer = Abc_NtkCreateNodeBuf( p->pNtk, pObj );
888  Abc_NtkForEachObjVec( p->vNonCrit, p->pNtk, pFanout, i )
889  Abc_ObjPatchFanin( pFanout, pObj, pBuffer );
890  // update timing
891  Abc_BufCreateEdges( p, pBuffer );
892  Abc_BufUpdateArr( p, pBuffer );
893  Abc_BufUpdateDep( p, pBuffer );
894  Abc_BufAddToQue( p, pObj );
895  Abc_BufAddToQue( p, pBuffer );
896  Abc_SclTimeIncUpdateLevel( pBuffer );
897  p->nSeparate++;
898 if ( fVerbose )
899 printf( "Adding buffer\n" );
900  }
901  else if ( !fSkipDup && nCrit > 0 && Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) > p->nFanMin )//&& Abc_ObjLevel(pObj) < 4 )//&& Abc_ObjFaninNum(pObj) < 2 )
902  {
903  // (2) only critical are present - duplicate
904  Abc_Obj_t * pClone = Abc_NtkDupObj( p->pNtk, pObj, 0 );
905  Abc_ObjForEachFanin( pObj, pFanout, i )
906  Abc_ObjAddFanin( pClone, pFanout );
907  Abc_NodeCollectFanouts( pObj, p->vFanouts );
909  Abc_ObjPatchFanin( pFanout, pObj, pClone );
910  // update timing
911  Abc_BufCreateEdges( p, pClone );
912  Abc_BufSetNodeArr( p, pClone, Abc_BufNodeArr(p, pObj) );
913  Abc_BufUpdateDep( p, pObj );
914  Abc_BufUpdateDep( p, pClone );
915  Abc_BufAddToQue( p, pObj );
916  Abc_BufAddToQue( p, pClone );
917  Abc_ObjForEachFanin( pObj, pFanout, i )
918  Abc_BufAddToQue( p, pFanout );
919  Abc_SclTimeIncUpdateLevel( pClone );
920  p->nDuplicate++;
921 // printf( "Duplicating %s on level %d\n", Mio_GateReadName((Mio_Gate_t *)pObj->pData), Abc_ObjLevel(pObj) );
922 if ( fVerbose )
923 printf( "Duplicating node\n" );
924  }
925  else if ( (nCrit > 0 && Abc_ObjFanoutNum(pObj) > 8) || Abc_ObjFanoutNum(pObj) > p->nFanMax )
926  {
927  // (2) only critical or only non-critical - add buffer/inverter tree
928  int nDegree, n1Degree, n1Number, nFirst;
929  int iFirstBuf = Abc_NtkObjNumMax( p->pNtk );
930 // nDegree = Abc_MinInt( 3, (int)pow(Abc_ObjFanoutNum(pObj), 0.34) );
931  nDegree = Abc_MinInt( 10, (int)pow(Abc_ObjFanoutNum(pObj), 0.5) );
932  n1Degree = Abc_ObjFanoutNum(pObj) / nDegree + 1;
933  n1Number = Abc_ObjFanoutNum(pObj) % nDegree;
934  nFirst = n1Degree * n1Number;
935  p->nBranchCrit += (nCrit > 0);
936  // create inverters
937  Abc_NodeCollectFanouts( pObj, p->vFanouts );
938  if ( Abc_ObjIsNode(pObj) && Abc_NodeIsBuf(pObj) )
939  {
940  p->nBranch0++;
942  Abc_BufSetEdgeDelay( p, pObj, 0, BUF_SCALE );
943  assert( Abc_NodeIsInv(pObj) );
944  for ( i = 0; i < nDegree; i++ )
945  Abc_NtkCreateNodeInv( p->pNtk, pObj );
946 if ( fVerbose )
947 printf( "Adding %d inverters\n", nDegree );
948  }
949  else
950  {
951  p->nBranch1++;
952  for ( i = 0; i < nDegree; i++ )
953  Abc_NtkCreateNodeBuf( p->pNtk, pObj );
954 if ( fVerbose )
955 printf( "Adding %d buffers\n", nDegree );
956  }
957  // connect inverters
958  Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanouts, pFanout, i )
959  {
960  j = (i < nFirst) ? i/n1Degree : n1Number + ((i - nFirst)/(n1Degree - 1));
961  assert( j >= 0 && j < nDegree );
962  Abc_ObjPatchFanin( pFanout, pObj, Abc_NtkObj(p->pNtk, iFirstBuf + j) );
963  }
964  // update timing
965  for ( i = 0; i < nDegree; i++ )
966  Abc_BufCreateEdges( p, Abc_NtkObj(p->pNtk, iFirstBuf + i) );
967  Abc_BufUpdateArr( p, pObj );
968  for ( i = 0; i < nDegree; i++ )
969  Abc_BufComputeDep( p, Abc_NtkObj(p->pNtk, iFirstBuf + i) );
970  Abc_BufUpdateDep( p, pObj );
971  for ( i = 0; i < nDegree; i++ )
972  Abc_BufAddToQue( p, Abc_NtkObj(p->pNtk, iFirstBuf + i) );
973  for ( i = 0; i < nDegree; i++ )
974  Abc_SclTimeIncUpdateLevel( Abc_NtkObj(p->pNtk, iFirstBuf + i) );
975  }
976  else
977  {
978 if ( fVerbose )
979 printf( "Doing nothing\n" );
980  }
981 // if ( DelayMax != p->DelayMax )
982 // printf( "%d (%.2f) ", p->DelayMax, 1.0 * p->DelayMax * p->DelayInv / BUF_SCALE );
983 }
984 Abc_Ntk_t * Abc_SclBufPerform( Abc_Ntk_t * pNtk, int FanMin, int FanMax, int fBufPis, int fSkipDup, int fVerbose )
985 {
986  Abc_Ntk_t * pNew;
987  Buf_Man_t * p = Buf_ManStart( pNtk, FanMin, FanMax, fBufPis );
988  int i, Limit = ABC_INFINITY;
989  Abc_NtkLevel( pNtk );
990 // if ( Abc_NtkNodeNum(pNtk) < 1000 )
991 // fSkipDup = 1;
992  for ( i = 0; i < Limit && Vec_QueSize(p->vQue); i++ )
993  Abc_BufPerformOne( p, Vec_QuePop(p->vQue), fSkipDup, fVerbose );
994  Buf_ManStop( p );
995 // Abc_BufReplaceBufsByInvs( pNtk );
996  // duplicate network in topo order
997  pNew = Abc_NtkDupDfs( pNtk );
998  Abc_SclCheckNtk( pNew, fVerbose );
999  return pNew;
1000 }
1001 
1002 ////////////////////////////////////////////////////////////////////////
1003 /// END OF FILE ///
1004 ////////////////////////////////////////////////////////////////////////
1005 
1006 
1008 
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition: mioApi.c:47
Buf_Man_t * Buf_ManStart(Abc_Ntk_t *pNtk, int FanMin, int FanMax, int fBufPis)
Definition: sclBuffer.c:669
static void Abc_BufSetEdgeDelay(Buf_Man_t *p, Abc_Obj_t *pObj, int i, int f)
Definition: sclBuffer.c:71
float Abc_BufComputeDep(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:523
void Abc_SclPerformBuffering_rec(Abc_Obj_t *pObj, int DegreeR, int Degree, int fUseInvs, int fVerbose)
Definition: sclBuffer.c:417
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
int * Abc_QuickSortCost(int *pCosts, int nSize, int fDecrease)
Definition: utilSort.c:719
Vec_Int_t * vDelays
Definition: sclBuffer.c:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Int_t * vOffsets
Definition: sclBuffer.c:42
int Abc_SclIsInv(Abc_Obj_t *pObj)
Definition: sclBuffer.c:116
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Abc_BufPerformOne(Buf_Man_t *p, int iPivot, int fSkipDup, int fVerbose)
Definition: sclBuffer.c:867
int nFanMin
Definition: sclBuffer.c:37
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
int DelayMax
Definition: sclBuffer.c:50
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float Mio_GateReadPinDelay(Mio_Gate_t *pGate, int iPin)
Definition: mioApi.c:201
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Abc_SclCheckNtk(Abc_Ntk_t *p, int fVerbose)
Definition: sclBuffer.c:286
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition: vecPtr.h:63
static int Abc_BufEdgeSlack(Buf_Man_t *p, Abc_Obj_t *pObj, Abc_Obj_t *pFan)
Definition: sclBuffer.c:73
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
void Abc_BufCollectTfoCone_rec(Abc_Obj_t *pNode, Vec_Int_t *vNodes)
Definition: sclBuffer.c:578
int nDuplicate
Definition: sclBuffer.c:60
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
Definition: abcUtil.c:758
static void Vec_FltFree(Vec_Flt_t *p)
Definition: vecFlt.h:218
int nObjStart
Definition: sclBuffer.c:48
Vec_Int_t * vDep
Definition: sclBuffer.c:45
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Abc_Ntk_t * Abc_SclUnBufferPhase(Abc_Ntk_t *pNtk, int fVerbose)
Definition: sclBuffer.c:239
void Abc_BufUpdateGlobal(Buf_Man_t *p)
Definition: sclBuffer.c:539
int Abc_NodeCompareLevels(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition: sclBuffer.c:341
static void Abc_BufSetNodeDep(Buf_Man_t *p, Abc_Obj_t *pObj, int f)
Definition: sclBuffer.c:69
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
int nFanMax
Definition: sclBuffer.c:38
static int Abc_NtkHasMapping(Abc_Ntk_t *pNtk)
Definition: abc.h:256
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
typedefABC_NAMESPACE_HEADER_START struct Vec_Que_t_ Vec_Que_t
INCLUDES ///.
Definition: vecQue.h:40
int Abc_SclComputeReverseLevel(Abc_Obj_t *pObj)
Definition: sclBuffer.c:355
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecFlt.h:78
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
Vec_Int_t * vOrder
Definition: sclBuffer.c:53
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_BufNodeSlack(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:72
word Mio_GateReadTruth(Mio_Gate_t *pGate)
Definition: mioApi.c:154
static int Vec_QuePop(Vec_Que_t *p)
Definition: vecQue.h:234
int nBranchCrit
Definition: sclBuffer.c:63
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
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_BufCollectTfiCone_rec(Abc_Obj_t *pNode, Vec_Int_t *vNodes)
Definition: sclBuffer.c:624
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
float Abc_BufComputeArr(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:507
void Abc_SclTimeIncUpdateLevel(Abc_Obj_t *pObj)
Definition: sclSize.c:576
static void Vec_FltFill(Vec_Flt_t *p, int nSize, float Entry)
Definition: vecFlt.h:450
static Vec_Int_t * Vec_IntStartFull(int nSize)
Definition: vecInt.h:119
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
Abc_Obj_t * Abc_BufFindNonBuffDriver(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:841
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
Definition: abc.h:367
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
void Abc_BufCollectTfoCone(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:593
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL int Abc_NodeIsBuf(Abc_Obj_t *pNode)
Definition: abcObj.c:920
void Abc_SclReportDupFanins(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: sclBuffer.c:90
int nBranch1
Definition: sclBuffer.c:62
void Abc_BufUpdateArr(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:599
static int Abc_BufNodeDep(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:67
Vec_Ptr_t * vFanouts
Definition: sclBuffer.c:57
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
int nBranch0
Definition: sclBuffer.c:61
static int Vec_QueSize(Vec_Que_t *p)
Definition: vecQue.h:134
int Abc_SclCountMaxPhases(Abc_Ntk_t *pNtk)
Definition: sclBuffer.c:181
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static int Abc_MinInt(int a, int b)
Definition: abc_global.h:239
Abc_Ntk_t * Abc_SclBufferPhase(Abc_Ntk_t *pNtk, int fVerbose)
Definition: sclBuffer.c:198
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
void Abc_BufAddToQue(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:555
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:662
Abc_Ntk_t * Abc_SclUnBufferPerform(Abc_Ntk_t *pNtk, int fVerbose)
Definition: sclBuffer.c:129
static int Abc_ObjLevel(Abc_Obj_t *pObj)
Definition: abc.h:330
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
Definition: abc.h:452
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
void Abc_BufPrintOne(Buf_Man_t *p, int iPivot)
Definition: sclBuffer.c:777
Vec_Int_t * vNonCrit
Definition: sclBuffer.c:55
Vec_Int_t * vPhases
Definition: abc.h:208
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
void Buf_ManStop(Buf_Man_t *p)
Definition: sclBuffer.c:723
int Abc_BufComputeAverage(Buf_Man_t *p, int iPivot, Vec_Int_t *vOrder)
Definition: sclBuffer.c:832
int nSeparate
Definition: sclBuffer.c:59
Vec_Que_t * vQue
Definition: sclBuffer.c:47
ABC_DLL Abc_Ntk_t * Abc_NtkDupDfs(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:476
static int Abc_BufNodeArr(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:66
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
Vec_Int_t * vTfCone
Definition: sclBuffer.c:56
#define BUF_SCALE
DECLARATIONS ///.
Definition: sclBuffer.c:31
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int fBufPis
Definition: sclBuffer.c:39
Abc_Ntk_t * Abc_SclBufPerform(Abc_Ntk_t *pNtk, int FanMin, int FanMax, int fBufPis, int fSkipDup, int fVerbose)
Definition: sclBuffer.c:984
int Abc_BufCountNonCritical(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:857
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
ABC_DLL int Abc_NodeIsInv(Abc_Obj_t *pNode)
Definition: abcObj.c:950
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static float ** Vec_FltArrayP(Vec_Flt_t *p)
Definition: vecFlt.h:278
void Abc_BufCollectTfiCone(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:638
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Abc_BufReplaceBufsByInvs(Abc_Ntk_t *pNtk)
Definition: sclBuffer.c:804
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
Abc_Obj_t * Abc_SclPerformBufferingOne(Abc_Obj_t *pObj, int Degree, int fUseInvs, int fVerbose)
Definition: sclBuffer.c:363
static void Vec_QueUpdate(Vec_Que_t *p, int v)
Definition: vecQue.h:199
static void Abc_BufSetNodeArr(Buf_Man_t *p, Abc_Obj_t *pObj, int f)
Definition: sclBuffer.c:68
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
static int Vec_QueIsMember(Vec_Que_t *p, int v)
Definition: vecQue.h:216
static int Abc_SclObjIsBufInv(Abc_Obj_t *pObj)
Definition: sclBuffer.c:112
static void Vec_QueFree(Vec_Que_t *p)
Definition: vecQue.h:83
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define Abc_NtkForEachNodeCo(pNtk, pNode, i)
Definition: abc.h:491
void Abc_BufUpdateDep(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:644
#define assert(ex)
Definition: util_old.h:213
static int Abc_ObjFaninPhase(Abc_Obj_t *p, int i)
Definition: abc.h:392
Abc_Ntk_t * pNtk
Definition: sclBuffer.c:41
void * pData
Definition: abc.h:145
static void Abc_ObjFaninFlipPhase(Abc_Obj_t *p, int i)
Definition: abc.h:393
Vec_Int_t * Abc_BufSortByDelay(Buf_Man_t *p, int iPivot)
Definition: sclBuffer.c:756
static Abc_Obj_t * Abc_ObjFanout(Abc_Obj_t *pObj, int i)
Definition: abc.h:370
Vec_Flt_t * vCounts
Definition: sclBuffer.c:46
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcUtil.c:1607
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
Abc_Ntk_t * Abc_SclPerformBuffering(Abc_Ntk_t *p, int DegreeR, int Degree, int fUseInvs, int fVerbose)
Definition: sclBuffer.c:457
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Abc_BufCreateEdges(Buf_Man_t *p, Abc_Obj_t *pObj)
Definition: sclBuffer.c:547
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
static Vec_Que_t * Vec_QueAlloc(int nCap)
MACRO DEFINITIONS ///.
Definition: vecQue.h:71
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
Vec_Int_t * vArr
Definition: sclBuffer.c:44
Vec_Int_t * vEdges
Definition: sclBuffer.c:43
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition: mioApi.c:48
static void Vec_QuePush(Vec_Que_t *p, int v)
Definition: vecQue.h:221
void Abc_NodeInvUpdateFanPolarity(Abc_Obj_t *pObj)
Definition: sclBuffer.c:320
float DelayInv
Definition: sclBuffer.c:51
int Abc_SclGetRealFaninLit(Abc_Obj_t *pObj)
Definition: sclBuffer.c:121
ABC_DLL int Abc_ObjLevelNew(Abc_Obj_t *pObj)
Definition: abcTiming.c:1058
static void Vec_QueSetPriority(Vec_Que_t *p, float **pCosts)
Definition: vecQue.h:95
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
int nObjAlloc
Definition: sclBuffer.c:49
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Abc_BufEdgeDelay(Buf_Man_t *p, Abc_Obj_t *pObj, int i)
Definition: sclBuffer.c:70