abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclLibUtil.c File Reference
#include "sclLib.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "bool/kit/kit.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
unsigned 
Abc_SclHashString (char *pName, int TableSize)
 DECLARATIONS ///. More...
 
int * Abc_SclHashLookup (SC_Lib *p, char *pName)
 
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)
 
static int Abc_SclCompareCells (SC_Cell **pp1, SC_Cell **pp2)
 
void Abc_SclLinkCells (SC_Lib *p)
 
SC_CellAbc_SclFindInvertor (SC_Lib *p, int fFindBuff)
 
SC_CellAbc_SclFindSmallestGate (SC_Cell *p, float CinMin)
 
SC_WireLoadAbc_SclFetchWireLoadModel (SC_Lib *p, char *pWLoadUsed)
 
SC_WireLoadAbc_SclFindWireLoadModel (SC_Lib *p, float Area)
 
int Abc_SclHasDelayInfo (void *pScl)
 
float Abc_SclComputeAverageSlew (SC_Lib *p)
 
int Abc_SclComputeParametersPin (SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float *pLD, float *pPD)
 
int Abc_SclComputeParametersCell (SC_Lib *p, SC_Cell *pCell, float Slew, float *pLD, float *pPD)
 
void Abc_SclComputeParametersClass (SC_Lib *p, SC_Cell *pRepr, float Slew, float *pLD, float *pPD)
 
void Abc_SclComputeParametersClassPin (SC_Lib *p, SC_Cell *pRepr, int iPin, float Slew, float *pLD, float *pPD)
 
float Abc_SclComputeDelayCellPin (SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float Gain)
 
float Abc_SclComputeDelayClassPin (SC_Lib *p, SC_Cell *pRepr, int iPin, float Slew, float Gain)
 
float Abc_SclComputeAreaClass (SC_Cell *pRepr)
 
void Abc_SclMarkSkippedCells (SC_Lib *p)
 
void Abc_SclPrintCells (SC_Lib *p, float SlewInit, float Gain, int fInvOnly, int fShort)
 
void Abc_SclConvertLeakageIntoArea (SC_Lib *p, float A, float B)
 
void Abc_SclLibNormalizeSurface (SC_Surface *p, float Time, float Load)
 
void Abc_SclLibNormalize (SC_Lib *p)
 
Vec_Str_tAbc_SclProduceGenlibStrSimple (SC_Lib *p)
 
Mio_Library_tAbc_SclDeriveGenlibSimple (void *pScl)
 
Vec_Str_tAbc_SclProduceGenlibStr (SC_Lib *p, float Slew, float Gain, int nGatesMin, int *pnCellCount)
 
void Abc_SclDumpGenlib (char *pFileName, SC_Lib *p, float SlewInit, float Gain, int nGatesMin)
 
Mio_Library_tAbc_SclDeriveGenlib (void *pScl, float SlewInit, float Gain, int nGatesMin, int fVerbose)
 
void Abc_SclInstallGenlib (void *pScl, float SlewInit, float Gain, int nGatesMin)
 

Function Documentation

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
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
static int Abc_SclCompareCells ( SC_Cell **  pp1,
SC_Cell **  pp2 
)
static

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

Synopsis [Links equal gates into rings while sorting them by area.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file sclLibUtil.c.

114 {
115  if ( (*pp1)->n_inputs < (*pp2)->n_inputs )
116  return -1;
117  if ( (*pp1)->n_inputs > (*pp2)->n_inputs )
118  return 1;
119 // if ( (*pp1)->area < (*pp2)->area )
120 // return -1;
121 // if ( (*pp1)->area > (*pp2)->area )
122 // return 1;
123  if ( SC_CellPinCapAve(*pp1) < SC_CellPinCapAve(*pp2) )
124  return -1;
125  if ( SC_CellPinCapAve(*pp1) > SC_CellPinCapAve(*pp2) )
126  return 1;
127  return strcmp( (*pp1)->pName, (*pp2)->pName );
128 }
static float SC_CellPinCapAve(SC_Cell *p)
Definition: sclLib.h:244
int strcmp()
float Abc_SclComputeAreaClass ( SC_Cell pRepr)

Definition at line 448 of file sclLibUtil.c.

449 {
450  SC_Cell * pCell;
451  float Area = 0;
452  int i, Count = 0;
453  SC_RingForEachCell( pRepr, pCell, i )
454  {
455  if ( pCell->fSkip )
456  continue;
457  Area += pCell->area;
458  Count++;
459  }
460  return Area / Abc_MaxInt(1, Count);
461 }
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
float area
Definition: sclLib.h:188
int fSkip
Definition: sclLib.h:185
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
float Abc_SclComputeDelayCellPin ( SC_Lib p,
SC_Cell pCell,
int  iPin,
float  Slew,
float  Gain 
)

Definition at line 426 of file sclLibUtil.c.

427 {
428  float LD = 0, PD = 0;
429  Abc_SclComputeParametersPin( p, pCell, iPin, Slew, &LD, &PD );
430  return 0.01 * LD * Gain + PD;
431 }
int Abc_SclComputeParametersPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float *pLD, float *pPD)
Definition: sclLibUtil.c:343
float Abc_SclComputeDelayClassPin ( SC_Lib p,
SC_Cell pRepr,
int  iPin,
float  Slew,
float  Gain 
)

Definition at line 432 of file sclLibUtil.c.

433 {
434  SC_Cell * pCell;
435  float Delay = 0;
436  int i, Count = 0;
437  SC_RingForEachCell( pRepr, pCell, i )
438  {
439  if ( pCell->fSkip )
440  continue;
441 // if ( pRepr == pCell ) // skip the first gate
442 // continue;
443  Delay += Abc_SclComputeDelayCellPin( p, pCell, iPin, Slew, Gain );
444  Count++;
445  }
446  return Delay / Abc_MaxInt(1, Count);
447 }
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
float Abc_SclComputeDelayCellPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float Gain)
Definition: sclLibUtil.c:426
int fSkip
Definition: sclLib.h:185
int Abc_SclComputeParametersCell ( SC_Lib p,
SC_Cell pCell,
float  Slew,
float *  pLD,
float *  pPD 
)

Definition at line 380 of file sclLibUtil.c.

381 {
382  SC_Pin * pPin;
383  float LD, PD, ld, pd;
384  int i;
385  LD = PD = ld = pd = 0;
386  SC_CellForEachPinIn( pCell, pPin, i )
387  {
388  if ( !Abc_SclComputeParametersPin( p, pCell, i, Slew, &ld, &pd ) )
389  return 0;
390  LD += ld; PD += pd;
391  }
392  *pLD = LD / Abc_MaxInt(1, pCell->n_inputs);
393  *pPD = PD / Abc_MaxInt(1, pCell->n_inputs);
394  return 1;
395 }
int Abc_SclComputeParametersPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float *pLD, float *pPD)
Definition: sclLibUtil.c:343
#define SC_CellForEachPinIn(p, pPin, i)
Definition: sclLib.h:254
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int n_inputs
Definition: sclLib.h:192
void Abc_SclComputeParametersClass ( SC_Lib p,
SC_Cell pRepr,
float  Slew,
float *  pLD,
float *  pPD 
)

Definition at line 396 of file sclLibUtil.c.

397 {
398  SC_Cell * pCell;
399  float LD, PD, ld, pd;
400  int i, Count = 0;
401  LD = PD = ld = pd = 0;
402  SC_RingForEachCell( pRepr, pCell, i )
403  {
404  Abc_SclComputeParametersCell( p, pCell, Slew, &ld, &pd );
405  LD += ld; PD += pd;
406  Count++;
407  }
408  *pLD = LD / Abc_MaxInt(1, Count);
409  *pPD = PD / Abc_MaxInt(1, Count);
410 }
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Abc_SclComputeParametersCell(SC_Lib *p, SC_Cell *pCell, float Slew, float *pLD, float *pPD)
Definition: sclLibUtil.c:380
void Abc_SclComputeParametersClassPin ( SC_Lib p,
SC_Cell pRepr,
int  iPin,
float  Slew,
float *  pLD,
float *  pPD 
)

Definition at line 411 of file sclLibUtil.c.

412 {
413  SC_Cell * pCell;
414  float LD, PD, ld, pd;
415  int i, Count = 0;
416  LD = PD = ld = pd = 0;
417  SC_RingForEachCell( pRepr, pCell, i )
418  {
419  Abc_SclComputeParametersPin( p, pCell, iPin, Slew, &ld, &pd );
420  LD += ld; PD += pd;
421  Count++;
422  }
423  *pLD = LD / Abc_MaxInt(1, Count);
424  *pPD = PD / Abc_MaxInt(1, Count);
425 }
int Abc_SclComputeParametersPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float *pLD, float *pPD)
Definition: sclLibUtil.c:343
#define SC_RingForEachCell(pRing, pCell, i)
Definition: sclLib.h:256
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
int Abc_SclComputeParametersPin ( SC_Lib p,
SC_Cell pCell,
int  iPin,
float  Slew,
float *  pLD,
float *  pPD 
)

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

Synopsis [Compute delay parameters of pin/cell/class.]

Description []

SideEffects []

SeeAlso []

Definition at line 343 of file sclLibUtil.c.

344 {
345  SC_Pair Load0, Load1, Load2;
346  SC_Pair ArrIn = { 0.0, 0.0 };
347  SC_Pair SlewIn = { Slew, Slew };
348  SC_Pair ArrOut0 = { 0.0, 0.0 };
349  SC_Pair ArrOut1 = { 0.0, 0.0 };
350  SC_Pair ArrOut2 = { 0.0, 0.0 };
351  SC_Pair SlewOut = { 0.0, 0.0 };
352  SC_Timing * pTime = Scl_CellPinTime( pCell, iPin );
353  Vec_Flt_t * vIndex = pTime ? pTime->pCellRise->vIndex1 : NULL; // capacitance
354  if ( vIndex == NULL )
355  return 0;
356  // handle constant table
357  if ( Vec_FltSize(vIndex) == 1 )
358  {
359  *pLD = 0;
360  *pPD = Vec_FltEntry( (Vec_Flt_t *)Vec_PtrEntry(pTime->pCellRise->vData, 0), 0 );
361  return 1;
362  }
363  // get load points
364  Load0.rise = Load0.fall = 0.0;
365  Load1.rise = Load1.fall = Vec_FltEntry( vIndex, 0 );
366  Load2.rise = Load2.fall = Vec_FltEntry( vIndex, Vec_FltSize(vIndex) - 2 );
367  // compute delay
368  Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load0, &ArrOut0, &SlewOut );
369  Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load1, &ArrOut1, &SlewOut );
370  Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load2, &ArrOut2, &SlewOut );
371  ArrOut0.rise = 0.5 * ArrOut0.rise + 0.5 * ArrOut0.fall;
372  ArrOut1.rise = 0.5 * ArrOut1.rise + 0.5 * ArrOut1.fall;
373  ArrOut2.rise = 0.5 * ArrOut2.rise + 0.5 * ArrOut2.fall;
374  // get tangent
375  *pLD = (ArrOut2.rise - ArrOut1.rise) / ((Load2.rise - Load1.rise) / SC_CellPinCap(pCell, iPin));
376  // get constant
377  *pPD = ArrOut0.rise;
378  return 1;
379 }
SC_Surface * pCellRise
Definition: sclLib.h:155
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
Vec_Ptr_t * vData
Definition: sclLib.h:146
Vec_Flt_t * vIndex1
Definition: sclLib.h:145
float rise
Definition: sclLib.h:65
float fall
Definition: sclLib.h:66
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static float SC_CellPinCap(SC_Cell *p, int i)
Definition: sclLib.h:243
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
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
Mio_Library_t* Abc_SclDeriveGenlib ( void *  pScl,
float  SlewInit,
float  Gain,
int  nGatesMin,
int  fVerbose 
)

Definition at line 818 of file sclLibUtil.c.

819 {
820  int nCellCount = 0;
821  SC_Lib * p = (SC_Lib *)pScl;
822  float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
823  Vec_Str_t * vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
824  Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
825  Vec_StrFree( vStr );
826  if ( !pLib )
827  printf( "Reading library has filed.\n" );
828  else if ( fVerbose )
829  printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nCellCount, Slew, Gain );
830  return pLib;
831 }
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
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
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
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
Mio_Library_t* Abc_SclDeriveGenlibSimple ( void *  pScl)

Definition at line 710 of file sclLibUtil.c.

711 {
712  SC_Lib * p = (SC_Lib *)pScl;
714  Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
715  Vec_StrFree( vStr );
716  if ( pLib )
717  printf( "Derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) );
718  else
719  printf( "Reading library has filed.\n" );
720  return pLib;
721 }
static int SC_LibCellNum(SC_Lib *p)
Definition: sclLib.h:239
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
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
Vec_Str_t * Abc_SclProduceGenlibStrSimple(SC_Lib *p)
Definition: sclLibUtil.c:663
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
char * pName
Definition: sclLib.h:204
void Abc_SclDumpGenlib ( char *  pFileName,
SC_Lib p,
float  SlewInit,
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
int* Abc_SclHashLookup ( SC_Lib p,
char *  pName 
)

Definition at line 56 of file sclLibUtil.c.

57 {
58  int i;
59  for ( i = Abc_SclHashString(pName, p->nBins); i < p->nBins; i = (i + 1) % p->nBins )
60  if ( p->pBins[i] == -1 || !strcmp(pName, SC_LibCell(p, p->pBins[i])->pName) )
61  return p->pBins + i;
62  assert( 0 );
63  return NULL;
64 }
int nBins
Definition: sclLib.h:218
int * pBins
Definition: sclLib.h:217
int strcmp()
char * pName
Definition: sclLib.h:183
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START unsigned Abc_SclHashString(char *pName, int TableSize)
DECLARATIONS ///.
Definition: sclLibUtil.c:48
static ABC_NAMESPACE_IMPL_START unsigned Abc_SclHashString ( char *  pName,
int  TableSize 
)
static

DECLARATIONS ///.

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

FileName [sclLibUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Standard-cell library representation.]

Synopsis [Various library utilities.]

Author [Alan Mishchenko, Niklas Een]

Affiliation [UC Berkeley]

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

Revision [

Id:
sclLibUtil.c,v 1.0 2012/08/24 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Reading library from file.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file sclLibUtil.c.

49 {
50  static int s_Primes[10] = { 1291, 1699, 2357, 4177, 5147, 5647, 6343, 7103, 7873, 8147 };
51  unsigned i, Key = 0;
52  for ( i = 0; pName[i] != '\0'; i++ )
53  Key += s_Primes[i%10]*pName[i]*pName[i];
54  return Key % TableSize;
55 }
static int s_Primes[MAX_PRIMES]
Definition: fxuPair.c:30
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
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
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_SclLibNormalizeSurface ( SC_Surface p,
float  Time,
float  Load 
)

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

Synopsis [Print cells]

Description []

SideEffects []

SeeAlso []

Definition at line 603 of file sclLibUtil.c.

604 {
605  Vec_Flt_t * vArray;
606  int i, k; float Entry;
607  Vec_FltForEachEntry( p->vIndex0, Entry, i ) // slew
608  Vec_FltWriteEntry( p->vIndex0, i, Time * Entry );
609  Vec_FltForEachEntry( p->vIndex1, Entry, i ) // load
610  Vec_FltWriteEntry( p->vIndex1, i, Load * Entry );
611  Vec_PtrForEachEntry( Vec_Flt_t *, p->vData, vArray, k )
612  Vec_FltForEachEntry( vArray, Entry, i ) // delay/slew
613  Vec_FltWriteEntry( vArray, i, Time * Entry );
614 }
#define Vec_FltForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecFlt.h:54
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
Definition: vecFlt.h:364
Vec_Flt_t * vIndex0
Definition: sclLib.h:144
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition: vecFlt.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
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
void Abc_SclMarkSkippedCells ( SC_Lib p)

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

Synopsis [Print cells]

Description []

SideEffects []

SeeAlso []

Definition at line 474 of file sclLibUtil.c.

475 {
476  char FileName[1000];
477  char Buffer[1000], * pName;
478  SC_Cell * pCell;
479  FILE * pFile;
480  int CellId, nSkipped = 0;
481  sprintf( FileName, "%s.skip", p->pName );
482  pFile = fopen( FileName, "rb" );
483  if ( pFile == NULL )
484  return;
485  while ( fgets( Buffer, 999, pFile ) != NULL )
486  {
487  pName = strtok( Buffer, "\r\n\t " );
488  if ( pName == NULL )
489  continue;
490  CellId = Abc_SclCellFind( p, pName );
491  if ( CellId == -1 )
492  {
493  printf( "Cannot find cell \"%s\" in the library \"%s\".\n", pName, p->pName );
494  continue;
495  }
496  pCell = SC_LibCell( p, CellId );
497  pCell->fSkip = 1;
498  nSkipped++;
499  }
500  fclose( pFile );
501  printf( "Marked %d cells for skipping in the library \"%s\".\n", nSkipped, p->pName );
502 }
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition: sclLibUtil.c:79
char * strtok()
char * sprintf()
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
int fSkip
Definition: sclLib.h:185
char * pName
Definition: sclLib.h:204
void Abc_SclPrintCells ( SC_Lib p,
float  SlewInit,
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
Vec_Str_t* Abc_SclProduceGenlibStr ( SC_Lib p,
float  Slew,
float  Gain,
int  nGatesMin,
int *  pnCellCount 
)

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

Synopsis [Derive GENLIB library.]

Description []

SideEffects []

SeeAlso []

Definition at line 735 of file sclLibUtil.c.

736 {
737  char Buffer[200];
738  Vec_Str_t * vStr;
739  SC_Cell * pRepr;
740  SC_Pin * pPin;
741  int i, k, Count = 2, nClassMax = 0;
742  // find the largest number of cells in a class
743  SC_LibForEachCellClass( p, pRepr, i )
744  if ( pRepr->n_outputs == 1 )
745  nClassMax = Abc_MaxInt( nClassMax, Abc_SclClassCellNum(pRepr) );
746  // update the number
747  if ( nGatesMin && nGatesMin >= nClassMax )
748  nGatesMin = 0;
749  // mark skipped cells
751  vStr = Vec_StrAlloc( 1000 );
752  Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
753  Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
754  SC_LibForEachCellClass( p, pRepr, i )
755  {
756  if ( pRepr->n_inputs == 0 )
757  continue;
758  if ( pRepr->n_outputs > 1 )
759  continue;
760  if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
761  continue;
762  assert( strlen(pRepr->pName) < 200 );
763  Vec_StrPrintStr( vStr, "GATE " );
764  sprintf( Buffer, "%-16s", pRepr->pName );
765  Vec_StrPrintStr( vStr, Buffer );
766  Vec_StrPrintStr( vStr, " " );
767 // sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
768  sprintf( Buffer, "%7.2f", pRepr->area );
769  Vec_StrPrintStr( vStr, Buffer );
770  Vec_StrPrintStr( vStr, " " );
771  Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
772  Vec_StrPrintStr( vStr, "=" );
773  Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
774  Vec_StrPrintStr( vStr, ";\n" );
775  SC_CellForEachPinIn( pRepr, pPin, k )
776  {
777  float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
778  assert( Delay > 0 );
779  Vec_StrPrintStr( vStr, " PIN " );
780  sprintf( Buffer, "%-4s", pPin->pName );
781  Vec_StrPrintStr( vStr, Buffer );
782  sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
783  Vec_StrPrintStr( vStr, Buffer );
784  }
785  Count++;
786  }
787  Vec_StrPrintStr( vStr, "\n.end\n" );
788  Vec_StrPush( vStr, '\0' );
789 // printf( "GENLIB library with %d gates is produced:\n", Count );
790 // printf( "%s", Vec_StrArray(vStr) );
791  if ( pnCellCount )
792  *pnCellCount = Count;
793  return vStr;
794 }
#define SC_CellForEachPinIn(p, pPin, i)
Definition: sclLib.h:254
#define SC_LibForEachCellClass(p, pCell, i)
Definition: sclLib.h:249
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
if(last==0)
Definition: sparse_int.h:34
char * sprintf()
static char * SC_CellPinName(SC_Cell *p, int i)
Definition: sclLib.h:246
void Abc_SclMarkSkippedCells(SC_Lib *p)
Definition: sclLibUtil.c:474
static char * SC_CellPinOutFunc(SC_Cell *p, int i)
Definition: sclLib.h:245
#define assert(ex)
Definition: util_old.h:213
int strlen()
char * pName
Definition: sclLib.h:169
static void Vec_StrPrintStr(Vec_Str_t *p, const char *pStr)
Definition: vecStr.h:627
float Abc_SclComputeDelayClassPin(SC_Lib *p, SC_Cell *pRepr, int iPin, float Slew, float Gain)
Definition: sclLibUtil.c:432
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition: sclLibUtil.c:84
Vec_Str_t* Abc_SclProduceGenlibStrSimple ( SC_Lib p)

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

Synopsis [Derives simple GENLIB library.]

Description []

SideEffects []

SeeAlso []

Definition at line 663 of file sclLibUtil.c.

664 {
665  char Buffer[200];
666  Vec_Str_t * vStr;
667  SC_Cell * pCell;
668  SC_Pin * pPin, * pPinOut;
669  int i, j, k, Count = 2;
670  // mark skipped cells
671 // Abc_SclMarkSkippedCells( p );
672  vStr = Vec_StrAlloc( 1000 );
673  Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
674  Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
675  SC_LibForEachCell( p, pCell, i )
676  {
677  if ( pCell->n_inputs == 0 )
678  continue;
679  assert( strlen(pCell->pName) < 200 );
680  SC_CellForEachPinOut( pCell, pPinOut, j )
681  {
682  Vec_StrPrintStr( vStr, "GATE " );
683  sprintf( Buffer, "%-16s", pCell->pName );
684  Vec_StrPrintStr( vStr, Buffer );
685  Vec_StrPrintStr( vStr, " " );
686  sprintf( Buffer, "%7.2f", pCell->area );
687  Vec_StrPrintStr( vStr, Buffer );
688  Vec_StrPrintStr( vStr, " " );
689  Vec_StrPrintStr( vStr, pPinOut->pName );
690  Vec_StrPrintStr( vStr, "=" );
691  Vec_StrPrintStr( vStr, pPinOut->func_text ? pPinOut->func_text : "?" );
692  Vec_StrPrintStr( vStr, ";\n" );
693  SC_CellForEachPinIn( pCell, pPin, k )
694  {
695  Vec_StrPrintStr( vStr, " PIN " );
696  sprintf( Buffer, "%-4s", pPin->pName );
697  Vec_StrPrintStr( vStr, Buffer );
698  sprintf( Buffer, " UNKNOWN 1 999 1.00 0.00 1.00 0.00\n" );
699  Vec_StrPrintStr( vStr, Buffer );
700  }
701  Count++;
702  }
703  }
704  Vec_StrPrintStr( vStr, "\n.end\n" );
705  Vec_StrPush( vStr, '\0' );
706 // printf( "GENLIB library with %d gates is produced:\n", Count );
707 // printf( "%s", Vec_StrArray(vStr) );
708  return vStr;
709 }
#define SC_CellForEachPinIn(p, pPin, i)
Definition: sclLib.h:254
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
char * func_text
Definition: sclLib.h:176
float area
Definition: sclLib.h:188
char * pName
Definition: sclLib.h:183
char * sprintf()
#define SC_CellForEachPinOut(p, pPin, i)
Definition: sclLib.h:255
int n_inputs
Definition: sclLib.h:192
#define assert(ex)
Definition: util_old.h:213
int strlen()
char * pName
Definition: sclLib.h:169
static void Vec_StrPrintStr(Vec_Str_t *p, const char *pStr)
Definition: vecStr.h:627
#define SC_LibForEachCell(p, pCell, i)
Definition: sclLib.h:248