abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclLib.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "misc/vec/vec.h"

Go to the source code of this file.

Data Structures

struct  SC_Pair_
 
struct  SC_SizePars_
 
struct  SC_BusPars_
 
struct  SC_WireLoad_
 
struct  SC_WireLoadSel_
 
struct  SC_TableTempl_
 
struct  SC_Surface_
 
struct  SC_Timing_
 
struct  SC_Timings_
 
struct  SC_Pin_
 
struct  SC_Cell_
 
struct  SC_Lib_
 

Macros

#define ABC_SCL_CUR_VERSION   8
 INCLUDES ///. More...
 
#define SC_LibForEachCell(p, pCell, i)   Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i )
 
#define SC_LibForEachCellClass(p, pCell, i)   Vec_PtrForEachEntry( SC_Cell *, p->vCellClasses, pCell, i )
 
#define SC_LibForEachWireLoad(p, pWL, i)   Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i )
 
#define SC_LibForEachWireLoadSel(p, pWLS, i)   Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i )
 
#define SC_LibForEachTempl(p, pTempl, i)   Vec_PtrForEachEntry( SC_TableTempl *, p->vTempls, pTempl, i )
 
#define SC_CellForEachPin(p, pPin, i)   Vec_PtrForEachEntry( SC_Pin *, p->vPins, pPin, i )
 
#define SC_CellForEachPinIn(p, pPin, i)   Vec_PtrForEachEntryStop( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
 
#define SC_CellForEachPinOut(p, pPin, i)   Vec_PtrForEachEntryStart( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
 
#define SC_RingForEachCell(pRing, pCell, i)   for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pNext, i++ )
 
#define SC_RingForEachCellRev(pRing, pCell, i)   for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pPrev, i++ )
 
#define SC_PinForEachRTiming(p, pRTime, i)   Vec_PtrForEachEntry( SC_Timings *, p->vRTimings, pRTime, i )
 

Typedefs

typedef struct SC_Pair_ SC_Pair
 
typedef struct SC_SizePars_ SC_SizePars
 
typedef struct SC_BusPars_ SC_BusPars
 
typedef struct SC_WireLoad_ SC_WireLoad
 STRUCTURE DEFINITIONS ///. More...
 
typedef struct SC_WireLoadSel_ SC_WireLoadSel
 
typedef struct SC_TableTempl_ SC_TableTempl
 
typedef struct SC_Surface_ SC_Surface
 
typedef struct SC_Timing_ SC_Timing
 
typedef struct SC_Timings_ SC_Timings
 
typedef struct SC_Pin_ SC_Pin
 
typedef struct SC_Cell_ SC_Cell
 
typedef struct SC_Lib_ SC_Lib
 

Enumerations

enum  SC_Dir {
  sc_dir_NULL, sc_dir_Input, sc_dir_Output, sc_dir_InOut,
  sc_dir_Internal
}
 
enum  SC_TSense { sc_ts_NULL, sc_ts_Pos, sc_ts_Neg, sc_ts_Non }
 

Functions

static void SC_PairClean (SC_Pair *d)
 GLOBAL VARIABLES ///. More...
 
static float SC_PairMax (SC_Pair *d)
 
static float SC_PairMin (SC_Pair *d)
 
static float SC_PairAve (SC_Pair *d)
 
static void SC_PairDup (SC_Pair *d, SC_Pair *s)
 
static void SC_PairMove (SC_Pair *d, SC_Pair *s)
 
static void SC_PairAdd (SC_Pair *d, SC_Pair *s)
 
static int SC_PairEqual (SC_Pair *d, SC_Pair *s)
 
static int SC_PairEqualE (SC_Pair *d, SC_Pair *s, float E)
 
static int SC_LibCellNum (SC_Lib *p)
 
static SC_CellSC_LibCell (SC_Lib *p, int i)
 
static SC_PinSC_CellPin (SC_Cell *p, int i)
 
static Vec_Wrd_tSC_CellFunc (SC_Cell *p)
 
static float SC_CellPinCap (SC_Cell *p, int i)
 
static float SC_CellPinCapAve (SC_Cell *p)
 
static char * SC_CellPinOutFunc (SC_Cell *p, int i)
 
static char * SC_CellPinName (SC_Cell *p, int i)
 
static SC_WireLoadAbc_SclWireLoadAlloc ()
 FUNCTION DEFINITIONS ///. More...
 
static SC_WireLoadSelAbc_SclWireLoadSelAlloc ()
 
static SC_TableTemplAbc_SclTableTemplAlloc ()
 
static SC_SurfaceAbc_SclSurfaceAlloc ()
 
static SC_TimingAbc_SclTimingAlloc ()
 
static SC_TimingsAbc_SclTimingsAlloc ()
 
static SC_PinAbc_SclPinAlloc ()
 
static SC_CellAbc_SclCellAlloc ()
 
static SC_LibAbc_SclLibAlloc ()
 
static void Abc_SclWireLoadFree (SC_WireLoad *p)
 
static void Abc_SclWireLoadSelFree (SC_WireLoadSel *p)
 
static void Abc_SclTableTemplFree (SC_TableTempl *p)
 
static void Abc_SclSurfaceFree (SC_Surface *p)
 
static void Abc_SclTimingFree (SC_Timing *p)
 
static void Abc_SclTimingsFree (SC_Timings *p)
 
static void Abc_SclPinFree (SC_Pin *p)
 
static void Abc_SclCellFree (SC_Cell *p)
 
static void Abc_SclLibFree (SC_Lib *p)
 
static float Scl_LibLookup (SC_Surface *p, float slew, float load)
 
static void Scl_LibPinArrival (SC_Timing *pTime, SC_Pair *pArrIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pArrOut, SC_Pair *pSlewOut)
 
static void Scl_LibPinDeparture (SC_Timing *pTime, SC_Pair *pDepIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pDepOut)
 
static SC_TimingScl_CellPinTime (SC_Cell *pCell, int iPin)
 
static float Scl_LibPinArrivalEstimate (SC_Cell *pCell, int iPin, float Slew, float Load)
 
static void Scl_LibHandleInputDriver (SC_Cell *pCell, SC_Pair *pLoadIn, SC_Pair *pArrOut, SC_Pair *pSlewOut)
 
SC_LibAbc_SclReadLiberty (char *pFileName, int fVerbose, int fVeryVerbose)
 
SC_LibAbc_SclReadFromStr (Vec_Str_t *vOut)
 
SC_LibAbc_SclReadFromFile (char *pFileName)
 
void Abc_SclWriteScl (char *pFileName, SC_Lib *p)
 
void Abc_SclWriteLiberty (char *pFileName, SC_Lib *p)
 
void Abc_SclHashCells (SC_Lib *p)
 
int Abc_SclCellFind (SC_Lib *p, char *pName)
 
int Abc_SclClassCellNum (SC_Cell *pClass)
 
int Abc_SclLibClassNum (SC_Lib *pLib)
 
void Abc_SclLinkCells (SC_Lib *p)
 
void Abc_SclPrintCells (SC_Lib *p, float Slew, float Gain, int fInvOnly, int fShort)
 
void Abc_SclConvertLeakageIntoArea (SC_Lib *p, float A, float B)
 
void Abc_SclLibNormalize (SC_Lib *p)
 
SC_CellAbc_SclFindInvertor (SC_Lib *p, int fFindBuff)
 
SC_CellAbc_SclFindSmallestGate (SC_Cell *p, float CinMin)
 
SC_WireLoadAbc_SclFindWireLoadModel (SC_Lib *p, float Area)
 
SC_WireLoadAbc_SclFetchWireLoadModel (SC_Lib *p, char *pName)
 
int Abc_SclHasDelayInfo (void *pScl)
 
float Abc_SclComputeAverageSlew (SC_Lib *p)
 
void Abc_SclDumpGenlib (char *pFileName, SC_Lib *p, float Slew, float Gain, int nGatesMin)
 
void Abc_SclInstallGenlib (void *pScl, float Slew, float Gain, int nGatesMin)
 

Macro Definition Documentation

#define ABC_SCL_CUR_VERSION   8

INCLUDES ///.

CFile****************************************************************

FileName [sclLib.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Standard-cell library representation.]

Synopsis [Simplified library representation for STA.]

Author [Alan Mishchenko, Niklas Een]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - August 24, 2012.]

Revision [

Id:
sclLib.h,v 1.0 2012/08/24 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 43 of file sclLib.h.

#define SC_CellForEachPin (   p,
  pPin,
 
)    Vec_PtrForEachEntry( SC_Pin *, p->vPins, pPin, i )

Definition at line 253 of file sclLib.h.

#define SC_CellForEachPinIn (   p,
  pPin,
 
)    Vec_PtrForEachEntryStop( SC_Pin *, p->vPins, pPin, i, p->n_inputs )

Definition at line 254 of file sclLib.h.

#define SC_CellForEachPinOut (   p,
  pPin,
 
)    Vec_PtrForEachEntryStart( SC_Pin *, p->vPins, pPin, i, p->n_inputs )

Definition at line 255 of file sclLib.h.

#define SC_LibForEachCell (   p,
  pCell,
 
)    Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i )

Definition at line 248 of file sclLib.h.

#define SC_LibForEachCellClass (   p,
  pCell,
 
)    Vec_PtrForEachEntry( SC_Cell *, p->vCellClasses, pCell, i )

Definition at line 249 of file sclLib.h.

#define SC_LibForEachTempl (   p,
  pTempl,
 
)    Vec_PtrForEachEntry( SC_TableTempl *, p->vTempls, pTempl, i )

Definition at line 252 of file sclLib.h.

#define SC_LibForEachWireLoad (   p,
  pWL,
 
)    Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i )

Definition at line 250 of file sclLib.h.

#define SC_LibForEachWireLoadSel (   p,
  pWLS,
 
)    Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i )

Definition at line 251 of file sclLib.h.

#define SC_PinForEachRTiming (   p,
  pRTime,
 
)    Vec_PtrForEachEntry( SC_Timings *, p->vRTimings, pRTime, i )

Definition at line 258 of file sclLib.h.

#define SC_RingForEachCell (   pRing,
  pCell,
 
)    for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pNext, i++ )

Definition at line 256 of file sclLib.h.

#define SC_RingForEachCellRev (   pRing,
  pCell,
 
)    for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pPrev, i++ )

Definition at line 257 of file sclLib.h.

Typedef Documentation

typedef struct SC_BusPars_ SC_BusPars

Definition at line 89 of file sclLib.h.

typedef struct SC_Cell_ SC_Cell

Definition at line 114 of file sclLib.h.

typedef struct SC_Lib_ SC_Lib

Definition at line 115 of file sclLib.h.

typedef struct SC_Pair_ SC_Pair

Definition at line 62 of file sclLib.h.

typedef struct SC_Pin_ SC_Pin

Definition at line 113 of file sclLib.h.

typedef struct SC_SizePars_ SC_SizePars

Definition at line 69 of file sclLib.h.

typedef struct SC_Surface_ SC_Surface

Definition at line 110 of file sclLib.h.

typedef struct SC_TableTempl_ SC_TableTempl

Definition at line 109 of file sclLib.h.

typedef struct SC_Timing_ SC_Timing

Definition at line 111 of file sclLib.h.

typedef struct SC_Timings_ SC_Timings

Definition at line 112 of file sclLib.h.

typedef struct SC_WireLoad_ SC_WireLoad

STRUCTURE DEFINITIONS ///.

Definition at line 107 of file sclLib.h.

Definition at line 108 of file sclLib.h.

Enumeration Type Documentation

enum SC_Dir
Enumerator
sc_dir_NULL 
sc_dir_Input 
sc_dir_Output 
sc_dir_InOut 
sc_dir_Internal 

Definition at line 45 of file sclLib.h.

enum SC_TSense
Enumerator
sc_ts_NULL 
sc_ts_Pos 
sc_ts_Neg 
sc_ts_Non 

Definition at line 54 of file sclLib.h.

55 {
56  sc_ts_NULL,
57  sc_ts_Pos,
58  sc_ts_Neg,
59  sc_ts_Non,
60 } SC_TSense;
SC_TSense
Definition: sclLib.h:54

Function Documentation

static SC_Cell* Abc_SclCellAlloc ( )
inlinestatic

Definition at line 336 of file sclLib.h.

337 {
338  SC_Cell * p;
339  p = ABC_CALLOC( SC_Cell, 1 );
340  p->vPins = Vec_PtrAlloc( 0 );
341  return p;
342 }
Vec_Ptr_t * vPins
Definition: sclLib.h:191
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int Abc_SclCellFind ( SC_Lib p,
char *  pName 
)

Definition at line 79 of file sclLibUtil.c.

80 {
81  int *pPlace = Abc_SclHashLookup( p, pName );
82  return pPlace ? *pPlace : -1;
83 }
int * Abc_SclHashLookup(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:56
static void Abc_SclCellFree ( SC_Cell p)
inlinestatic

Definition at line 433 of file sclLib.h.

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 }
#define SC_CellForEachPin(p, pPin, i)
Definition: sclLib.h:253
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Abc_SclPinFree(SC_Pin *p)
Definition: sclLib.h:421
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_SclClassCellNum ( SC_Cell pClass)

Definition at line 84 of file sclLibUtil.c.

85 {
86  SC_Cell * pCell;
87  int i, Count = 0;
88  SC_RingForEachCell( pClass, pCell, i )
89  if ( !pCell->fSkip )
90  Count++;
91  return Count;
92 }
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
if(last==0)
Definition: sparse_int.h:34
float Abc_SclComputeAverageSlew ( SC_Lib p)

Function*************************************************************

Synopsis [Returns "average" slew.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file sclLibUtil.c.

318 {
319  SC_Cell * pCell;
320  SC_Timing * pTime;
321  Vec_Flt_t * vIndex;
322  pCell = Abc_SclFindInvertor(p, 0);
323  if ( pCell == NULL )
324  return 0;
325  pTime = Scl_CellPinTime( pCell, 0 );
326  if ( pTime == NULL )
327  return 0;
328  vIndex = pTime->pCellRise->vIndex0; // slew
329  return Vec_FltEntry( vIndex, Vec_FltSize(vIndex)/3 );
330 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition: sclLibUtil.c:197
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
void Abc_SclConvertLeakageIntoArea ( SC_Lib p,
float  A,
float  B 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 584 of file sclLibUtil.c.

585 {
586  SC_Cell * pCell; int i;
587  SC_LibForEachCell( p, pCell, i )
588  pCell->area = A * pCell->area + B * pCell->leakage;
589 }
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
void Abc_SclDumpGenlib ( char *  pFileName,
SC_Lib p,
float  Slew,
float  Gain,
int  nGatesMin 
)

Definition at line 795 of file sclLibUtil.c.

796 {
797  int nCellCount = 0;
798  char FileName[1000];
799  float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
800  Vec_Str_t * vStr;
801  FILE * pFile;
802  if ( pFileName == NULL )
803  sprintf( FileName, "%s_s%03d_g%03d_m%d.genlib", p->pName, (int)Slew, (int)Gain, nGatesMin );
804  else
805  sprintf( FileName, "%s", pFileName );
806  pFile = fopen( FileName, "wb" );
807  if ( pFile == NULL )
808  {
809  printf( "Cannot open file \"%s\" for writing.\n", FileName );
810  return;
811  }
812  vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
813  fprintf( pFile, "%s", Vec_StrArray(vStr) );
814  Vec_StrFree( vStr );
815  fclose( pFile );
816  printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName );
817 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
char * sprintf()
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition: sclLibUtil.c:317
Vec_Str_t * Abc_SclProduceGenlibStr(SC_Lib *p, float Slew, float Gain, int nGatesMin, int *pnCellCount)
Definition: sclLibUtil.c:735
char * pName
Definition: sclLib.h:204
SC_WireLoad* Abc_SclFetchWireLoadModel ( SC_Lib p,
char *  pWLoadUsed 
)

Function*************************************************************

Synopsis [Returns the wireload model for the given area.]

Description []

SideEffects []

SeeAlso []

Definition at line 230 of file sclLibUtil.c.

231 {
232  SC_WireLoad * pWL = NULL;
233  int i;
234  // Get the actual table and reformat it for 'wire_cap' output:
235  assert( pWLoadUsed != NULL );
236  SC_LibForEachWireLoad( p, pWL, i )
237  if ( !strcmp(pWL->pName, pWLoadUsed) )
238  break;
239  if ( i == Vec_PtrSize(p->vWireLoads) )
240  {
241  Abc_Print( -1, "Cannot find wire load model \"%s\".\n", pWLoadUsed );
242  exit(1);
243  }
244 // printf( "Using wireload model \"%s\".\n", pWL->pName );
245  return pWL;
246 }
VOID_HACK exit()
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int strcmp()
if(last==0)
Definition: sparse_int.h:34
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define SC_LibForEachWireLoad(p, pWL, i)
Definition: sclLib.h:250
#define assert(ex)
Definition: util_old.h:213
SC_Cell* Abc_SclFindInvertor ( SC_Lib p,
int  fFindBuff 
)

Function*************************************************************

Synopsis [Returns the largest inverter.]

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file sclLibUtil.c.

198 {
199  SC_Cell * pCell = NULL;
200  word Truth = fFindBuff ? ABC_CONST(0xAAAAAAAAAAAAAAAA) : ABC_CONST(0x5555555555555555);
201  int k;
202  SC_LibForEachCellClass( p, pCell, k )
203  if ( pCell->n_inputs == 1 && Vec_WrdEntry(SC_CellPin(pCell, 1)->vFunc, 0) == Truth )
204  break;
205  // take representative
206  return pCell ? pCell->pRepr : NULL;
207 }
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
if(last==0)
Definition: sparse_int.h:34
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
static word Vec_WrdEntry(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:384
SC_Cell* Abc_SclFindSmallestGate ( SC_Cell p,
float  CinMin 
)

Definition at line 208 of file sclLibUtil.c.

209 {
210  SC_Cell * pRes = NULL;
211  int i;
212  SC_RingForEachCell( p->pRepr, pRes, i )
213  if ( SC_CellPinCapAve(pRes) > CinMin )
214  return pRes;
215  // take the largest gate
216  return p->pRepr->pPrev;
217 }
SC_Cell * pRepr
Definition: sclLib.h:196
static float SC_CellPinCapAve(SC_Cell *p)
Definition: sclLib.h:244
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
if(last==0)
Definition: sparse_int.h:34
SC_WireLoad* Abc_SclFindWireLoadModel ( SC_Lib p,
float  Area 
)

Definition at line 247 of file sclLibUtil.c.

248 {
249  char * pWLoadUsed = NULL;
250  int i;
252  {
253  SC_WireLoadSel * pWLS = NULL;
254  SC_LibForEachWireLoadSel( p, pWLS, i )
255  if ( !strcmp(pWLS->pName, p->default_wire_load_sel) )
256  break;
257  if ( i == Vec_PtrSize(p->vWireLoadSels) )
258  {
259  Abc_Print( -1, "Cannot find wire load selection model \"%s\".\n", p->default_wire_load_sel );
260  exit(1);
261  }
262  for ( i = 0; i < Vec_FltSize(pWLS->vAreaFrom); i++)
263  if ( Area >= Vec_FltEntry(pWLS->vAreaFrom, i) && Area < Vec_FltEntry(pWLS->vAreaTo, i) )
264  {
265  pWLoadUsed = (char *)Vec_PtrEntry(pWLS->vWireLoadModel, i);
266  break;
267  }
268  if ( i == Vec_FltSize(pWLS->vAreaFrom) )
269  pWLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel);
270  }
271  else if ( p->default_wire_load && strlen(p->default_wire_load) )
272  pWLoadUsed = p->default_wire_load;
273  else
274  {
275 // Abc_Print( 0, "No wire model given.\n" );
276  return NULL;
277  }
278  return Abc_SclFetchWireLoadModel( p, pWLoadUsed );
279 }
VOID_HACK exit()
char * default_wire_load
Definition: sclLib.h:206
Vec_Flt_t * vAreaTo
Definition: sclLib.h:130
Vec_Ptr_t * vWireLoadModel
Definition: sclLib.h:131
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pWLoadUsed)
Definition: sclLibUtil.c:230
int strcmp()
#define SC_LibForEachWireLoadSel(p, pWLS, i)
Definition: sclLib.h:251
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
if(last==0)
Definition: sparse_int.h:34
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int strlen()
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
Vec_Flt_t * vAreaFrom
Definition: sclLib.h:129
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
char * default_wire_load_sel
Definition: sclLib.h:207
int Abc_SclHasDelayInfo ( void *  pScl)

Function*************************************************************

Synopsis [Returns 1 if the library has delay info.]

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file sclLibUtil.c.

293 {
294  SC_Lib * p = (SC_Lib *)pScl;
295  SC_Cell * pCell;
296  SC_Timing * pTime;
297  pCell = Abc_SclFindInvertor(p, 0);
298  if ( pCell == NULL )
299  return 0;
300  pTime = Scl_CellPinTime( pCell, 0 );
301  if ( pTime == NULL )
302  return 0;
303  return 1;
304 }
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
static Llb_Mgr_t * p
Definition: llb3Image.c:950
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition: sclLibUtil.c:197
void Abc_SclHashCells ( SC_Lib p)

Definition at line 65 of file sclLibUtil.c.

66 {
67  SC_Cell * pCell;
68  int i, * pPlace;
69  assert( p->nBins == 0 );
70  p->nBins = Abc_PrimeCudd( 5 * SC_LibCellNum(p) );
71  p->pBins = ABC_FALLOC( int, p->nBins );
72  SC_LibForEachCell( p, pCell, i )
73  {
74  pPlace = Abc_SclHashLookup( p, pCell->pName );
75  assert( *pPlace == -1 );
76  *pPlace = i;
77  }
78 }
static int SC_LibCellNum(SC_Lib *p)
Definition: sclLib.h:239
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
int nBins
Definition: sclLib.h:218
int * pBins
Definition: sclLib.h:217
int * Abc_SclHashLookup(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:56
char * pName
Definition: sclLib.h:183
#define assert(ex)
Definition: util_old.h:213
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
void Abc_SclInstallGenlib ( void *  pScl,
float  SlewInit,
float  Gain,
int  nGatesMin 
)

Function*************************************************************

Synopsis [Install library.]

Description []

SideEffects []

SeeAlso []

Definition at line 844 of file sclLibUtil.c.

845 {
846  SC_Lib * p = (SC_Lib *)pScl;
847  Vec_Str_t * vStr, * vStr2;
848  float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
849  int RetValue, nGateCount = SC_LibCellNum(p);
850  if ( Gain == 0 )
852  else
853  vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nGateCount );
854  vStr2 = Vec_StrDup( vStr );
855  RetValue = Mio_UpdateGenlib2( vStr, vStr2, p->pName, 0 );
856  Vec_StrFree( vStr );
857  Vec_StrFree( vStr2 );
858  if ( !RetValue )
859  printf( "Reading library has filed.\n" );
860  else if ( Gain != 0 )
861  printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nGateCount, Slew, Gain );
862 // else
863 // printf( "Derived unit-delay GENLIB library \"%s\" with %d gates.\n", p->pName, nGateCount );
864 }
static int SC_LibCellNum(SC_Lib *p)
Definition: sclLib.h:239
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Str_t * Abc_SclProduceGenlibStrSimple(SC_Lib *p)
Definition: sclLibUtil.c:663
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
int Mio_UpdateGenlib2(Vec_Str_t *vStr, Vec_Str_t *vStr2, char *pFileName, int fVerbose)
Definition: mio.c:141
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition: sclLibUtil.c:317
Vec_Str_t * Abc_SclProduceGenlibStr(SC_Lib *p, float Slew, float Gain, int nGatesMin, int *pnCellCount)
Definition: sclLibUtil.c:735
static Vec_Str_t * Vec_StrDup(Vec_Str_t *pVec)
Definition: vecStr.h:158
char * pName
Definition: sclLib.h:204
static SC_Lib* Abc_SclLibAlloc ( )
inlinestatic

Definition at line 343 of file sclLib.h.

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 }
int unit_time
Definition: sclLib.h:209
float unit_cap_fst
Definition: sclLib.h:210
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vCellClasses
Definition: sclLib.h:216
Vec_Ptr_t * vWireLoads
Definition: sclLib.h:212
int unit_cap_snd
Definition: sclLib.h:211
float default_max_out_slew
Definition: sclLib.h:208
Vec_Ptr_t * vTempls
Definition: sclLib.h:214
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Ptr_t * vWireLoadSels
Definition: sclLib.h:213
Vec_Ptr_t * vCells
Definition: sclLib.h:215
int Abc_SclLibClassNum ( SC_Lib pLib)

Definition at line 93 of file sclLibUtil.c.

94 {
95  SC_Cell * pRepr;
96  int i, Count = 0;
97  SC_LibForEachCellClass( pLib, pRepr, i )
98  Count++;
99  return Count;
100 }
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
static void Abc_SclLibFree ( SC_Lib p)
inlinestatic

Definition at line 443 of file sclLib.h.

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 );
455  Vec_PtrFree( p->vWireLoadSels );
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 );
462  Vec_PtrFree( p->vCellClasses );
463  ABC_FREE( p->pName );
464  ABC_FREE( p->pFileName );
465  ABC_FREE( p->default_wire_load );
466  ABC_FREE( p->default_wire_load_sel );
467  ABC_FREE( p->pBins );
468  ABC_FREE( p );
469 }
static void Abc_SclTableTemplFree(SC_TableTempl *p)
Definition: sclLib.h:386
static void Abc_SclWireLoadFree(SC_WireLoad *p)
Definition: sclLib.h:371
#define SC_LibForEachWireLoadSel(p, pWLS, i)
Definition: sclLib.h:251
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define SC_LibForEachWireLoad(p, pWL, i)
Definition: sclLib.h:250
static void Abc_SclCellFree(SC_Cell *p)
Definition: sclLib.h:433
#define SC_LibForEachTempl(p, pTempl, i)
Definition: sclLib.h:252
static void Abc_SclWireLoadSelFree(SC_WireLoadSel *p)
Definition: sclLib.h:378
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_SclLibNormalize ( SC_Lib p)

Definition at line 615 of file sclLibUtil.c.

616 {
617  SC_WireLoad * pWL;
618  SC_Cell * pCell;
619  SC_Pin * pPin;
620  SC_Timings * pTimings;
621  SC_Timing * pTiming;
622  int i, k, m, n;
623  float Time = 1.0 * pow(10.0, 12 - p->unit_time);
624  float Load = p->unit_cap_fst * pow(10.0, 15 - p->unit_cap_snd);
625  if ( Time == 1 && Load == 1 )
626  return;
627  p->unit_time = 12;
628  p->unit_cap_fst = 1;
629  p->unit_cap_snd = 15;
630  p->default_max_out_slew *= Time;
631  SC_LibForEachWireLoad( p, pWL, i )
632  pWL->cap *= Load;
633  SC_LibForEachCell( p, pCell, i )
634  SC_CellForEachPin( pCell, pPin, k )
635  {
636  pPin->cap *= Load;
637  pPin->rise_cap *= Load;
638  pPin->fall_cap *= Load;
639  pPin->max_out_cap *= Load;
640  pPin->max_out_slew *= Time;
641  SC_PinForEachRTiming( pPin, pTimings, m )
642  Vec_PtrForEachEntry( SC_Timing *, pTimings->vTimings, pTiming, n )
643  {
644  Abc_SclLibNormalizeSurface( pTiming->pCellRise, Time, Load );
645  Abc_SclLibNormalizeSurface( pTiming->pCellFall, Time, Load );
646  Abc_SclLibNormalizeSurface( pTiming->pRiseTrans, Time, Load );
647  Abc_SclLibNormalizeSurface( pTiming->pFallTrans, Time, Load );
648  }
649  }
650 }
int unit_time
Definition: sclLib.h:209
#define SC_CellForEachPin(p, pPin, i)
Definition: sclLib.h:253
float unit_cap_fst
Definition: sclLib.h:210
void Abc_SclLibNormalizeSurface(SC_Surface *p, float Time, float Load)
Definition: sclLibUtil.c:603
int unit_cap_snd
Definition: sclLib.h:211
float default_max_out_slew
Definition: sclLib.h:208
#define SC_LibForEachWireLoad(p, pWL, i)
Definition: sclLib.h:250
#define SC_PinForEachRTiming(p, pRTime, i)
Definition: sclLib.h:258
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
void Abc_SclLinkCells ( SC_Lib p)

Definition at line 129 of file sclLibUtil.c.

130 {
131  Vec_Ptr_t * vList;
132  SC_Cell * pCell, * pRepr = NULL;
133  int i, k;
134  assert( Vec_PtrSize(p->vCellClasses) == 0 );
135  SC_LibForEachCell( p, pCell, i )
136  {
137  // find gate with the same function
138  SC_LibForEachCellClass( p, pRepr, k )
139  if ( pCell->n_inputs == pRepr->n_inputs &&
140  pCell->n_outputs == pRepr->n_outputs &&
141  Vec_WrdEqual(SC_CellFunc(pCell), SC_CellFunc(pRepr)) )
142  break;
143  if ( k == Vec_PtrSize(p->vCellClasses) )
144  {
145  Vec_PtrPush( p->vCellClasses, pCell );
146  pCell->pNext = pCell->pPrev = pCell;
147  continue;
148  }
149  // add it to the list before the cell
150  pRepr->pPrev->pNext = pCell; pCell->pNext = pRepr;
151  pCell->pPrev = pRepr->pPrev; pRepr->pPrev = pCell;
152  }
153  // sort cells by size then by name
154  qsort( (void *)Vec_PtrArray(p->vCellClasses), Vec_PtrSize(p->vCellClasses), sizeof(void *), (int(*)(const void *,const void *))Abc_SclCompareCells );
155  // sort cell lists
156  vList = Vec_PtrAlloc( 100 );
157  SC_LibForEachCellClass( p, pRepr, k )
158  {
159  Vec_PtrClear( vList );
160  SC_RingForEachCell( pRepr, pCell, i )
161  Vec_PtrPush( vList, pCell );
162  qsort( (void *)Vec_PtrArray(vList), Vec_PtrSize(vList), sizeof(void *), (int(*)(const void *,const void *))Abc_SclCompareCells );
163  // create new representative
164  pRepr = (SC_Cell *)Vec_PtrEntry( vList, 0 );
165  pRepr->pNext = pRepr->pPrev = pRepr;
166  pRepr->pRepr = pRepr;
167  pRepr->pAve = (SC_Cell *)Vec_PtrEntry( vList, Vec_PtrSize(vList)/2 );
168  pRepr->Order = 0;
169  pRepr->nGates = Vec_PtrSize(vList);
170  // relink cells
171  Vec_PtrForEachEntryStart( SC_Cell *, vList, pCell, i, 1 )
172  {
173  pRepr->pPrev->pNext = pCell; pCell->pNext = pRepr;
174  pCell->pPrev = pRepr->pPrev; pRepr->pPrev = pCell;
175  pCell->pRepr = pRepr;
176  pCell->pAve = (SC_Cell *)Vec_PtrEntry( vList, Vec_PtrSize(vList)/2 );
177  pCell->Order = i;
178  pCell->nGates = Vec_PtrSize(vList);
179  }
180  // update list
181  Vec_PtrWriteEntry( p->vCellClasses, k, pRepr );
182  }
183  Vec_PtrFree( vList );
184 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Vec_WrdEqual(Vec_Wrd_t *p1, Vec_Wrd_t *p2)
Definition: vecWrd.h:963
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Vec_Ptr_t * vCellClasses
Definition: sclLib.h:216
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
if(last==0)
Definition: sparse_int.h:34
static int Abc_SclCompareCells(SC_Cell **pp1, SC_Cell **pp2)
Definition: sclLibUtil.c:113
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static Vec_Wrd_t * SC_CellFunc(SC_Cell *p)
Definition: sclLib.h:242
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
SC_Cell * pPrev
Definition: sclLib.h:195
#define const
Definition: zconf.h:196
SC_Cell * pNext
Definition: sclLib.h:194
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static SC_Pin* Abc_SclPinAlloc ( )
inlinestatic

Definition at line 327 of file sclLib.h.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vRTimings
Definition: sclLib.h:178
Vec_Wrd_t * vFunc
Definition: sclLib.h:177
static Vec_Wrd_t * Vec_WrdAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWrd.h:80
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
float max_out_slew
Definition: sclLib.h:175
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Abc_SclPinFree ( SC_Pin p)
inlinestatic

Definition at line 421 of file sclLib.h.

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 }
static void Vec_WrdFree(Vec_Wrd_t *p)
Definition: vecWrd.h:260
static void Abc_SclTimingsFree(SC_Timings *p)
Definition: sclLib.h:411
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define SC_PinForEachRTiming(p, pRTime, i)
Definition: sclLib.h:258
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_SclPrintCells ( SC_Lib p,
float  Slew,
float  Gain,
int  fInvOnly,
int  fShort 
)

Definition at line 503 of file sclLibUtil.c.

504 {
505  SC_Cell * pCell, * pRepr;
506  SC_Pin * pPin;
507  int i, j, k, nLength = 0;
508  float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
509  float LD = 0, PD = 0;
510  assert( Vec_PtrSize(p->vCellClasses) > 0 );
511  printf( "Library \"%s\" ", p->pName );
512  printf( "has %d cells in %d classes. ",
514  if ( !fShort )
515  printf( "Delay estimate is based on slew %.2f ps and gain %.2f.", Slew, Gain );
516  printf( "\n" );
518  // find the longest name
519  SC_LibForEachCellClass( p, pRepr, k )
520  SC_RingForEachCell( pRepr, pCell, i )
521  nLength = Abc_MaxInt( nLength, strlen(pRepr->pName) );
522  // print cells
523  SC_LibForEachCellClass( p, pRepr, k )
524  {
525  if ( fInvOnly && pRepr->n_inputs != 1 )
526  continue;
527  SC_CellForEachPinOut( pRepr, pPin, i )
528  {
529  if ( i == pRepr->n_inputs )
530  {
531  printf( "Class%4d : ", k );
532  printf( "Cells =%3d ", Abc_SclClassCellNum(pRepr) );
533  printf( "Ins =%2d ", pRepr->n_inputs );
534  printf( "Outs =%2d ", pRepr->n_outputs );
535  }
536  else
537  printf( " " );
538  if ( pPin->func_text )
539  printf( "%-30s", pPin->func_text );
540  printf( " " );
541  Kit_DsdPrintFromTruth( (unsigned *)Vec_WrdArray(pPin->vFunc), pRepr->n_inputs );
542  printf( "\n" );
543  if ( fShort )
544  continue;
545  SC_RingForEachCell( pRepr, pCell, j )
546  {
547  printf( " %3d ", j+1 );
548  printf( "%s", pCell->fSkip ? "s" : " " );
549  printf( " : " );
550  printf( "%-*s ", nLength, pCell->pName );
551  printf( "%2d ", pCell->drive_strength );
552  printf( "A =%8.2f ", pCell->area );
553  printf( "L =%8.2f ", pCell->leakage );
554  if ( pCell->n_outputs == 1 )
555  {
556  if ( Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ) )
557  {
558  printf( "D =%6.1f ps ", 0.01 * Gain * LD + PD );
559  printf( "LD =%6.1f ps ", LD );
560  printf( "PD =%6.1f ps ", PD );
561  printf( "C =%5.1f ff ", SC_CellPinCapAve(pCell) );
562  printf( "Cm =%5.0f ff ", SC_CellPin(pCell, pCell->n_inputs)->max_out_cap );
563  printf( "Sm =%5.1f ps ", SC_CellPin(pCell, pCell->n_inputs)->max_out_slew );
564  }
565  }
566  printf( "\n" );
567  }
568  break;
569  }
570  }
571 }
Vec_Ptr_t * vCellClasses
Definition: sclLib.h:216
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
static float SC_CellPinCapAve(SC_Cell *p)
Definition: sclLib.h:244
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
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
char * func_text
Definition: sclLib.h:176
Vec_Wrd_t * vFunc
Definition: sclLib.h:177
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition: sclLibUtil.c:317
int Abc_SclComputeParametersCell(SC_Lib *p, SC_Cell *pCell, float Slew, float *pLD, float *pPD)
Definition: sclLibUtil.c:380
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
float max_out_slew
Definition: sclLib.h:175
#define SC_CellForEachPinOut(p, pPin, i)
Definition: sclLib.h:255
void Abc_SclMarkSkippedCells(SC_Lib *p)
Definition: sclLibUtil.c:474
#define assert(ex)
Definition: util_old.h:213
int strlen()
float max_out_cap
Definition: sclLib.h:174
Vec_Ptr_t * vCells
Definition: sclLib.h:215
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition: sclLibUtil.c:84
char * pName
Definition: sclLib.h:204
SC_Lib* Abc_SclReadFromFile ( char *  pFileName)

Definition at line 248 of file sclLibScl.c.

249 {
250  SC_Lib * p;
251  FILE * pFile;
252  Vec_Str_t * vOut;
253  int nFileSize;
254  pFile = fopen( pFileName, "rb" );
255  if ( pFile == NULL )
256  {
257  printf( "Cannot open file \"%s\" for reading.\n", pFileName );
258  return NULL;
259  }
260  // get the file size, in bytes
261  fseek( pFile, 0, SEEK_END );
262  nFileSize = ftell( pFile );
263  rewind( pFile );
264  // load the contents
265  vOut = Vec_StrAlloc( nFileSize );
266  vOut->nSize = vOut->nCap;
267  assert( nFileSize == Vec_StrSize(vOut) );
268  nFileSize = fread( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
269  assert( nFileSize == Vec_StrSize(vOut) );
270  fclose( pFile );
271  // read the library
272  p = Abc_SclReadFromStr( vOut );
273  if ( p != NULL )
274  p->pFileName = Abc_UtilStrsav( pFileName );
275  if ( p != NULL )
276  Abc_SclLibNormalize( p );
277  Vec_StrFree( vOut );
278  return p;
279 }
char * pFileName
Definition: sclLib.h:205
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
#define SEEK_END
Definition: zconf.h:392
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition: sclLibScl.c:234
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int nSize
Definition: bblif.c:50
#define assert(ex)
Definition: util_old.h:213
int nCap
Definition: bblif.c:49
void Abc_SclLibNormalize(SC_Lib *p)
Definition: sclLibUtil.c:615
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
VOID_HACK rewind()
SC_Lib* Abc_SclReadFromStr ( Vec_Str_t vOut)

Definition at line 234 of file sclLibScl.c.

235 {
236  SC_Lib * p;
237  int Pos = 0;
238  // read the library
239  p = Abc_SclLibAlloc();
240  if ( !Abc_SclReadLibrary( vOut, &Pos, p ) )
241  return NULL;
242  assert( Pos == Vec_StrSize(vOut) );
243  // hash gates by name
244  Abc_SclHashCells( p );
245  Abc_SclLinkCells( p );
246  return p;
247 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ush Pos
Definition: deflate.h:88
static int Abc_SclReadLibrary(Vec_Str_t *vOut, int *pPos, SC_Lib *p)
Definition: sclLibScl.c:74
static SC_Lib * Abc_SclLibAlloc()
Definition: sclLib.h:343
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
void Abc_SclLinkCells(SC_Lib *p)
Definition: sclLibUtil.c:129
#define assert(ex)
Definition: util_old.h:213
void Abc_SclHashCells(SC_Lib *p)
Definition: sclLibUtil.c:65
SC_Lib* Abc_SclReadLiberty ( char *  pFileName,
int  fVerbose,
int  fVeryVerbose 
)

Definition at line 1626 of file sclLiberty.c.

1627 {
1628  SC_Lib * pLib;
1629  Scl_Tree_t * p;
1630  Vec_Str_t * vStr;
1631  p = Scl_LibertyParse( pFileName, fVeryVerbose );
1632  if ( p == NULL )
1633  return NULL;
1634 // Scl_LibertyParseDump( p, "temp_.lib" );
1635  // collect relevant data
1636  vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose );
1637  Scl_LibertyStop( p, fVeryVerbose );
1638  if ( vStr == NULL )
1639  return NULL;
1640  // construct SCL data-structure
1641  pLib = Abc_SclReadFromStr( vStr );
1642  if ( pLib == NULL )
1643  return NULL;
1644  pLib->pFileName = Abc_UtilStrsav( pFileName );
1645  Abc_SclLibNormalize( pLib );
1646  Vec_StrFree( vStr );
1647 // printf( "Average slew = %.2f ps\n", Abc_SclComputeAverageSlew(pLib) );
1648  return pLib;
1649 }
char * pFileName
Definition: sclLib.h:205
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Str_t * Scl_LibertyReadSclStr(Scl_Tree_t *p, int fVerbose, int fVeryVerbose)
Definition: sclLiberty.c:1394
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition: sclLibScl.c:234
Scl_Tree_t * Scl_LibertyParse(char *pFileName, int fVerbose)
Definition: sclLiberty.c:573
void Scl_LibertyStop(Scl_Tree_t *p, int fVerbose)
Definition: sclLiberty.c:560
void Abc_SclLibNormalize(SC_Lib *p)
Definition: sclLibUtil.c:615
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
static SC_Surface* Abc_SclSurfaceAlloc ( )
inlinestatic

Definition at line 301 of file sclLib.h.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vData
Definition: sclLib.h:146
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecFlt.h:78
Vec_Flt_t * vIndex1
Definition: sclLib.h:145
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Abc_SclSurfaceFree ( SC_Surface p)
inlinestatic

Definition at line 393 of file sclLib.h.

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 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static void Vec_FltFree(Vec_Flt_t *p)
Definition: vecFlt.h:218
Vec_Ptr_t * vData
Definition: sclLib.h:146
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Vec_Flt_t * vIndex1
Definition: sclLib.h:145
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * pName
Definition: sclLib.h:143
static SC_TableTempl* Abc_SclTableTemplAlloc ( )
inlinestatic

Definition at line 293 of file sclLib.h.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vVars
Definition: sclLib.h:137
Vec_Ptr_t * vIndex
Definition: sclLib.h:138
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Abc_SclTableTemplFree ( SC_TableTempl p)
inlinestatic

Definition at line 386 of file sclLib.h.

387 {
388  Vec_PtrFreeFree( p->vVars );
389  Vec_VecFree( (Vec_Vec_t *)p->vIndex );
390  ABC_FREE( p->pName );
391  ABC_FREE( p );
392 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
Vec_Ptr_t * vVars
Definition: sclLib.h:137
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Vec_Ptr_t * vIndex
Definition: sclLib.h:138
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * pName
Definition: sclLib.h:136
static SC_Timing* Abc_SclTimingAlloc ( )
inlinestatic

Definition at line 310 of file sclLib.h.

311 {
312  SC_Timing * p;
313  p = ABC_CALLOC( SC_Timing, 1 );
318  return p;
319 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static SC_Surface * Abc_SclSurfaceAlloc()
Definition: sclLib.h:301
SC_Surface * pFallTrans
Definition: sclLib.h:158
SC_Surface * pRiseTrans
Definition: sclLib.h:157
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
SC_Surface * pCellFall
Definition: sclLib.h:156
static void Abc_SclTimingFree ( SC_Timing p)
inlinestatic

Definition at line 401 of file sclLib.h.

402 {
407  ABC_FREE( p->related_pin );
408  ABC_FREE( p->when_text );
409  ABC_FREE( p );
410 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static void Abc_SclSurfaceFree(SC_Surface *p)
Definition: sclLib.h:393
SC_Surface * pFallTrans
Definition: sclLib.h:158
SC_Surface * pRiseTrans
Definition: sclLib.h:157
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * related_pin
Definition: sclLib.h:152
char * when_text
Definition: sclLib.h:154
SC_Surface * pCellFall
Definition: sclLib.h:156
static SC_Timings* Abc_SclTimingsAlloc ( )
inlinestatic

Definition at line 320 of file sclLib.h.

321 {
322  SC_Timings * p;
323  p = ABC_CALLOC( SC_Timings, 1 );
324  p->vTimings = Vec_PtrAlloc( 0 );
325  return p;
326 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vTimings
Definition: sclLib.h:164
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Abc_SclTimingsFree ( SC_Timings p)
inlinestatic

Definition at line 411 of file sclLib.h.

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 }
Vec_Ptr_t * vTimings
Definition: sclLib.h:164
static void Abc_SclTimingFree(SC_Timing *p)
Definition: sclLib.h:401
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static SC_WireLoad* Abc_SclWireLoadAlloc ( )
inlinestatic

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Constructors of the library data-structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 276 of file sclLib.h.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecFlt.h:78
Vec_Flt_t * vLen
Definition: sclLib.h:123
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Int_t * vFanout
Definition: sclLib.h:122
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static void Abc_SclWireLoadFree ( SC_WireLoad p)
inlinestatic

Function*************************************************************

Synopsis [Destructors of the library data-structures.]

Description []

SideEffects []

SeeAlso []

Definition at line 371 of file sclLib.h.

372 {
373  Vec_IntFree( p->vFanout );
374  Vec_FltFree( p->vLen );
375  ABC_FREE( p->pName );
376  ABC_FREE( p );
377 }
static void Vec_FltFree(Vec_Flt_t *p)
Definition: vecFlt.h:218
Vec_Flt_t * vLen
Definition: sclLib.h:123
char * pName
Definition: sclLib.h:119
Vec_Int_t * vFanout
Definition: sclLib.h:122
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static SC_WireLoadSel* Abc_SclWireLoadSelAlloc ( )
inlinestatic

Definition at line 284 of file sclLib.h.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Flt_t * vAreaTo
Definition: sclLib.h:130
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecFlt.h:78
Vec_Ptr_t * vWireLoadModel
Definition: sclLib.h:131
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Flt_t * vAreaFrom
Definition: sclLib.h:129
static void Abc_SclWireLoadSelFree ( SC_WireLoadSel p)
inlinestatic

Definition at line 378 of file sclLib.h.

379 {
380  Vec_FltFree( p->vAreaFrom );
381  Vec_FltFree( p->vAreaTo );
383  ABC_FREE( p->pName );
384  ABC_FREE( p );
385 }
static void Vec_FltFree(Vec_Flt_t *p)
Definition: vecFlt.h:218
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
Vec_Flt_t * vAreaTo
Definition: sclLib.h:130
Vec_Ptr_t * vWireLoadModel
Definition: sclLib.h:131
char * pName
Definition: sclLib.h:128
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Flt_t * vAreaFrom
Definition: sclLib.h:129
void Abc_SclWriteLiberty ( char *  pFileName,
SC_Lib p 
)

Definition at line 660 of file sclLibScl.c.

661 {
662  FILE * pFile = fopen( pFileName, "wb" );
663  if ( pFile == NULL )
664  printf( "Cannot open text file \"%s\" for writing.\n", pFileName );
665  else
666  {
667  Abc_SclWriteLibraryText( pFile, p );
668  fclose( pFile );
669  printf( "Dumped internal library into Liberty file \"%s\".\n", pFileName );
670  }
671 }
static void Abc_SclWriteLibraryText(FILE *s, SC_Lib *p)
Definition: sclLibScl.c:521
void Abc_SclWriteScl ( char *  pFileName,
SC_Lib p 
)

Definition at line 444 of file sclLibScl.c.

445 {
446  Vec_Str_t * vOut;
447  vOut = Vec_StrAlloc( 10000 );
448  Abc_SclWriteLibrary( vOut, p );
449  if ( Vec_StrSize(vOut) > 0 )
450  {
451  FILE * pFile = fopen( pFileName, "wb" );
452  if ( pFile == NULL )
453  printf( "Cannot open file \"%s\" for writing.\n", pFileName );
454  else
455  {
456  fwrite( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
457  fclose( pFile );
458  }
459  }
460  Vec_StrFree( vOut );
461 }
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
static void Abc_SclWriteLibrary(Vec_Str_t *vOut, SC_Lib *p)
Definition: sclLibScl.c:317
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static Vec_Wrd_t* SC_CellFunc ( SC_Cell p)
inlinestatic

Definition at line 242 of file sclLib.h.

242 { return SC_CellPin(p, p->n_inputs)->vFunc; }
Vec_Wrd_t * vFunc
Definition: sclLib.h:177
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
int n_inputs
Definition: sclLib.h:192
static SC_Pin* SC_CellPin ( SC_Cell p,
int  i 
)
inlinestatic

Definition at line 241 of file sclLib.h.

241 { return (SC_Pin *)Vec_PtrEntry(p->vPins, i); }
Vec_Ptr_t * vPins
Definition: sclLib.h:191
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static float SC_CellPinCap ( SC_Cell p,
int  i 
)
inlinestatic

Definition at line 243 of file sclLib.h.

243 { return 0.5 * SC_CellPin(p, i)->rise_cap + 0.5 * SC_CellPin(p, i)->fall_cap; }
float fall_cap
Definition: sclLib.h:173
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
float rise_cap
Definition: sclLib.h:172
static float SC_CellPinCapAve ( SC_Cell p)
inlinestatic

Definition at line 244 of file sclLib.h.

244 { 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); }
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static float SC_CellPinCap(SC_Cell *p, int i)
Definition: sclLib.h:243
int n_inputs
Definition: sclLib.h:192
static char* SC_CellPinName ( SC_Cell p,
int  i 
)
inlinestatic

Definition at line 246 of file sclLib.h.

246 { return SC_CellPin(p, i)->pName; }
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
char * pName
Definition: sclLib.h:169
static char* SC_CellPinOutFunc ( SC_Cell p,
int  i 
)
inlinestatic

Definition at line 245 of file sclLib.h.

245 { return SC_CellPin(p, p->n_inputs + i)->func_text; }
char * func_text
Definition: sclLib.h:176
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
int n_inputs
Definition: sclLib.h:192
static SC_Cell* SC_LibCell ( SC_Lib p,
int  i 
)
inlinestatic

Definition at line 240 of file sclLib.h.

240 { return (SC_Cell *)Vec_PtrEntry(p->vCells, i); }
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vCells
Definition: sclLib.h:215
static int SC_LibCellNum ( SC_Lib p)
inlinestatic

Definition at line 239 of file sclLib.h.

239 { return Vec_PtrSize(p->vCells); }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * vCells
Definition: sclLib.h:215
static void SC_PairAdd ( SC_Pair d,
SC_Pair s 
)
inlinestatic

Definition at line 235 of file sclLib.h.

235 { d->rise += s->rise; d->fall += s->fall;}
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static float SC_PairAve ( SC_Pair d)
inlinestatic

Definition at line 232 of file sclLib.h.

232 { return 0.5 * d->rise + 0.5 * d->fall; }
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static void SC_PairClean ( SC_Pair d)
inlinestatic

GLOBAL VARIABLES ///.

MACRO DEFINITIONS ///

Definition at line 229 of file sclLib.h.

229 { d->rise = d->fall = 0; }
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static void SC_PairDup ( SC_Pair d,
SC_Pair s 
)
inlinestatic

Definition at line 233 of file sclLib.h.

233 { *d = *s; }
static int SC_PairEqual ( SC_Pair d,
SC_Pair s 
)
inlinestatic

Definition at line 236 of file sclLib.h.

236 { return d->rise == s->rise && d->fall == s->fall; }
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static int SC_PairEqualE ( SC_Pair d,
SC_Pair s,
float  E 
)
inlinestatic

Definition at line 237 of file sclLib.h.

237 { return d->rise - s->rise < E && s->rise - d->rise < E && d->fall - s->fall < E && s->fall - d->fall < E; }
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static float SC_PairMax ( SC_Pair d)
inlinestatic

Definition at line 230 of file sclLib.h.

230 { return Abc_MaxFloat(d->rise, d->fall); }
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static float SC_PairMin ( SC_Pair d)
inlinestatic

Definition at line 231 of file sclLib.h.

231 { return Abc_MinFloat(d->rise, d->fall); }
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static void SC_PairMove ( SC_Pair d,
SC_Pair s 
)
inlinestatic

Definition at line 234 of file sclLib.h.

234 { *d = *s; s->rise = s->fall = 0; }
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static SC_Timing* Scl_CellPinTime ( SC_Cell pCell,
int  iPin 
)
inlinestatic

Function*************************************************************

Synopsis [Compute one timing edge.]

Description []

SideEffects []

SeeAlso []

Definition at line 565 of file sclLib.h.

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 }
Vec_Ptr_t * vRTimings
Definition: sclLib.h:178
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static SC_Pin * SC_CellPin(SC_Cell *p, int i)
Definition: sclLib.h:241
Vec_Ptr_t * vTimings
Definition: sclLib.h:164
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int n_inputs
Definition: sclLib.h:192
#define assert(ex)
Definition: util_old.h:213
static void Scl_LibHandleInputDriver ( SC_Cell pCell,
SC_Pair pLoadIn,
SC_Pair pArrOut,
SC_Pair pSlewOut 
)
inlinestatic

Definition at line 591 of file sclLib.h.

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 }
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
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
int n_inputs
Definition: sclLib.h:192
#define assert(ex)
Definition: util_old.h:213
static float Scl_LibLookup ( SC_Surface p,
float  slew,
float  load 
)
inlinestatic

Function*************************************************************

Synopsis [Lookup table delay computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 483 of file sclLib.h.

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 }
Vec_Ptr_t * vData
Definition: sclLib.h:146
static float * Vec_FltArray(Vec_Flt_t *p)
Definition: vecFlt.h:274
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Flt_t * vIndex1
Definition: sclLib.h:145
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
#define assert(ex)
Definition: util_old.h:213
static float Vec_FltEntry(Vec_Flt_t *p, int i)
Definition: vecFlt.h:342
static int Vec_FltSize(Vec_Flt_t *p)
Definition: vecFlt.h:294
static void Scl_LibPinArrival ( SC_Timing pTime,
SC_Pair pArrIn,
SC_Pair pSlewIn,
SC_Pair pLoad,
SC_Pair pArrOut,
SC_Pair pSlewOut 
)
inlinestatic

Definition at line 523 of file sclLib.h.

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 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
float rise
Definition: sclLib.h:65
SC_TSense tsense
Definition: sclLib.h:153
static float Scl_LibLookup(SC_Surface *p, float slew, float load)
Definition: sclLib.h:483
float fall
Definition: sclLib.h:66
SC_Surface * pFallTrans
Definition: sclLib.h:158
SC_Surface * pRiseTrans
Definition: sclLib.h:157
SC_Surface * pCellFall
Definition: sclLib.h:156
static float Scl_LibPinArrivalEstimate ( SC_Cell pCell,
int  iPin,
float  Slew,
float  Load 
)
inlinestatic

Definition at line 578 of file sclLib.h.

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 }
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
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
static void Scl_LibPinDeparture ( SC_Timing pTime,
SC_Pair pDepIn,
SC_Pair pSlewIn,
SC_Pair pLoad,
SC_Pair pDepOut 
)
inlinestatic

Definition at line 540 of file sclLib.h.

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 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
float rise
Definition: sclLib.h:65
SC_TSense tsense
Definition: sclLib.h:153
static float Scl_LibLookup(SC_Surface *p, float slew, float load)
Definition: sclLib.h:483
float fall
Definition: sclLib.h:66
SC_Surface * pCellFall
Definition: sclLib.h:156