ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sclLib.h
Go to the documentation of this file.
1
20
21#ifndef ABC__map__scl__sclLib_h
22#define ABC__map__scl__sclLib_h
23
24
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
42
43#define ABC_SCL_CUR_VERSION 8
44
53
54typedef enum // -- timing sense, positive-, negative- or non-unate
55{
60} SC_TSense;
61
62typedef struct SC_DontUse_ SC_DontUse;
64{
65 int size;
67};
68
69typedef struct SC_Pair_ SC_Pair;
70struct SC_Pair_
71{
72 float rise;
73 float fall;
74};
75typedef struct SC_PairI_ SC_PairI;
76struct SC_PairI_
77{
78 int rise;
79 int fall;
80};
81
84{
85 int nIters;
87 int Window; // used for upsizing
88 int Ratio; // used for upsizing
93 int BuffTreeEst; // ratio for buffer tree estimation
94 int BypassFreq; // frequency to try bypassing
100};
101
102typedef struct SC_BusPars_ SC_BusPars;
104{
105 int GainRatio; // target gain
106 int Slew; // target slew
107 int nDegree; // max branching factor
108 int fSizeOnly; // perform only sizing
109 int fAddBufs; // add buffers
110 int fBufPis; // use CI buffering
111 int fUseWireLoads; // wire loads
112 int fVerbose; // verbose
113 int fVeryVerbose; // verbose
114};
115
119
123typedef struct SC_Surface_ SC_Surface;
124typedef struct SC_Timing_ SC_Timing;
125typedef struct SC_Timings_ SC_Timings;
126typedef struct SC_Pin_ SC_Pin;
127typedef struct SC_Cell_ SC_Cell;
128typedef struct SC_Lib_ SC_Lib;
129
131{
132 char * pName;
133 float cap; // }- multiply estimation in 'fanout_len[].snd' with this value
134 float slope; // used to extrapolate wireload for large fanout count
135 Vec_Int_t vFanout; // Vec<Pair<uint,float> > -- pairs '(#fanouts, est-wire-len)'
137};
138
140{
141 char * pName;
142 Vec_Flt_t vAreaFrom; // Vec<Trip<float,float,Str> > -- triplets '(from-area, upto-area, wire-load-model)'; range is [from, upto[
145};
146
148{
149 char * pName;
150 Vec_Ptr_t vVars; // Vec<Str> -- name of variable (numbered from 0, not 1 as in the Liberty file)
151 Vec_Ptr_t vIndex; // Vec<Vec<float> > -- this is the point of measurement in table for the given variable
152};
153
155{
156 char * pName;
157 Vec_Flt_t vIndex0; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
158 Vec_Flt_t vIndex1; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
159 Vec_Ptr_t vData; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
160 Vec_Int_t vIndex0I; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
161 Vec_Int_t vIndex1I; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
162 Vec_Ptr_t vDataI; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
163 float approx[3][6];
164};
165
167{
168 char * related_pin; // -- related pin
169 SC_TSense tsense; // -- timing sense (positive_unate, negative_unate, non_unate)
170 char * when_text; // -- logic condition on inputs triggering this delay model for the output (currently not used)
171 SC_Surface pCellRise; // -- Used to compute pin-to-pin delay
173 SC_Surface pRiseTrans; // -- Used to compute output slew
175};
176
178{
179 char * pName; // -- the 'related_pin' field
180 Vec_Ptr_t vTimings; // structures of type SC_Timing
181};
182
183struct SC_Pin_
184{
185 char * pName;
187 float cap; // -- this value is used if 'rise_cap' and 'fall_cap' is missing (copied by 'postProcess()'). (not used)
188 float rise_cap; // }- used for input pins ('cap' too).
189 float fall_cap; // }
190 int rise_capI; // }- used for input pins ('cap' too).
191 int fall_capI; // }
192 float max_out_cap; // } (not used)
193 float max_out_slew; // }- used only for output pins (max values must not be exceeded or else mapping is illegal) (not used)
194 char * func_text; // }
196 Vec_Ptr_t vRTimings; // -- for output pins
197// SC_Timing Timing; // -- for output pins
198};
199
200struct SC_Cell_
201{
202 char * pName;
203 int Id;
204 int fSkip; // skip this cell during genlib computation
205 int seq; // -- set to TRUE by parser if a sequential element
206 int unsupp; // -- set to TRUE by parser if cell contains information we cannot handle
207 float area;
208 float leakage;
209 int areaI;
211 int drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)
212 Vec_Ptr_t vPins; // NamedSet<SC_Pin>
213 int n_inputs; // -- 'pins[0 .. n_inputs-1]' are input pins
214 int n_outputs; // -- 'pins[n_inputs .. n_inputs+n_outputs-1]' are output pins
215 SC_Cell * pNext; // same-functionality cells linked into a ring by area
216 SC_Cell * pPrev; // same-functionality cells linked into a ring by area
217 SC_Cell * pRepr; // representative of the class
218 SC_Cell * pAve; // average size cell of this class
219 int Order; // order of the gate in the list
220 int nGates; // the number of gates in the list
221};
222
223struct SC_Lib_
224{
225 char * pName;
226 char * pFileName;
229 float default_max_out_slew; // -- 'default_max_transition'; this is copied to each output pin where 'max_transition' is not defined (not used)
230 int unit_time; // -- Valid 9..12. Unit is '10^(-val)' seconds (e.g. 9=1ns, 10=100ps, 11=10ps, 12=1ps)
231 float unit_cap_fst; // -- First part is a multiplier, second either 12 or 15 for 'pf' or 'ff'.
233 Vec_Ptr_t vWireLoads; // NamedSet<SC_WireLoad>
234 Vec_Ptr_t vWireLoadSels; // NamedSet<SC_WireLoadSel>
235 Vec_Ptr_t vTempls; // NamedSet<SC_TableTempl>
236 Vec_Ptr_t vCells; // NamedSet<SC_Cell>
237 Vec_Ptr_t vCellClasses; // NamedSet<SC_Cell>
238 int * pBins; // hashing gateName -> gateId
239 int nBins;
240};
241
245
249
250static inline void SC_PairClean( SC_Pair * d ) { d->rise = d->fall = 0; }
251static inline float SC_PairMax( SC_Pair * d ) { return Abc_MaxFloat(d->rise, d->fall); }
252static inline float SC_PairMin( SC_Pair * d ) { return Abc_MinFloat(d->rise, d->fall); }
253static inline float SC_PairAve( SC_Pair * d ) { return 0.5 * d->rise + 0.5 * d->fall; }
254static inline void SC_PairDup( SC_Pair * d, SC_Pair * s ) { *d = *s; }
255static inline void SC_PairMove( SC_Pair * d, SC_Pair * s ) { *d = *s; s->rise = s->fall = 0; }
256static inline void SC_PairAdd( SC_Pair * d, SC_Pair * s ) { d->rise += s->rise; d->fall += s->fall;}
257static inline int SC_PairEqual( SC_Pair * d, SC_Pair * s ) { return d->rise == s->rise && d->fall == s->fall; }
258static 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; }
259
260static inline int SC_LibCellNum( SC_Lib * p ) { return Vec_PtrSize(&p->vCells); }
261static inline SC_Cell * SC_LibCell( SC_Lib * p, int i ) { return (SC_Cell *)Vec_PtrEntry(&p->vCells, i); }
262static inline SC_Pin * SC_CellPin( SC_Cell * p, int i ) { return (SC_Pin *)Vec_PtrEntry(&p->vPins, i); }
263static inline Vec_Wrd_t * SC_CellFunc( SC_Cell * p ) { return &SC_CellPin(p, p->n_inputs)->vFunc; }
264static 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; }
265static 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); }
266static inline char * SC_CellPinOutFunc( SC_Cell * p, int i ) { return SC_CellPin(p, p->n_inputs + i)->func_text; }
267static inline char * SC_CellPinName( SC_Cell * p, int i ) { return SC_CellPin(p, i)->pName; }
268
269#define SC_LibForEachCell( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, &p->vCells, pCell, i )
270#define SC_LibForEachCellClass( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, &p->vCellClasses, pCell, i )
271#define SC_LibForEachWireLoad( p, pWL, i ) Vec_PtrForEachEntry( SC_WireLoad *, &p->vWireLoads, pWL, i )
272#define SC_LibForEachWireLoadSel( p, pWLS, i ) Vec_PtrForEachEntry( SC_WireLoadSel *, &p->vWireLoadSels, pWLS, i )
273#define SC_LibForEachTempl( p, pTempl, i ) Vec_PtrForEachEntry( SC_TableTempl *, &p->vTempls, pTempl, i )
274#define SC_CellForEachPin( p, pPin, i ) Vec_PtrForEachEntry( SC_Pin *, &p->vPins, pPin, i )
275#define SC_CellForEachPinIn( p, pPin, i ) Vec_PtrForEachEntryStop( SC_Pin *, &p->vPins, pPin, i, p->n_inputs )
276#define SC_CellForEachPinOut( p, pPin, i ) Vec_PtrForEachEntryStart( SC_Pin *, &p->vPins, pPin, i, p->n_inputs )
277#define SC_RingForEachCell( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pNext, i++ )
278#define SC_RingForEachCellRev( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pPrev, i++ )
279#define SC_PinForEachRTiming( p, pRTime, i ) Vec_PtrForEachEntry( SC_Timings *, &p->vRTimings, pRTime, i )
280
281
285
297static inline SC_WireLoad * Abc_SclWireLoadAlloc()
298{
299 SC_WireLoad * p;
300 p = ABC_CALLOC( SC_WireLoad, 1 );
301 return p;
302}
303static inline SC_WireLoadSel * Abc_SclWireLoadSelAlloc()
304{
307 return p;
308}
309static inline SC_TableTempl * Abc_SclTableTemplAlloc()
310{
312 p = ABC_CALLOC( SC_TableTempl, 1 );
313 return p;
314}
315static inline SC_Surface * Abc_SclSurfaceAlloc()
316{
317 SC_Surface * p;
318 p = ABC_CALLOC( SC_Surface, 1 );
319 return p;
320}
321static inline SC_Timing * Abc_SclTimingAlloc()
322{
323 SC_Timing * p;
324 p = ABC_CALLOC( SC_Timing, 1 );
325 return p;
326}
327static inline SC_Timings * Abc_SclTimingsAlloc()
328{
329 SC_Timings * p;
330 p = ABC_CALLOC( SC_Timings, 1 );
331 return p;
332}
333static inline SC_Pin * Abc_SclPinAlloc()
334{
335 SC_Pin * p;
336 p = ABC_CALLOC( SC_Pin, 1 );
337 p->max_out_slew = -1;
338 return p;
339}
340static inline SC_Cell * Abc_SclCellAlloc()
341{
342 SC_Cell * p;
343 p = ABC_CALLOC( SC_Cell, 1 );
344 return p;
345}
346static inline SC_Lib * Abc_SclLibAlloc()
347{
348 SC_Lib * p;
349 p = ABC_CALLOC( SC_Lib, 1 );
350 p->default_max_out_slew = -1;
351 p->unit_time = 9;
352 p->unit_cap_fst = 1;
353 p->unit_cap_snd = 12;
354 return p;
355}
356
357
369static inline void Abc_SclWireLoadFree( SC_WireLoad * p )
370{
371 Vec_IntErase( &p->vFanout );
372 Vec_FltErase( &p->vLen );
373 ABC_FREE( p->pName );
374 ABC_FREE( p );
375}
376static inline void Abc_SclWireLoadSelFree( SC_WireLoadSel * p )
377{
378 Vec_FltErase( &p->vAreaFrom );
379 Vec_FltErase( &p->vAreaTo );
380 Vec_PtrFreeData( &p->vWireLoadModel );
381 Vec_PtrErase( &p->vWireLoadModel );
382 ABC_FREE( p->pName );
383 ABC_FREE( p );
384}
385static inline void Abc_SclTableTemplFree( SC_TableTempl * p )
386{
387 Vec_PtrFreeData( &p->vVars );
388 Vec_PtrErase( &p->vVars );
389 Vec_VecErase( (Vec_Vec_t *)&p->vIndex );
390 ABC_FREE( p->pName );
391 ABC_FREE( p );
392}
393static inline void Abc_SclSurfaceFree( SC_Surface * p )
394{
395 Vec_FltErase( &p->vIndex0 );
396 Vec_FltErase( &p->vIndex1 );
397 Vec_IntErase( &p->vIndex0I );
398 Vec_IntErase( &p->vIndex1I );
399 Vec_VecErase( (Vec_Vec_t *)&p->vData );
400 Vec_VecErase( (Vec_Vec_t *)&p->vDataI );
401 ABC_FREE( p->pName );
402// ABC_FREE( p );
403}
404static inline void Abc_SclTimingFree( SC_Timing * p )
405{
406 Abc_SclSurfaceFree( &p->pCellRise );
407 Abc_SclSurfaceFree( &p->pCellFall );
408 Abc_SclSurfaceFree( &p->pRiseTrans );
409 Abc_SclSurfaceFree( &p->pFallTrans );
410 ABC_FREE( p->related_pin );
411 ABC_FREE( p->when_text );
412 ABC_FREE( p );
413}
414static inline void Abc_SclTimingsFree( SC_Timings * p )
415{
416 SC_Timing * pTemp;
417 int i;
418 Vec_PtrForEachEntry( SC_Timing *, &p->vTimings, pTemp, i )
419 Abc_SclTimingFree( pTemp );
420 Vec_PtrErase( &p->vTimings );
421 ABC_FREE( p->pName );
422 ABC_FREE( p );
423}
424static inline void Abc_SclPinFree( SC_Pin * p )
425{
426 SC_Timings * pTemp;
427 int i;
428 SC_PinForEachRTiming( p, pTemp, i )
429 Abc_SclTimingsFree( pTemp );
430 Vec_PtrErase( &p->vRTimings );
431 Vec_WrdErase( &p->vFunc );
432 ABC_FREE( p->func_text );
433 ABC_FREE( p->pName );
434 ABC_FREE( p );
435}
436static inline void Abc_SclCellFree( SC_Cell * p )
437{
438 SC_Pin * pTemp;
439 int i;
440 SC_CellForEachPin( p, pTemp, i )
441 Abc_SclPinFree( pTemp );
442 Vec_PtrErase( &p->vPins );
443 ABC_FREE( p->pName );
444 ABC_FREE( p );
445}
446static inline void Abc_SclLibFree( SC_Lib * p )
447{
448 SC_WireLoad * pWL;
449 SC_WireLoadSel * pWLS;
450 SC_TableTempl * pTempl;
451 SC_Cell * pCell;
452 int i;
453 SC_LibForEachWireLoad( p, pWL, i )
454 Abc_SclWireLoadFree( pWL );
455 Vec_PtrErase( &p->vWireLoads );
456 SC_LibForEachWireLoadSel( p, pWLS, i )
457 Abc_SclWireLoadSelFree( pWLS );
458 Vec_PtrErase( &p->vWireLoadSels );
459 SC_LibForEachTempl( p, pTempl, i )
460 Abc_SclTableTemplFree( pTempl );
461 Vec_PtrErase( &p->vTempls );
462 SC_LibForEachCell( p, pCell, i )
463 Abc_SclCellFree( pCell );
464 Vec_PtrErase( &p->vCells );
465 Vec_PtrErase( &p->vCellClasses );
466 ABC_FREE( p->pName );
467 ABC_FREE( p->pFileName );
468 ABC_FREE( p->default_wire_load );
469 ABC_FREE( p->default_wire_load_sel );
470 ABC_FREE( p->pBins );
471 ABC_FREE( p );
472}
473
474
486static inline float Scl_LibLookup( SC_Surface * p, float slew, float load )
487{
488 float * pIndex0, * pIndex1, * pDataS, * pDataS1;
489 float sfrac, lfrac, p0, p1;
490 int s, l;
491
492 // handle constant table
493 if ( Vec_FltSize(&p->vIndex0) == 1 && Vec_FltSize(&p->vIndex1) == 1 )
494 {
495 Vec_Flt_t * vTemp = (Vec_Flt_t *)Vec_PtrEntry(&p->vData, 0);
496 assert( Vec_PtrSize(&p->vData) == 1 );
497 assert( Vec_FltSize(vTemp) == 1 );
498 return Vec_FltEntry(vTemp, 0);
499 }
500
501 // Find closest sample points in surface:
502 pIndex0 = Vec_FltArray(&p->vIndex0);
503 for ( s = 1; s < Vec_FltSize(&p->vIndex0)-1; s++ )
504 if ( pIndex0[s] > slew )
505 break;
506 s--;
507
508 pIndex1 = Vec_FltArray(&p->vIndex1);
509 for ( l = 1; l < Vec_FltSize(&p->vIndex1)-1; l++ )
510 if ( pIndex1[l] > load )
511 break;
512 l--;
513
514 // Interpolate (or extrapolate) function value from sample points:
515 sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
516 lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
517
518 pDataS = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(&p->vData, s) );
519 pDataS1 = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(&p->vData, s+1) );
520
521 p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
522 p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
523
524 return p0 + sfrac * (p1 - p0); // <<== multiply result with K factor here
525}
526static inline void Scl_LibPinArrival( SC_Timing * pTime, SC_Pair * pArrIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pArrOut, SC_Pair * pSlewOut )
527{
528 if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
529 {
530 pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->rise + Scl_LibLookup(&pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
531 pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->fall + Scl_LibLookup(&pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
532 pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(&pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
533 pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(&pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
534 }
535 if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
536 {
537 pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->fall + Scl_LibLookup(&pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
538 pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->rise + Scl_LibLookup(&pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
539 pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(&pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
540 pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(&pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
541 }
542}
543static inline void Scl_LibPinDeparture( SC_Timing * pTime, SC_Pair * pDepIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pDepOut )
544{
545 if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
546 {
547 pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->rise + Scl_LibLookup(&pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
548 pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->fall + Scl_LibLookup(&pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
549 }
550 if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
551 {
552 pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->rise + Scl_LibLookup(&pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
553 pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->fall + Scl_LibLookup(&pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
554 }
555}
556
568static inline int Scl_LibLookupI( SC_Surface * p, int slew, int load )
569{
570 int * pIndex0, * pIndex1, * pDataS, * pDataS1;
571 int p0, p1, s, l;
572 iword lFrac0, lFrac1, sFrac;
573
574 // handle constant table
575 if ( Vec_IntSize(&p->vIndex0I) == 1 && Vec_IntSize(&p->vIndex1I) == 1 )
576 {
577 Vec_Int_t * vTemp = (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, 0);
578 assert( Vec_PtrSize(&p->vDataI) == 1 );
579 assert( Vec_IntSize(vTemp) == 1 );
580 return Vec_IntEntry(vTemp, 0);
581 }
582
583 // Find closest sample points in surface:
584 pIndex0 = Vec_IntArray(&p->vIndex0I);
585 for ( s = 1; s < Vec_IntSize(&p->vIndex0I)-1; s++ )
586 if ( pIndex0[s] > slew )
587 break;
588 s--;
589
590 pIndex1 = Vec_IntArray(&p->vIndex1I);
591 for ( l = 1; l < Vec_IntSize(&p->vIndex1I)-1; l++ )
592 if ( pIndex1[l] > load )
593 break;
594 l--;
595
596 pDataS = Vec_IntArray( (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, s) );
597 pDataS1 = Vec_IntArray( (Vec_Int_t *)Vec_PtrEntry(&p->vDataI, s+1) );
598
599 // Interpolate (or extrapolate) function value from sample points:
600// lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
601// sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
602
603 lFrac0 = (iword)(pDataS [l+1] - pDataS [l]) * (iword)(load - pIndex1[l]) / (iword)(pIndex1[l+1] - pIndex1[l]);
604 lFrac1 = (iword)(pDataS1[l+1] - pDataS1[l]) * (iword)(load - pIndex1[l]) / (iword)(pIndex1[l+1] - pIndex1[l]);
605
606// p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
607// p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
608
609 p0 = pDataS [l] + (int)lFrac0;
610 p1 = pDataS1[l] + (int)lFrac1;
611
612 sFrac = (iword)(p1 - p0) * (iword)(slew - pIndex0[s]) / (iword)(pIndex0[s+1] - pIndex0[s]);
613
614// return p0 + sfrac * (p1 - p0);
615 return p0 + (int)sFrac;
616}
617static inline void Scl_LibPinArrivalI( SC_Timing * pTime, SC_PairI * pArrIn, SC_PairI * pSlewIn, SC_PairI * pLoad, SC_PairI * pArrOut, SC_PairI * pSlewOut, int * pArray )
618{
619 if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
620 {
621 pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->rise + (pArray[0] = Scl_LibLookupI(&pTime->pCellRise, pSlewIn->rise, pLoad->rise)) );
622 pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->fall + (pArray[1] = Scl_LibLookupI(&pTime->pCellFall, pSlewIn->fall, pLoad->fall)) );
623 pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
624 pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
625 }
626 if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
627 {
628 pArrOut->rise = Abc_MaxInt( pArrOut->rise, pArrIn->fall + (pArray[2] = Scl_LibLookupI(&pTime->pCellRise, pSlewIn->fall, pLoad->rise)) );
629 pArrOut->fall = Abc_MaxInt( pArrOut->fall, pArrIn->rise + (pArray[3] = Scl_LibLookupI(&pTime->pCellFall, pSlewIn->rise, pLoad->fall)) );
630 pSlewOut->rise = Abc_MaxInt( pSlewOut->rise, Scl_LibLookupI(&pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
631 pSlewOut->fall = Abc_MaxInt( pSlewOut->fall, Scl_LibLookupI(&pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
632 }
633}
634static inline void Scl_LibPinRequiredI( SC_Timing * pTime, SC_PairI * pReqIn, SC_PairI * pReqOut, int * pArray )
635{
636 if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
637 {
638 pReqIn->rise = Abc_MinInt( pReqIn->rise, pReqOut->rise - pArray[0] );
639 pReqIn->fall = Abc_MinInt( pReqIn->fall, pReqOut->fall - pArray[1] );
640 }
641 if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
642 {
643 pReqIn->fall = Abc_MinInt( pReqIn->fall, pReqOut->rise - pArray[2] );
644 pReqIn->rise = Abc_MinInt( pReqIn->rise, pReqOut->fall - pArray[3] );
645 }
646}
647
659static inline SC_Timing * Scl_CellPinTime( SC_Cell * pCell, int iPin )
660{
661 SC_Pin * pPin;
662 SC_Timings * pRTime;
663 assert( iPin >= 0 && iPin < pCell->n_inputs );
664 pPin = SC_CellPin( pCell, pCell->n_inputs );
665 assert( Vec_PtrSize(&pPin->vRTimings) == pCell->n_inputs );
666 pRTime = (SC_Timings *)Vec_PtrEntry( &pPin->vRTimings, iPin );
667 if ( Vec_PtrSize(&pRTime->vTimings) == 0 )
668 return NULL;
669 assert( Vec_PtrSize(&pRTime->vTimings) == 1 );
670 return (SC_Timing *)Vec_PtrEntry( &pRTime->vTimings, 0 );
671}
672static inline float Scl_LibPinArrivalEstimate( SC_Cell * pCell, int iPin, float Slew, float Load )
673{
674 SC_Pair LoadIn = { Load, Load };
675 SC_Pair ArrIn = { 0.0, 0.0 };
676 SC_Pair ArrOut = { 0.0, 0.0 };
677 SC_Pair SlewIn = { 0.0, 0.0 };
678 SC_Pair SlewOut = { 0.0, 0.0 };
679// Vec_Flt_t * vIndex0 = pTime->pCellRise->vIndex0; // slew
680// SlewIn.fall = SlewIn.rise = Vec_FltEntry( vIndex0, Vec_FltSize(vIndex0)/2 );
681 SlewIn.fall = SlewIn.rise = Slew;
682 Scl_LibPinArrival( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut );
683 return 0.5 * ArrOut.fall + 0.5 * ArrOut.rise;
684}
685static inline void Scl_LibHandleInputDriver( SC_Cell * pCell, SC_Pair * pLoadIn, SC_Pair * pArrOut, SC_Pair * pSlewOut )
686{
687 SC_Pair LoadIn = { 0.0, 0.0 }; // zero input load
688 SC_Pair ArrIn = { 0.0, 0.0 }; // zero input time
689 SC_Pair SlewIn = { 0.0, 0.0 }; // zero input slew
690 SC_Pair ArrOut0 = { 0.0, 0.0 }; // output time under zero load
691 SC_Pair ArrOut1 = { 0.0, 0.0 }; // output time under given load
692 SC_Pair SlewOut = { 0.0, 0.0 }; // output slew under zero load
693 pSlewOut->fall = pSlewOut->rise = 0;
694 assert( pCell->n_inputs == 1 );
695 Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut );
696 Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut );
697 pArrOut->fall = ArrOut1.fall - ArrOut0.fall;
698 pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
699}
700
712static inline int Scl_LibPinArrivalEstimateI( SC_Cell * pCell, int iPin, int Slew, int Load )
713{
714 int Arrray[4];
715 SC_PairI LoadIn = { Load, Load };
716 SC_PairI ArrIn = { 0, 0 };
717 SC_PairI ArrOut = { 0, 0 };
718 SC_PairI SlewIn = { 0, 0 };
719 SC_PairI SlewOut = { 0, 0 };
720// Vec_Flt_t * vIndex0 = pTime->pCellRise->vIndex0; // slew
721// SlewIn.fall = SlewIn.rise = Vec_FltEntry( vIndex0, Vec_FltSize(vIndex0)/2 );
722 SlewIn.fall = SlewIn.rise = Slew;
723 Scl_LibPinArrivalI( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut, Arrray );
724 return (ArrOut.fall + ArrOut.rise) >> 1;
725}
726static inline void Scl_LibHandleInputDriver2( SC_Cell * pCell, SC_PairI * pLoadIn, SC_PairI * pArrOut, SC_PairI * pSlewOut )
727{
728 int Arrray[4];
729 SC_PairI LoadIn = { 0, 0 }; // zero input load
730 SC_PairI ArrIn = { 0, 0 }; // zero input time
731 SC_PairI SlewIn = { 0, 0 }; // zero input slew
732 SC_PairI ArrOut0 = { 0, 0 }; // output time under zero load
733 SC_PairI ArrOut1 = { 0, 0 }; // output time under given load
734 SC_PairI SlewOut = { 0, 0 }; // output slew under zero load
735 pSlewOut->fall = pSlewOut->rise = 0;
736 assert( pCell->n_inputs == 1 );
737 Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut, Arrray );
738 Scl_LibPinArrivalI( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut, Arrray );
739 pArrOut->fall = ArrOut1.fall - ArrOut0.fall;
740 pArrOut->rise = ArrOut1.rise - ArrOut0.rise;
741}
742
743/*=== sclLiberty.c ===============================================================*/
744extern SC_Lib * Abc_SclReadLiberty( char * pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts );
745/*=== sclLibScl.c ===============================================================*/
746extern SC_Lib * Abc_SclReadFromGenlib( void * pLib );
747extern SC_Lib * Abc_SclReadFromStr( Vec_Str_t * vOut );
748extern SC_Lib * Abc_SclReadFromFile( char * pFileName );
749extern void Abc_SclWriteScl( char * pFileName, SC_Lib * p );
750extern void Abc_SclWriteLiberty( char * pFileName, SC_Lib * p );
751extern SC_Lib * Abc_SclMergeLibraries( SC_Lib * pLib1, SC_Lib * pLib2, int fUsePrefix );
752/*=== sclLibUtil.c ===============================================================*/
753extern void Abc_SclHashCells( SC_Lib * p );
754extern int Abc_SclCellFind( SC_Lib * p, char * pName );
755extern int Abc_SclClassCellNum( SC_Cell * pClass );
756extern void Abc_SclShortNames( SC_Lib * p );
757extern int Abc_SclLibClassNum( SC_Lib * pLib );
758extern void Abc_SclLinkCells( SC_Lib * p );
759extern void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain, int fInvOnly, int fShort );
760extern void Abc_SclConvertLeakageIntoArea( SC_Lib * p, float A, float B );
761extern void Abc_SclLibNormalize( SC_Lib * p );
762extern SC_Cell * Abc_SclFindInvertor( SC_Lib * p, int fFindBuff );
763extern SC_Cell * Abc_SclFindSmallestGate( SC_Cell * p, float CinMin );
764extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area );
765extern SC_WireLoad * Abc_SclFetchWireLoadModel( SC_Lib * p, char * pName );
766extern int Abc_SclHasDelayInfo( void * pScl );
767extern float Abc_SclComputeAverageSlew( SC_Lib * p );
768extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
769extern void Abc_SclInstallGenlib( void * pScl, float Slew, float Gain, int fUseAll, int nGatesMin );
770
771
773
774#endif
775
ABC_INT64_T iword
Definition abc_global.h:244
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Cube * p
Definition exorList.c:222
void Abc_SclWriteScl(char *pFileName, SC_Lib *p)
Definition sclLibScl.c:629
struct SC_SizePars_ SC_SizePars
Definition sclLib.h:82
#define SC_CellForEachPin(p, pPin, i)
Definition sclLib.h:274
#define SC_PinForEachRTiming(p, pRTime, i)
Definition sclLib.h:279
struct SC_Timing_ SC_Timing
Definition sclLib.h:124
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pName)
Definition sclLibUtil.c:365
SC_TSense
Definition sclLib.h:55
@ sc_ts_Neg
Definition sclLib.h:58
@ sc_ts_Non
Definition sclLib.h:59
@ sc_ts_NULL
Definition sclLib.h:56
@ sc_ts_Pos
Definition sclLib.h:57
#define SC_LibForEachCell(p, pCell, i)
Definition sclLib.h:269
int Abc_SclLibClassNum(SC_Lib *pLib)
Definition sclLibUtil.c:95
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition sclLibUtil.c:86
struct SC_DontUse_ SC_DontUse
Definition sclLib.h:62
struct SC_Lib_ SC_Lib
Definition sclLib.h:128
struct SC_Pair_ SC_Pair
Definition sclLib.h:69
SC_WireLoad * Abc_SclFindWireLoadModel(SC_Lib *p, float Area)
Definition sclLibUtil.c:382
SC_Lib * Abc_SclMergeLibraries(SC_Lib *pLib1, SC_Lib *pLib2, int fUsePrefix)
Definition sclLibScl.c:869
struct SC_BusPars_ SC_BusPars
Definition sclLib.h:102
struct SC_WireLoadSel_ SC_WireLoadSel
Definition sclLib.h:121
void Abc_SclWriteLiberty(char *pFileName, SC_Lib *p)
Definition sclLibScl.c:845
void Abc_SclShortNames(SC_Lib *p)
Definition sclLibUtil.c:195
void Abc_SclConvertLeakageIntoArea(SC_Lib *p, float A, float B)
Definition sclLibUtil.c:719
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition sclLibScl.c:403
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition sclLibUtil.c:332
void Abc_SclLibNormalize(SC_Lib *p)
Definition sclLibUtil.c:750
struct SC_Pin_ SC_Pin
Definition sclLib.h:126
#define SC_LibForEachTempl(p, pTempl, i)
Definition sclLib.h:273
struct SC_PairI_ SC_PairI
Definition sclLib.h:75
SC_Cell * Abc_SclFindSmallestGate(SC_Cell *p, float CinMin)
Definition sclLibUtil.c:343
SC_Dir
Definition sclLib.h:46
@ sc_dir_Output
Definition sclLib.h:49
@ sc_dir_Internal
Definition sclLib.h:51
@ sc_dir_InOut
Definition sclLib.h:50
@ sc_dir_NULL
Definition sclLib.h:47
@ sc_dir_Input
Definition sclLib.h:48
SC_Lib * Abc_SclReadFromGenlib(void *pLib)
Definition sclLibScl.c:169
#define SC_LibForEachWireLoadSel(p, pWLS, i)
Definition sclLib.h:272
SC_Lib * Abc_SclReadFromFile(char *pFileName)
Definition sclLibScl.c:417
struct SC_Timings_ SC_Timings
Definition sclLib.h:125
void Abc_SclHashCells(SC_Lib *p)
Definition sclLibUtil.c:65
void Abc_SclLinkCells(SC_Lib *p)
Definition sclLibUtil.c:264
#define SC_LibForEachWireLoad(p, pWL, i)
Definition sclLib.h:271
struct SC_Surface_ SC_Surface
Definition sclLib.h:123
struct SC_WireLoad_ SC_WireLoad
STRUCTURE DEFINITIONS ///.
Definition sclLib.h:120
void Abc_SclPrintCells(SC_Lib *p, float Slew, float Gain, int fInvOnly, int fShort)
Definition sclLibUtil.c:638
struct SC_Cell_ SC_Cell
Definition sclLib.h:127
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition sclLibUtil.c:452
void Abc_SclInstallGenlib(void *pScl, float Slew, float Gain, int fUseAll, int nGatesMin)
struct SC_TableTempl_ SC_TableTempl
Definition sclLib.h:122
int Abc_SclHasDelayInfo(void *pScl)
Definition sclLibUtil.c:427
void Abc_SclDumpGenlib(char *pFileName, SC_Lib *p, float Slew, float Gain, int nGatesMin)
SC_Lib * Abc_SclReadLiberty(char *pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts)
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition sclLibUtil.c:81
int fBufPis
Definition sclLib.h:110
int fUseWireLoads
Definition sclLib.h:111
int nDegree
Definition sclLib.h:107
int fVeryVerbose
Definition sclLib.h:113
int fVerbose
Definition sclLib.h:112
int fAddBufs
Definition sclLib.h:109
int fSizeOnly
Definition sclLib.h:108
int GainRatio
Definition sclLib.h:105
SC_Cell * pNext
Definition sclLib.h:215
float area
Definition sclLib.h:207
int n_outputs
Definition sclLib.h:214
SC_Cell * pAve
Definition sclLib.h:218
char * pName
Definition sclLib.h:202
int fSkip
Definition sclLib.h:204
int drive_strength
Definition sclLib.h:211
int areaI
Definition sclLib.h:209
Vec_Ptr_t vPins
Definition sclLib.h:212
int n_inputs
Definition sclLib.h:213
int seq
Definition sclLib.h:205
SC_Cell * pPrev
Definition sclLib.h:216
int Id
Definition sclLib.h:203
int nGates
Definition sclLib.h:220
float leakage
Definition sclLib.h:208
SC_Cell * pRepr
Definition sclLib.h:217
int Order
Definition sclLib.h:219
int leakageI
Definition sclLib.h:210
int unsupp
Definition sclLib.h:206
int size
Definition sclLib.h:65
char ** dont_use_list
Definition sclLib.h:66
char * default_wire_load_sel
Definition sclLib.h:228
int * pBins
Definition sclLib.h:238
float unit_cap_fst
Definition sclLib.h:231
Vec_Ptr_t vCells
Definition sclLib.h:236
char * default_wire_load
Definition sclLib.h:227
char * pFileName
Definition sclLib.h:226
int unit_time
Definition sclLib.h:230
Vec_Ptr_t vCellClasses
Definition sclLib.h:237
Vec_Ptr_t vWireLoadSels
Definition sclLib.h:234
Vec_Ptr_t vWireLoads
Definition sclLib.h:233
int unit_cap_snd
Definition sclLib.h:232
int nBins
Definition sclLib.h:239
float default_max_out_slew
Definition sclLib.h:229
char * pName
Definition sclLib.h:225
Vec_Ptr_t vTempls
Definition sclLib.h:235
int fall
Definition sclLib.h:79
int rise
Definition sclLib.h:78
float fall
Definition sclLib.h:73
float rise
Definition sclLib.h:72
SC_Dir dir
Definition sclLib.h:186
float max_out_cap
Definition sclLib.h:192
int rise_capI
Definition sclLib.h:190
float rise_cap
Definition sclLib.h:188
float fall_cap
Definition sclLib.h:189
char * pName
Definition sclLib.h:185
char * func_text
Definition sclLib.h:194
Vec_Wrd_t vFunc
Definition sclLib.h:195
int fall_capI
Definition sclLib.h:191
float cap
Definition sclLib.h:187
float max_out_slew
Definition sclLib.h:193
Vec_Ptr_t vRTimings
Definition sclLib.h:196
int BypassFreq
Definition sclLib.h:94
int DelayUser
Definition sclLib.h:90
int fDumpStats
Definition sclLib.h:96
int Notches
Definition sclLib.h:89
int nIterNoChange
Definition sclLib.h:86
int fUseDept
Definition sclLib.h:95
int nIters
Definition sclLib.h:85
int fVerbose
Definition sclLib.h:98
int fVeryVerbose
Definition sclLib.h:99
int DelayGap
Definition sclLib.h:91
int BuffTreeEst
Definition sclLib.h:93
int Ratio
Definition sclLib.h:88
int Window
Definition sclLib.h:87
int TimeOut
Definition sclLib.h:92
int fUseWireLoads
Definition sclLib.h:97
Vec_Int_t vIndex1I
Definition sclLib.h:161
Vec_Flt_t vIndex0
Definition sclLib.h:157
char * pName
Definition sclLib.h:156
float approx[3][6]
Definition sclLib.h:163
Vec_Ptr_t vData
Definition sclLib.h:159
Vec_Ptr_t vDataI
Definition sclLib.h:162
Vec_Flt_t vIndex1
Definition sclLib.h:158
Vec_Int_t vIndex0I
Definition sclLib.h:160
Vec_Ptr_t vVars
Definition sclLib.h:150
char * pName
Definition sclLib.h:149
Vec_Ptr_t vIndex
Definition sclLib.h:151
SC_Surface pRiseTrans
Definition sclLib.h:173
SC_TSense tsense
Definition sclLib.h:169
char * related_pin
Definition sclLib.h:168
SC_Surface pCellRise
Definition sclLib.h:171
char * when_text
Definition sclLib.h:170
SC_Surface pFallTrans
Definition sclLib.h:174
SC_Surface pCellFall
Definition sclLib.h:172
char * pName
Definition sclLib.h:179
Vec_Ptr_t vTimings
Definition sclLib.h:180
Vec_Flt_t vAreaFrom
Definition sclLib.h:142
char * pName
Definition sclLib.h:141
Vec_Flt_t vAreaTo
Definition sclLib.h:143
Vec_Ptr_t vWireLoadModel
Definition sclLib.h:144
float cap
Definition sclLib.h:133
char * pName
Definition sclLib.h:132
Vec_Int_t vFanout
Definition sclLib.h:135
float slope
Definition sclLib.h:134
Vec_Flt_t vLen
Definition sclLib.h:136
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition vecFlt.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42