abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclLib.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [sclLib.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Standard-cell library representation.]
8 
9  Synopsis [Simplified library representation for STA.]
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: sclLib.h,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__map__scl__sclLib_h
22 #define ABC__map__scl__sclLib_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 #include <math.h>
34 #include "misc/vec/vec.h"
35 
37 
38 
39 ////////////////////////////////////////////////////////////////////////
40 /// PARAMETERS ///
41 ////////////////////////////////////////////////////////////////////////
42 
43 #define ABC_SCL_CUR_VERSION 8
44 
45 typedef enum
46 {
52 } SC_Dir;
53 
54 typedef enum // -- timing sense, positive-, negative- or non-unate
55 {
60 } SC_TSense;
61 
62 typedef struct SC_Pair_ SC_Pair;
63 struct SC_Pair_
64 {
65  float rise;
66  float fall;
67 };
68 
69 typedef struct SC_SizePars_ SC_SizePars;
71 {
72  int nIters;
74  int Window; // used for upsizing
75  int Ratio; // used for upsizing
76  int Notches;
77  int DelayUser;
78  int DelayGap;
79  int TimeOut;
80  int BuffTreeEst; // ratio for buffer tree estimation
81  int BypassFreq; // frequency to try bypassing
82  int fUseDept;
85  int fVerbose;
87 };
88 
89 typedef struct SC_BusPars_ SC_BusPars;
91 {
92  int GainRatio; // target gain
93  int Slew; // target slew
94  int nDegree; // max branching factor
95  int fSizeOnly; // perform only sizing
96  int fAddBufs; // add buffers
97  int fBufPis; // use CI buffering
98  int fUseWireLoads; // wire loads
99  int fVerbose; // verbose
100  int fVeryVerbose; // verbose
101 };
102 
103 ////////////////////////////////////////////////////////////////////////
104 /// STRUCTURE DEFINITIONS ///
105 ////////////////////////////////////////////////////////////////////////
106 
107 typedef struct SC_WireLoad_ SC_WireLoad;
110 typedef struct SC_Surface_ SC_Surface;
111 typedef struct SC_Timing_ SC_Timing;
112 typedef struct SC_Timings_ SC_Timings;
113 typedef struct SC_Pin_ SC_Pin;
114 typedef struct SC_Cell_ SC_Cell;
115 typedef struct SC_Lib_ SC_Lib;
116 
118 {
119  char * pName;
120  float cap; // }- multiply estimation in 'fanout_len[].snd' with this value
121  float slope; // used to extrapolate wireload for large fanout count
122  Vec_Int_t * vFanout; // Vec<Pair<uint,float> > -- pairs '(#fanouts, est-wire-len)'
124 };
125 
127 {
128  char * pName;
129  Vec_Flt_t * vAreaFrom; // Vec<Trip<float,float,Str> > -- triplets '(from-area, upto-area, wire-load-model)'; range is [from, upto[
132 };
133 
135 {
136  char * pName;
137  Vec_Ptr_t * vVars; // Vec<Str> -- name of variable (numbered from 0, not 1 as in the Liberty file)
138  Vec_Ptr_t * vIndex; // Vec<Vec<float> > -- this is the point of measurement in table for the given variable
139 };
140 
141 struct SC_Surface_
142 {
143  char * pName;
144  Vec_Flt_t * vIndex0; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
145  Vec_Flt_t * vIndex1; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
146  Vec_Ptr_t * vData; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
147  float approx[3][6];
148 };
149 
150 struct SC_Timing_
151 {
152  char * related_pin; // -- related pin
153  SC_TSense tsense; // -- timing sense (positive_unate, negative_unate, non_unate)
154  char * when_text; // -- logic condition on inputs triggering this delay model for the output (currently not used)
155  SC_Surface * pCellRise; // -- Used to compute pin-to-pin delay
157  SC_Surface * pRiseTrans; // -- Used to compute output slew
159 };
160 
161 struct SC_Timings_
162 {
163  char * pName; // -- the 'related_pin' field
164  Vec_Ptr_t * vTimings; // structures of type SC_Timing
165 };
166 
167 struct SC_Pin_
168 {
169  char * pName;
171  float cap; // -- this value is used if 'rise_cap' and 'fall_cap' is missing (copied by 'postProcess()'). (not used)
172  float rise_cap; // }- used for input pins ('cap' too).
173  float fall_cap; // }
174  float max_out_cap; // } (not used)
175  float max_out_slew; // }- used only for output pins (max values must not be exceeded or else mapping is illegal) (not used)
176  char * func_text; // }
177  Vec_Wrd_t * vFunc; // }
178  Vec_Ptr_t * vRTimings; // -- for output pins
179 };
180 
181 struct SC_Cell_
182 {
183  char * pName;
184  int Id;
185  int fSkip; // skip this cell during genlib computation
186  int seq; // -- set to TRUE by parser if a sequential element
187  int unsupp; // -- set to TRUE by parser if cell contains information we cannot handle
188  float area;
189  float leakage;
190  int drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)
191  Vec_Ptr_t * vPins; // NamedSet<SC_Pin>
192  int n_inputs; // -- 'pins[0 .. n_inputs-1]' are input pins
193  int n_outputs; // -- 'pins[n_inputs .. n_inputs+n_outputs-1]' are output pins
194  SC_Cell * pNext; // same-functionality cells linked into a ring by area
195  SC_Cell * pPrev; // same-functionality cells linked into a ring by area
196  SC_Cell * pRepr; // representative of the class
197  SC_Cell * pAve; // average size cell of this class
198  int Order; // order of the gate in the list
199  int nGates; // the number of gates in the list
200 };
201 
202 struct SC_Lib_
203 {
204  char * pName;
205  char * pFileName;
208  float default_max_out_slew; // -- 'default_max_transition'; this is copied to each output pin where 'max_transition' is not defined (not used)
209  int unit_time; // -- Valid 9..12. Unit is '10^(-val)' seconds (e.g. 9=1ns, 10=100ps, 11=10ps, 12=1ps)
210  float unit_cap_fst; // -- First part is a multiplier, second either 12 or 15 for 'pf' or 'ff'.
212  Vec_Ptr_t * vWireLoads; // NamedSet<SC_WireLoad>
213  Vec_Ptr_t * vWireLoadSels; // NamedSet<SC_WireLoadSel>
214  Vec_Ptr_t * vTempls; // NamedSet<SC_TableTempl>
215  Vec_Ptr_t * vCells; // NamedSet<SC_Cell>
216  Vec_Ptr_t * vCellClasses; // NamedSet<SC_Cell>
217  int * pBins; // hashing gateName -> gateId
218  int nBins;
219 };
220 
221 ////////////////////////////////////////////////////////////////////////
222 /// GLOBAL VARIABLES ///
223 ////////////////////////////////////////////////////////////////////////
224 
225 ////////////////////////////////////////////////////////////////////////
226 /// MACRO DEFINITIONS ///
227 ////////////////////////////////////////////////////////////////////////
228 
229 static inline void SC_PairClean( SC_Pair * d ) { d->rise = d->fall = 0; }
230 static inline float SC_PairMax( SC_Pair * d ) { return Abc_MaxFloat(d->rise, d->fall); }
231 static inline float SC_PairMin( SC_Pair * d ) { return Abc_MinFloat(d->rise, d->fall); }
232 static inline float SC_PairAve( SC_Pair * d ) { return 0.5 * d->rise + 0.5 * d->fall; }
233 static inline void SC_PairDup( SC_Pair * d, SC_Pair * s ) { *d = *s; }
234 static inline void SC_PairMove( SC_Pair * d, SC_Pair * s ) { *d = *s; s->rise = s->fall = 0; }
235 static inline void SC_PairAdd( SC_Pair * d, SC_Pair * s ) { d->rise += s->rise; d->fall += s->fall;}
236 static inline int SC_PairEqual( SC_Pair * d, SC_Pair * s ) { return d->rise == s->rise && d->fall == s->fall; }
237 static inline int SC_PairEqualE( SC_Pair * d, SC_Pair * s, float E ) { return d->rise - s->rise < E && s->rise - d->rise < E && d->fall - s->fall < E && s->fall - d->fall < E; }
238 
239 static inline int SC_LibCellNum( SC_Lib * p ) { return Vec_PtrSize(p->vCells); }
240 static inline SC_Cell * SC_LibCell( SC_Lib * p, int i ) { return (SC_Cell *)Vec_PtrEntry(p->vCells, i); }
241 static inline SC_Pin * SC_CellPin( SC_Cell * p, int i ) { return (SC_Pin *)Vec_PtrEntry(p->vPins, i); }
242 static inline Vec_Wrd_t * SC_CellFunc( SC_Cell * p ) { return SC_CellPin(p, p->n_inputs)->vFunc; }
243 static inline float SC_CellPinCap( SC_Cell * p, int i ) { return 0.5 * SC_CellPin(p, i)->rise_cap + 0.5 * SC_CellPin(p, i)->fall_cap; }
244 static inline float SC_CellPinCapAve( SC_Cell * p ) { int i; float c = 0; for (i = 0; i < p->n_inputs; i++) c += SC_CellPinCap(p, i); return c / Abc_MaxInt(1, p->n_inputs); }
245 static inline char * SC_CellPinOutFunc( SC_Cell * p, int i ) { return SC_CellPin(p, p->n_inputs + i)->func_text; }
246 static inline char * SC_CellPinName( SC_Cell * p, int i ) { return SC_CellPin(p, i)->pName; }
247 
248 #define SC_LibForEachCell( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i )
249 #define SC_LibForEachCellClass( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, p->vCellClasses, pCell, i )
250 #define SC_LibForEachWireLoad( p, pWL, i ) Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i )
251 #define SC_LibForEachWireLoadSel( p, pWLS, i ) Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i )
252 #define SC_LibForEachTempl( p, pTempl, i ) Vec_PtrForEachEntry( SC_TableTempl *, p->vTempls, pTempl, i )
253 #define SC_CellForEachPin( p, pPin, i ) Vec_PtrForEachEntry( SC_Pin *, p->vPins, pPin, i )
254 #define SC_CellForEachPinIn( p, pPin, i ) Vec_PtrForEachEntryStop( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
255 #define SC_CellForEachPinOut( p, pPin, i ) Vec_PtrForEachEntryStart( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
256 #define SC_RingForEachCell( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pNext, i++ )
257 #define SC_RingForEachCellRev( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pPrev, i++ )
258 #define SC_PinForEachRTiming( p, pRTime, i ) Vec_PtrForEachEntry( SC_Timings *, p->vRTimings, pRTime, i )
259 
260 
261 ////////////////////////////////////////////////////////////////////////
262 /// FUNCTION DEFINITIONS ///
263 ////////////////////////////////////////////////////////////////////////
264 
265 /**Function*************************************************************
266 
267  Synopsis [Constructors of the library data-structures.]
268 
269  Description []
270 
271  SideEffects []
272 
273  SeeAlso []
274 
275 ***********************************************************************/
277 {
278  SC_WireLoad * p;
279  p = ABC_CALLOC( SC_WireLoad, 1 );
280  p->vFanout = Vec_IntAlloc( 0 );
281  p->vLen = Vec_FltAlloc( 0 );
282  return p;
283 }
285 {
286  SC_WireLoadSel * p;
287  p = ABC_CALLOC( SC_WireLoadSel, 1 );
288  p->vAreaFrom = Vec_FltAlloc( 0 );
289  p->vAreaTo = Vec_FltAlloc( 0 );
290  p->vWireLoadModel = Vec_PtrAlloc( 0 );
291  return p;
292 }
294 {
295  SC_TableTempl * p;
296  p = ABC_CALLOC( SC_TableTempl, 1 );
297  p->vVars = Vec_PtrAlloc( 0 );
298  p->vIndex = Vec_PtrAlloc( 0 );
299  return p;
300 }
302 {
303  SC_Surface * p;
304  p = ABC_CALLOC( SC_Surface, 1 );
305  p->vIndex0 = Vec_FltAlloc( 0 );
306  p->vIndex1 = Vec_FltAlloc( 0 );
307  p->vData = Vec_PtrAlloc( 0 );
308  return p;
309 }
310 static inline SC_Timing * Abc_SclTimingAlloc()
311 {
312  SC_Timing * p;
313  p = ABC_CALLOC( SC_Timing, 1 );
318  return p;
319 }
321 {
322  SC_Timings * p;
323  p = ABC_CALLOC( SC_Timings, 1 );
324  p->vTimings = Vec_PtrAlloc( 0 );
325  return p;
326 }
327 static inline SC_Pin * Abc_SclPinAlloc()
328 {
329  SC_Pin * p;
330  p = ABC_CALLOC( SC_Pin, 1 );
331  p->max_out_slew = -1;
332  p->vFunc = Vec_WrdAlloc( 0 );
333  p->vRTimings = Vec_PtrAlloc( 0 );
334  return p;
335 }
336 static inline SC_Cell * Abc_SclCellAlloc()
337 {
338  SC_Cell * p;
339  p = ABC_CALLOC( SC_Cell, 1 );
340  p->vPins = Vec_PtrAlloc( 0 );
341  return p;
342 }
343 static inline SC_Lib * Abc_SclLibAlloc()
344 {
345  SC_Lib * p;
346  p = ABC_CALLOC( SC_Lib, 1 );
347  p->default_max_out_slew = -1;
348  p->unit_time = 9;
349  p->unit_cap_fst = 1;
350  p->unit_cap_snd = 12;
351  p->vWireLoads = Vec_PtrAlloc( 0 );
352  p->vWireLoadSels = Vec_PtrAlloc( 0 );
353  p->vTempls = Vec_PtrAlloc( 0 );
354  p->vCells = Vec_PtrAlloc( 0 );
355  p->vCellClasses = Vec_PtrAlloc( 0 );
356  return p;
357 }
358 
359 
360 /**Function*************************************************************
361 
362  Synopsis [Destructors of the library data-structures.]
363 
364  Description []
365 
366  SideEffects []
367 
368  SeeAlso []
369 
370 ***********************************************************************/
371 static inline void Abc_SclWireLoadFree( SC_WireLoad * p )
372 {
373  Vec_IntFree( p->vFanout );
374  Vec_FltFree( p->vLen );
375  ABC_FREE( p->pName );
376  ABC_FREE( p );
377 }
378 static inline void Abc_SclWireLoadSelFree( SC_WireLoadSel * p )
379 {
380  Vec_FltFree( p->vAreaFrom );
381  Vec_FltFree( p->vAreaTo );
383  ABC_FREE( p->pName );
384  ABC_FREE( p );
385 }
386 static inline void Abc_SclTableTemplFree( SC_TableTempl * p )
387 {
388  Vec_PtrFreeFree( p->vVars );
389  Vec_VecFree( (Vec_Vec_t *)p->vIndex );
390  ABC_FREE( p->pName );
391  ABC_FREE( p );
392 }
393 static inline void Abc_SclSurfaceFree( SC_Surface * p )
394 {
395  Vec_FltFree( p->vIndex0 );
396  Vec_FltFree( p->vIndex1 );
397  Vec_VecFree( (Vec_Vec_t *)p->vData );
398  ABC_FREE( p->pName );
399  ABC_FREE( p );
400 }
401 static inline void Abc_SclTimingFree( SC_Timing * p )
402 {
407  ABC_FREE( p->related_pin );
408  ABC_FREE( p->when_text );
409  ABC_FREE( p );
410 }
411 static inline void Abc_SclTimingsFree( SC_Timings * p )
412 {
413  SC_Timing * pTemp;
414  int i;
415  Vec_PtrForEachEntry( SC_Timing *, p->vTimings, pTemp, i )
416  Abc_SclTimingFree( pTemp );
417  Vec_PtrFree( p->vTimings );
418  ABC_FREE( p->pName );
419  ABC_FREE( p );
420 }
421 static inline void Abc_SclPinFree( SC_Pin * p )
422 {
423  SC_Timings * pTemp;
424  int i;
425  SC_PinForEachRTiming( p, pTemp, i )
426  Abc_SclTimingsFree( pTemp );
427  Vec_PtrFree( p->vRTimings );
428  Vec_WrdFree( p->vFunc );
429  ABC_FREE( p->func_text );
430  ABC_FREE( p->pName );
431  ABC_FREE( p );
432 }
433 static inline void Abc_SclCellFree( SC_Cell * p )
434 {
435  SC_Pin * pTemp;
436  int i;
437  SC_CellForEachPin( p, pTemp, i )
438  Abc_SclPinFree( pTemp );
439  Vec_PtrFree( p->vPins );
440  ABC_FREE( p->pName );
441  ABC_FREE( p );
442 }
443 static inline void Abc_SclLibFree( SC_Lib * p )
444 {
445  SC_WireLoad * pWL;
446  SC_WireLoadSel * pWLS;
447  SC_TableTempl * pTempl;
448  SC_Cell * pCell;
449  int i;
450  SC_LibForEachWireLoad( p, pWL, i )
451  Abc_SclWireLoadFree( pWL );
452  Vec_PtrFree( p->vWireLoads );
453  SC_LibForEachWireLoadSel( p, pWLS, i )
454  Abc_SclWireLoadSelFree( pWLS );
456  SC_LibForEachTempl( p, pTempl, i )
457  Abc_SclTableTemplFree( pTempl );
458  Vec_PtrFree( p->vTempls );
459  SC_LibForEachCell( p, pCell, i )
460  Abc_SclCellFree( pCell );
461  Vec_PtrFree( p->vCells );
463  ABC_FREE( p->pName );
464  ABC_FREE( p->pFileName );
467  ABC_FREE( p->pBins );
468  ABC_FREE( p );
469 }
470 
471 
472 /**Function*************************************************************
473 
474  Synopsis [Lookup table delay computation.]
475 
476  Description []
477 
478  SideEffects []
479 
480  SeeAlso []
481 
482 ***********************************************************************/
483 static inline float Scl_LibLookup( SC_Surface * p, float slew, float load )
484 {
485  float * pIndex0, * pIndex1, * pDataS, * pDataS1;
486  float sfrac, lfrac, p0, p1;
487  int s, l;
488 
489  // handle constant table
490  if ( Vec_FltSize(p->vIndex0) == 1 && Vec_FltSize(p->vIndex1) == 1 )
491  {
492  Vec_Flt_t * vTemp = (Vec_Flt_t *)Vec_PtrEntry(p->vData, 0);
493  assert( Vec_PtrSize(p->vData) == 1 );
494  assert( Vec_FltSize(vTemp) == 1 );
495  return Vec_FltEntry(vTemp, 0);
496  }
497 
498  // Find closest sample points in surface:
499  pIndex0 = Vec_FltArray(p->vIndex0);
500  for ( s = 1; s < Vec_FltSize(p->vIndex0)-1; s++ )
501  if ( pIndex0[s] > slew )
502  break;
503  s--;
504 
505  pIndex1 = Vec_FltArray(p->vIndex1);
506  for ( l = 1; l < Vec_FltSize(p->vIndex1)-1; l++ )
507  if ( pIndex1[l] > load )
508  break;
509  l--;
510 
511  // Interpolate (or extrapolate) function value from sample points:
512  sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
513  lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
514 
515  pDataS = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(p->vData, s) );
516  pDataS1 = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(p->vData, s+1) );
517 
518  p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
519  p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
520 
521  return p0 + sfrac * (p1 - p0); // <<== multiply result with K factor here
522 }
523 static inline void Scl_LibPinArrival( SC_Timing * pTime, SC_Pair * pArrIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pArrOut, SC_Pair * pSlewOut )
524 {
525  if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
526  {
527  pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
528  pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
529  pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
530  pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
531  }
532  if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
533  {
534  pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->fall + Scl_LibLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
535  pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->rise + Scl_LibLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
536  pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
537  pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
538  }
539 }
540 static inline void Scl_LibPinDeparture( SC_Timing * pTime, SC_Pair * pDepIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pDepOut )
541 {
542  if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
543  {
544  pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
545  pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
546  }
547  if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
548  {
549  pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
550  pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
551  }
552 }
553 
554 /**Function*************************************************************
555 
556  Synopsis [Compute one timing edge.]
557 
558  Description []
559 
560  SideEffects []
561 
562  SeeAlso []
563 
564 ***********************************************************************/
565 static inline SC_Timing * Scl_CellPinTime( SC_Cell * pCell, int iPin )
566 {
567  SC_Pin * pPin;
568  SC_Timings * pRTime;
569  assert( iPin >= 0 && iPin < pCell->n_inputs );
570  pPin = SC_CellPin( pCell, pCell->n_inputs );
571  assert( Vec_PtrSize(pPin->vRTimings) == pCell->n_inputs );
572  pRTime = (SC_Timings *)Vec_PtrEntry( pPin->vRTimings, iPin );
573  if ( Vec_PtrSize(pRTime->vTimings) == 0 )
574  return NULL;
575  assert( Vec_PtrSize(pRTime->vTimings) == 1 );
576  return (SC_Timing *)Vec_PtrEntry( pRTime->vTimings, 0 );
577 }
578 static inline float Scl_LibPinArrivalEstimate( SC_Cell * pCell, int iPin, float Slew, float Load )
579 {
580  SC_Pair LoadIn = { Load, Load };
581  SC_Pair ArrIn = { 0.0, 0.0 };
582  SC_Pair ArrOut = { 0.0, 0.0 };
583  SC_Pair SlewIn = { 0.0, 0.0 };
584  SC_Pair SlewOut = { 0.0, 0.0 };
585 // Vec_Flt_t * vIndex0 = pTime->pCellRise->vIndex0; // slew
586 // SlewIn.fall = SlewIn.rise = Vec_FltEntry( vIndex0, Vec_FltSize(vIndex0)/2 );
587  SlewIn.fall = SlewIn.rise = Slew;
588  Scl_LibPinArrival( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut );
589  return 0.5 * ArrOut.fall + 0.5 * ArrOut.rise;
590 }
591 static inline void Scl_LibHandleInputDriver( SC_Cell * pCell, SC_Pair * pLoadIn, SC_Pair * pArrOut, SC_Pair * pSlewOut )
592 {
593  SC_Pair LoadIn = { 0.0, 0.0 }; // zero input load
594  SC_Pair ArrIn = { 0.0, 0.0 }; // zero input time
595  SC_Pair SlewIn = { 0.0, 0.0 }; // zero input slew
596  SC_Pair ArrOut0 = { 0.0, 0.0 }; // output time under zero load
597  SC_Pair ArrOut1 = { 0.0, 0.0 }; // output time under given load
598  SC_Pair SlewOut = { 0.0, 0.0 }; // output slew under zero load
599  pSlewOut->fall = pSlewOut->rise = 0;
600  assert( pCell->n_inputs == 1 );
601  Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut );
602  Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut );
603  pArrOut->fall = ArrOut1.fall - ArrOut0.fall;
604  pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
605 }
606 
607 /*=== sclLiberty.c ===============================================================*/
608 extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose );
609 /*=== sclLibScl.c ===============================================================*/
610 extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );
611 extern SC_Lib * Abc_SclReadFromFile( char * pFileName );
612 extern void Abc_SclWriteScl( char * pFileName, SC_Lib * p );
613 extern void Abc_SclWriteLiberty( char * pFileName, SC_Lib * p );
614 /*=== sclLibUtil.c ===============================================================*/
615 extern void Abc_SclHashCells( SC_Lib * p );
616 extern int Abc_SclCellFind( SC_Lib * p, char * pName );
617 extern int Abc_SclClassCellNum( SC_Cell * pClass );
618 extern int Abc_SclLibClassNum( SC_Lib * pLib );
619 extern void Abc_SclLinkCells( SC_Lib * p );
620 extern void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fShort );
621 extern void Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B );
622 extern void Abc_SclLibNormalize( SC_Lib * p );
623 extern SC_Cell * Abc_SclFindInvertor( SC_Lib * p, int fFindBuff );
624 extern SC_Cell * Abc_SclFindSmallestGate( SC_Cell * p, float CinMin );
625 extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area );
626 extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName );
627 extern int Abc_SclHasDelayInfo( void * pScl );
628 extern float Abc_SclComputeAverageSlew( SC_Lib * p );
629 extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
630 extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int nGatesMin );
631 
632 
634 
635 #endif
636 
637 ////////////////////////////////////////////////////////////////////////
638 /// END OF FILE ///
639 ////////////////////////////////////////////////////////////////////////
int unit_time
Definition: sclLib.h:209
int unsupp
Definition: sclLib.h:187
SC_Cell * pRepr
Definition: sclLib.h:196
static float SC_PairMin(SC_Pair *d)
Definition: sclLib.h:231
Vec_Ptr_t * vPins
Definition: sclLib.h:191
SC_Surface * pCellRise
Definition: sclLib.h:155
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
static int SC_LibCellNum(SC_Lib *p)
Definition: sclLib.h:239
static void Abc_SclSurfaceFree(SC_Surface *p)
Definition: sclLib.h:393
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int nGates
Definition: sclLib.h:199
#define SC_CellForEachPin(p, pPin, i)
Definition: sclLib.h:253
float unit_cap_fst
Definition: sclLib.h:210
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
SC_Lib * Abc_SclReadFromFile(char *pFileName)
Definition: sclLibScl.c:248
int fBufPis
Definition: sclLib.h:97
static SC_WireLoad * Abc_SclWireLoadAlloc()
FUNCTION DEFINITIONS ///.
Definition: sclLib.h:276
static void SC_PairDup(SC_Pair *d, SC_Pair *s)
Definition: sclLib.h:233
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
char * pFileName
Definition: sclLib.h:205
char * pName
Definition: sclLib.h:163
static void Abc_SclTableTemplFree(SC_TableTempl *p)
Definition: sclLib.h:386
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
float fall_cap
Definition: sclLib.h:173
int fAddBufs
Definition: sclLib.h:96
float slope
Definition: sclLib.h:121
static SC_TableTempl * Abc_SclTableTemplAlloc()
Definition: sclLib.h:293
int Order
Definition: sclLib.h:198
int TimeOut
Definition: sclLib.h:79
static SC_Surface * Abc_SclSurfaceAlloc()
Definition: sclLib.h:301
char * default_wire_load
Definition: sclLib.h:206
SC_Lib * Abc_SclReadLiberty(char *pFileName, int fVerbose, int fVeryVerbose)
Definition: sclLiberty.c:1626
static void Vec_FltFree(Vec_Flt_t *p)
Definition: vecFlt.h:218
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
static void Scl_LibPinDeparture(SC_Timing *pTime, SC_Pair *pDepIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pDepOut)
Definition: sclLib.h:540
Vec_Ptr_t * vRTimings
Definition: sclLib.h:178
Vec_Flt_t * vAreaTo
Definition: sclLib.h:130
float approx[3][6]
Definition: sclLib.h:147
int fVeryVerbose
Definition: sclLib.h:86
Vec_Ptr_t * vData
Definition: sclLib.h:146
Vec_Ptr_t * vCellClasses
Definition: sclLib.h:216
SC_Dir
Definition: sclLib.h:45
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecFlt.h:78
Vec_Ptr_t * vWireLoadModel
Definition: sclLib.h:131
char * pName
Definition: sclLib.h:128
Vec_Ptr_t * vVars
Definition: sclLib.h:137
float leakage
Definition: sclLib.h:189
static float * Vec_FltArray(Vec_Flt_t *p)
Definition: vecFlt.h:274
static float SC_CellPinCapAve(SC_Cell *p)
Definition: sclLib.h:244
Vec_Ptr_t * vWireLoads
Definition: sclLib.h:212
Vec_Flt_t * vLen
Definition: sclLib.h:123
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
int nBins
Definition: sclLib.h:218
int * pBins
Definition: sclLib.h:217
int fVerbose
Definition: sclLib.h:85
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
Vec_Ptr_t * vIndex
Definition: sclLib.h:138
static SC_Timings * Abc_SclTimingsAlloc()
Definition: sclLib.h:320
static void Abc_SclWireLoadFree(SC_WireLoad *p)
Definition: sclLib.h:371
char * func_text
Definition: sclLib.h:176
SC_Dir dir
Definition: sclLib.h:170
static SC_Lib * Abc_SclLibAlloc()
Definition: sclLib.h:343
Vec_Wrd_t * vFunc
Definition: sclLib.h:177
#define SC_LibForEachWireLoadSel(p, pWLS, i)
Definition: sclLib.h:251
int fUseWireLoads
Definition: sclLib.h:84
SC_WireLoad * Abc_SclFindWireLoadModel(SC_Lib *p, float Area)
Definition: sclLibUtil.c:247
int fUseWireLoads
Definition: sclLib.h:98
static SC_Pin * Abc_SclPinAlloc()
Definition: sclLib.h:327
int fSizeOnly
Definition: sclLib.h:95
Vec_Flt_t * vIndex1
Definition: sclLib.h:145
float area
Definition: sclLib.h:188
static SC_Cell * Abc_SclCellAlloc()
Definition: sclLib.h:336
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int unit_cap_snd
Definition: sclLib.h:211
int nIterNoChange
Definition: sclLib.h:73
static void SC_PairClean(SC_Pair *d)
GLOBAL VARIABLES ///.
Definition: sclLib.h:229
float rise
Definition: sclLib.h:65
void Abc_SclWriteLiberty(char *pFileName, SC_Lib *p)
Definition: sclLibScl.c:660
SC_TSense tsense
Definition: sclLib.h:153
static float Scl_LibLookup(SC_Surface *p, float slew, float load)
Definition: sclLib.h:483
int fVeryVerbose
Definition: sclLib.h:100
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition: sclLibScl.c:234
static SC_WireLoadSel * Abc_SclWireLoadSelAlloc()
Definition: sclLib.h:284
float cap
Definition: sclLib.h:120
float fall
Definition: sclLib.h:66
float default_max_out_slew
Definition: sclLib.h:208
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
static SC_Timing * Abc_SclTimingAlloc()
Definition: sclLib.h:310
static void Abc_SclTimingsFree(SC_Timings *p)
Definition: sclLib.h:411
SC_Cell * pAve
Definition: sclLib.h:197
char * pName
Definition: sclLib.h:119
int Id
Definition: sclLib.h:184
SC_Cell * Abc_SclFindSmallestGate(SC_Cell *p, float CinMin)
Definition: sclLibUtil.c:208
char * pName
Definition: sclLib.h:183
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
int seq
Definition: sclLib.h:186
static char * SC_CellPinName(SC_Cell *p, int i)
Definition: sclLib.h:246
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
int DelayUser
Definition: sclLib.h:77
static int SC_PairEqual(SC_Pair *d, SC_Pair *s)
Definition: sclLib.h:236
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
void Abc_SclPrintCells(SC_Lib *p, float Slew, float Gain, int fInvOnly, int fShort)
Definition: sclLibUtil.c:503
int Abc_SclLibClassNum(SC_Lib *pLib)
Definition: sclLibUtil.c:93
SC_Surface * pFallTrans
Definition: sclLib.h:158
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
void Abc_SclWriteScl(char *pFileName, SC_Lib *p)
Definition: sclLibScl.c:444
Vec_Ptr_t * vTimings
Definition: sclLib.h:164
int Notches
Definition: sclLib.h:76
static void Abc_SclTimingFree(SC_Timing *p)
Definition: sclLib.h:401
static Vec_Wrd_t * SC_CellFunc(SC_Cell *p)
Definition: sclLib.h:242
static void SC_PairAdd(SC_Pair *d, SC_Pair *s)
Definition: sclLib.h:235
static float SC_PairAve(SC_Pair *d)
Definition: sclLib.h:232
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
int nDegree
Definition: sclLib.h:94
int drive_strength
Definition: sclLib.h:190
void Abc_SclInstallGenlib(void *pScl, float Slew, float Gain, int nGatesMin)
Definition: sclLibUtil.c:844
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int fUseDept
Definition: sclLib.h:82
int n_outputs
Definition: sclLib.h:193
Vec_Ptr_t * vTempls
Definition: sclLib.h:214
int BypassFreq
Definition: sclLib.h:81
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition: sclLibUtil.c:197
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
float max_out_slew
Definition: sclLib.h:175
SC_Surface * pRiseTrans
Definition: sclLib.h:157
static int SC_PairEqualE(SC_Pair *d, SC_Pair *s, float E)
Definition: sclLib.h:237
int GainRatio
Definition: sclLib.h:92
Vec_Int_t * vFanout
Definition: sclLib.h:122
static float SC_CellPinCap(SC_Cell *p, int i)
Definition: sclLib.h:243
int Window
Definition: sclLib.h:74
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:79
static float SC_PairMax(SC_Pair *d)
Definition: sclLib.h:230
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:230
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Abc_SclPinFree(SC_Pin *p)
Definition: sclLib.h:421
void Abc_SclLinkCells(SC_Lib *p)
Definition: sclLibUtil.c:129
int Abc_SclHasDelayInfo(void *pScl)
Definition: sclLibUtil.c:292
int Slew
Definition: sclLib.h:93
static void Scl_LibPinArrival(SC_Timing *pTime, SC_Pair *pArrIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pArrOut, SC_Pair *pSlewOut)
Definition: sclLib.h:523
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int nIters
Definition: sclLib.h:72
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
int n_inputs
Definition: sclLib.h:192
#define SC_LibForEachWireLoad(p, pWL, i)
Definition: sclLib.h:250
char * related_pin
Definition: sclLib.h:152
static void Abc_SclCellFree(SC_Cell *p)
Definition: sclLib.h:433
char * when_text
Definition: sclLib.h:154
static char * SC_CellPinOutFunc(SC_Cell *p, int i)
Definition: sclLib.h:245
#define assert(ex)
Definition: util_old.h:213
SC_Cell * pPrev
Definition: sclLib.h:195
void Abc_SclHashCells(SC_Lib *p)
Definition: sclLibUtil.c:65
char * pName
Definition: sclLib.h:169
float cap
Definition: sclLib.h:171
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
Vec_Ptr_t * vWireLoadSels
Definition: sclLib.h:213
Vec_Flt_t * vAreaFrom
Definition: sclLib.h:129
#define SC_PinForEachRTiming(p, pRTime, i)
Definition: sclLib.h:258
SC_Surface * pCellFall
Definition: sclLib.h:156
static void SC_PairMove(SC_Pair *d, SC_Pair *s)
Definition: sclLib.h:234
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition: sclLibUtil.c:317
#define SC_LibForEachTempl(p, pTempl, i)
Definition: sclLib.h:252
float rise_cap
Definition: sclLib.h:172
static float Scl_LibPinArrivalEstimate(SC_Cell *pCell, int iPin, float Slew, float Load)
Definition: sclLib.h:578
char * pName
Definition: sclLib.h:136
char * pName
Definition: sclLib.h:143
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
float max_out_cap
Definition: sclLib.h:174
static void Abc_SclLibFree(SC_Lib *p)
Definition: sclLib.h:443
Vec_Ptr_t * vCells
Definition: sclLib.h:215
void Abc_SclLibNormalize(SC_Lib *p)
Definition: sclLibUtil.c:615
int fSkip
Definition: sclLib.h:185
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
int Ratio
Definition: sclLib.h:75
SC_Cell * pNext
Definition: sclLib.h:194
void Abc_SclDumpGenlib(char *pFileName, SC_Lib *p, float Slew, float Gain, int nGatesMin)
Definition: sclLibUtil.c:795
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
int fDumpStats
Definition: sclLib.h:83
int fVerbose
Definition: sclLib.h:99
static void Abc_SclWireLoadSelFree(SC_WireLoadSel *p)
Definition: sclLib.h:378
char * default_wire_load_sel
Definition: sclLib.h:207
char * pName
Definition: sclLib.h:204
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition: sclLibUtil.c:84
SC_TSense
Definition: sclLib.h:54
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static void Scl_LibHandleInputDriver(SC_Cell *pCell, SC_Pair *pLoadIn, SC_Pair *pArrOut, SC_Pair *pSlewOut)
Definition: sclLib.h:591
void Abc_SclConvertLeakageIntoArea(SC_Lib *p, float A, float B)
Definition: sclLibUtil.c:584