21#ifndef ABC__map__scl__sclLib_h
22#define ABC__map__scl__sclLib_h
43#define ABC_SCL_CUR_VERSION 8
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; }
260static inline int SC_LibCellNum(
SC_Lib *
p ) {
return Vec_PtrSize(&
p->vCells); }
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; }
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 )
315static inline SC_Surface * Abc_SclSurfaceAlloc()
321static inline SC_Timing * Abc_SclTimingAlloc()
327static inline SC_Timings * Abc_SclTimingsAlloc()
333static inline SC_Pin * Abc_SclPinAlloc()
337 p->max_out_slew = -1;
340static inline SC_Cell * Abc_SclCellAlloc()
346static inline SC_Lib * Abc_SclLibAlloc()
350 p->default_max_out_slew = -1;
353 p->unit_cap_snd = 12;
369static inline void Abc_SclWireLoadFree(
SC_WireLoad *
p )
371 Vec_IntErase( &
p->vFanout );
372 Vec_FltErase( &
p->vLen );
378 Vec_FltErase( &
p->vAreaFrom );
379 Vec_FltErase( &
p->vAreaTo );
380 Vec_PtrFreeData( &
p->vWireLoadModel );
381 Vec_PtrErase( &
p->vWireLoadModel );
387 Vec_PtrFreeData( &
p->vVars );
388 Vec_PtrErase( &
p->vVars );
393static inline void Abc_SclSurfaceFree(
SC_Surface *
p )
395 Vec_FltErase( &
p->vIndex0 );
396 Vec_FltErase( &
p->vIndex1 );
397 Vec_IntErase( &
p->vIndex0I );
398 Vec_IntErase( &
p->vIndex1I );
404static inline void Abc_SclTimingFree(
SC_Timing *
p )
406 Abc_SclSurfaceFree( &
p->pCellRise );
407 Abc_SclSurfaceFree( &
p->pCellFall );
408 Abc_SclSurfaceFree( &
p->pRiseTrans );
409 Abc_SclSurfaceFree( &
p->pFallTrans );
414static inline void Abc_SclTimingsFree(
SC_Timings *
p )
419 Abc_SclTimingFree( pTemp );
420 Vec_PtrErase( &
p->vTimings );
424static inline void Abc_SclPinFree(
SC_Pin *
p )
429 Abc_SclTimingsFree( pTemp );
430 Vec_PtrErase( &
p->vRTimings );
431 Vec_WrdErase( &
p->vFunc );
436static inline void Abc_SclCellFree(
SC_Cell *
p )
441 Abc_SclPinFree( pTemp );
442 Vec_PtrErase( &
p->vPins );
446static inline void Abc_SclLibFree(
SC_Lib *
p )
454 Abc_SclWireLoadFree( pWL );
455 Vec_PtrErase( &
p->vWireLoads );
457 Abc_SclWireLoadSelFree( pWLS );
458 Vec_PtrErase( &
p->vWireLoadSels );
460 Abc_SclTableTemplFree( pTempl );
461 Vec_PtrErase( &
p->vTempls );
463 Abc_SclCellFree( pCell );
464 Vec_PtrErase( &
p->vCells );
465 Vec_PtrErase( &
p->vCellClasses );
486static inline float Scl_LibLookup(
SC_Surface *
p,
float slew,
float load )
488 float * pIndex0, * pIndex1, * pDataS, * pDataS1;
489 float sfrac, lfrac, p0, p1;
493 if ( Vec_FltSize(&
p->vIndex0) == 1 && Vec_FltSize(&
p->vIndex1) == 1 )
496 assert( Vec_PtrSize(&
p->vData) == 1 );
497 assert( Vec_FltSize(vTemp) == 1 );
498 return Vec_FltEntry(vTemp, 0);
502 pIndex0 = Vec_FltArray(&
p->vIndex0);
503 for ( s = 1; s < Vec_FltSize(&
p->vIndex0)-1; s++ )
504 if ( pIndex0[s] > slew )
508 pIndex1 = Vec_FltArray(&
p->vIndex1);
509 for ( l = 1; l < Vec_FltSize(&
p->vIndex1)-1; l++ )
510 if ( pIndex1[l] > load )
515 sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
516 lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
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) );
521 p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
522 p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
524 return p0 + sfrac * (p1 - p0);
568static inline int Scl_LibLookupI(
SC_Surface *
p,
int slew,
int load )
570 int * pIndex0, * pIndex1, * pDataS, * pDataS1;
572 iword lFrac0, lFrac1, sFrac;
575 if ( Vec_IntSize(&
p->vIndex0I) == 1 && Vec_IntSize(&
p->vIndex1I) == 1 )
578 assert( Vec_PtrSize(&
p->vDataI) == 1 );
579 assert( Vec_IntSize(vTemp) == 1 );
580 return Vec_IntEntry(vTemp, 0);
584 pIndex0 = Vec_IntArray(&
p->vIndex0I);
585 for ( s = 1; s < Vec_IntSize(&
p->vIndex0I)-1; s++ )
586 if ( pIndex0[s] > slew )
590 pIndex1 = Vec_IntArray(&
p->vIndex1I);
591 for ( l = 1; l < Vec_IntSize(&
p->vIndex1I)-1; l++ )
592 if ( pIndex1[l] > load )
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) );
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]);
609 p0 = pDataS [l] + (int)lFrac0;
610 p1 = pDataS1[l] + (int)lFrac1;
612 sFrac = (
iword)(p1 - p0) * (
iword)(slew - pIndex0[s]) / (
iword)(pIndex0[s+1] - pIndex0[s]);
615 return p0 + (int)sFrac;
638 pReqIn->
rise = Abc_MinInt( pReqIn->
rise, pReqOut->
rise - pArray[0] );
639 pReqIn->
fall = Abc_MinInt( pReqIn->
fall, pReqOut->
fall - pArray[1] );
643 pReqIn->
fall = Abc_MinInt( pReqIn->
fall, pReqOut->
rise - pArray[2] );
644 pReqIn->
rise = Abc_MinInt( pReqIn->
rise, pReqOut->
fall - pArray[3] );
663 assert( iPin >= 0 && iPin < pCell->n_inputs );
664 pPin = SC_CellPin( pCell, pCell->
n_inputs );
667 if ( Vec_PtrSize(&pRTime->
vTimings) == 0 )
672static inline float Scl_LibPinArrivalEstimate(
SC_Cell * pCell,
int iPin,
float Slew,
float Load )
674 SC_Pair LoadIn = { Load, Load };
678 SC_Pair SlewOut = { 0.0, 0.0 };
682 Scl_LibPinArrival( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut );
683 return 0.5 * ArrOut.
fall + 0.5 * ArrOut.
rise;
690 SC_Pair ArrOut0 = { 0.0, 0.0 };
691 SC_Pair ArrOut1 = { 0.0, 0.0 };
692 SC_Pair SlewOut = { 0.0, 0.0 };
693 pSlewOut->
fall = pSlewOut->
rise = 0;
695 Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, &LoadIn, &ArrOut0, &SlewOut );
696 Scl_LibPinArrival( Scl_CellPinTime(pCell, 0), &ArrIn, &SlewIn, pLoadIn, &ArrOut1, pSlewOut );
712static inline int Scl_LibPinArrivalEstimateI(
SC_Cell * pCell,
int iPin,
int Slew,
int Load )
723 Scl_LibPinArrivalI( Scl_CellPinTime(pCell, iPin), &ArrIn, &SlewIn, &LoadIn, &ArrOut, &SlewOut, Arrray );
724 return (ArrOut.
fall + ArrOut.
rise) >> 1;
735 pSlewOut->
fall = pSlewOut->
rise = 0;
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 );
769extern void Abc_SclInstallGenlib(
void * pScl,
float Slew,
float Gain,
int fUseAll,
int nGatesMin );
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
void Abc_SclWriteScl(char *pFileName, SC_Lib *p)
struct SC_SizePars_ SC_SizePars
#define SC_CellForEachPin(p, pPin, i)
#define SC_PinForEachRTiming(p, pRTime, i)
struct SC_Timing_ SC_Timing
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pName)
#define SC_LibForEachCell(p, pCell, i)
int Abc_SclLibClassNum(SC_Lib *pLib)
int Abc_SclClassCellNum(SC_Cell *pClass)
struct SC_DontUse_ SC_DontUse
SC_WireLoad * Abc_SclFindWireLoadModel(SC_Lib *p, float Area)
SC_Lib * Abc_SclMergeLibraries(SC_Lib *pLib1, SC_Lib *pLib2, int fUsePrefix)
struct SC_BusPars_ SC_BusPars
struct SC_WireLoadSel_ SC_WireLoadSel
void Abc_SclWriteLiberty(char *pFileName, SC_Lib *p)
void Abc_SclShortNames(SC_Lib *p)
void Abc_SclConvertLeakageIntoArea(SC_Lib *p, float A, float B)
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
void Abc_SclLibNormalize(SC_Lib *p)
#define SC_LibForEachTempl(p, pTempl, i)
struct SC_PairI_ SC_PairI
SC_Cell * Abc_SclFindSmallestGate(SC_Cell *p, float CinMin)
SC_Lib * Abc_SclReadFromGenlib(void *pLib)
#define SC_LibForEachWireLoadSel(p, pWLS, i)
SC_Lib * Abc_SclReadFromFile(char *pFileName)
struct SC_Timings_ SC_Timings
void Abc_SclHashCells(SC_Lib *p)
void Abc_SclLinkCells(SC_Lib *p)
#define SC_LibForEachWireLoad(p, pWL, i)
struct SC_Surface_ SC_Surface
struct SC_WireLoad_ SC_WireLoad
STRUCTURE DEFINITIONS ///.
void Abc_SclPrintCells(SC_Lib *p, float Slew, float Gain, int fInvOnly, int fShort)
float Abc_SclComputeAverageSlew(SC_Lib *p)
void Abc_SclInstallGenlib(void *pScl, float Slew, float Gain, int fUseAll, int nGatesMin)
struct SC_TableTempl_ SC_TableTempl
int Abc_SclHasDelayInfo(void *pScl)
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)
char * default_wire_load_sel
float default_max_out_slew
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.