ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sclLib.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "misc/vec/vec.h"
Include dependency graph for sclLib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SC_DontUse_
 
struct  SC_Pair_
 
struct  SC_PairI_
 
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 ///.
 
#define SC_LibForEachCell(p, pCell, i)
 
#define SC_LibForEachCellClass(p, pCell, i)
 
#define SC_LibForEachWireLoad(p, pWL, i)
 
#define SC_LibForEachWireLoadSel(p, pWLS, i)
 
#define SC_LibForEachTempl(p, pTempl, i)
 
#define SC_CellForEachPin(p, pPin, i)
 
#define SC_CellForEachPinIn(p, pPin, i)
 
#define SC_CellForEachPinOut(p, pPin, i)
 
#define SC_RingForEachCell(pRing, pCell, i)
 
#define SC_RingForEachCellRev(pRing, pCell, i)
 
#define SC_PinForEachRTiming(p, pRTime, i)
 

Typedefs

typedef struct SC_DontUse_ SC_DontUse
 
typedef struct SC_Pair_ SC_Pair
 
typedef struct SC_PairI_ SC_PairI
 
typedef struct SC_SizePars_ SC_SizePars
 
typedef struct SC_BusPars_ SC_BusPars
 
typedef struct SC_WireLoad_ SC_WireLoad
 STRUCTURE DEFINITIONS ///.
 
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

SC_LibAbc_SclReadLiberty (char *pFileName, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts)
 
SC_LibAbc_SclReadFromGenlib (void *pLib)
 
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)
 
SC_LibAbc_SclMergeLibraries (SC_Lib *pLib1, SC_Lib *pLib2, int fUsePrefix)
 
void Abc_SclHashCells (SC_Lib *p)
 
int Abc_SclCellFind (SC_Lib *p, char *pName)
 
int Abc_SclClassCellNum (SC_Cell *pClass)
 
void Abc_SclShortNames (SC_Lib *p)
 
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 fUseAll, int nGatesMin)
 

Macro Definition Documentation

◆ ABC_SCL_CUR_VERSION

#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.

◆ SC_CellForEachPin

#define SC_CellForEachPin ( p,
pPin,
i )
Value:
Vec_PtrForEachEntry( SC_Pin *, &p->vPins, pPin, i )
Cube * p
Definition exorList.c:222
struct SC_Pin_ SC_Pin
Definition sclLib.h:126
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55

Definition at line 274 of file sclLib.h.

◆ SC_CellForEachPinIn

#define SC_CellForEachPinIn ( p,
pPin,
i )
Value:
Vec_PtrForEachEntryStop( SC_Pin *, &p->vPins, pPin, i, p->n_inputs )
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition vecPtr.h:59

Definition at line 275 of file sclLib.h.

◆ SC_CellForEachPinOut

#define SC_CellForEachPinOut ( p,
pPin,
i )
Value:
Vec_PtrForEachEntryStart( SC_Pin *, &p->vPins, pPin, i, p->n_inputs )
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57

Definition at line 276 of file sclLib.h.

◆ SC_LibForEachCell

#define SC_LibForEachCell ( p,
pCell,
i )
Value:
Vec_PtrForEachEntry( SC_Cell *, &p->vCells, pCell, i )
struct SC_Cell_ SC_Cell
Definition sclLib.h:127

Definition at line 269 of file sclLib.h.

◆ SC_LibForEachCellClass

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

Definition at line 270 of file sclLib.h.

◆ SC_LibForEachTempl

#define SC_LibForEachTempl ( p,
pTempl,
i )
Value:
Vec_PtrForEachEntry( SC_TableTempl *, &p->vTempls, pTempl, i )
struct SC_TableTempl_ SC_TableTempl
Definition sclLib.h:122

Definition at line 273 of file sclLib.h.

◆ SC_LibForEachWireLoad

#define SC_LibForEachWireLoad ( p,
pWL,
i )
Value:
Vec_PtrForEachEntry( SC_WireLoad *, &p->vWireLoads, pWL, i )
struct SC_WireLoad_ SC_WireLoad
STRUCTURE DEFINITIONS ///.
Definition sclLib.h:120

Definition at line 271 of file sclLib.h.

◆ SC_LibForEachWireLoadSel

#define SC_LibForEachWireLoadSel ( p,
pWLS,
i )
Value:
Vec_PtrForEachEntry( SC_WireLoadSel *, &p->vWireLoadSels, pWLS, i )
struct SC_WireLoadSel_ SC_WireLoadSel
Definition sclLib.h:121

Definition at line 272 of file sclLib.h.

◆ SC_PinForEachRTiming

#define SC_PinForEachRTiming ( p,
pRTime,
i )
Value:
Vec_PtrForEachEntry( SC_Timings *, &p->vRTimings, pRTime, i )
struct SC_Timings_ SC_Timings
Definition sclLib.h:125

Definition at line 279 of file sclLib.h.

◆ SC_RingForEachCell

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

Definition at line 277 of file sclLib.h.

◆ SC_RingForEachCellRev

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

Definition at line 278 of file sclLib.h.

Typedef Documentation

◆ SC_BusPars

typedef struct SC_BusPars_ SC_BusPars

Definition at line 102 of file sclLib.h.

◆ SC_Cell

typedef struct SC_Cell_ SC_Cell

Definition at line 127 of file sclLib.h.

◆ SC_DontUse

typedef struct SC_DontUse_ SC_DontUse

Definition at line 62 of file sclLib.h.

◆ SC_Lib

typedef struct SC_Lib_ SC_Lib

Definition at line 128 of file sclLib.h.

◆ SC_Pair

typedef struct SC_Pair_ SC_Pair

Definition at line 69 of file sclLib.h.

◆ SC_PairI

typedef struct SC_PairI_ SC_PairI

Definition at line 75 of file sclLib.h.

◆ SC_Pin

typedef struct SC_Pin_ SC_Pin

Definition at line 126 of file sclLib.h.

◆ SC_SizePars

typedef struct SC_SizePars_ SC_SizePars

Definition at line 82 of file sclLib.h.

◆ SC_Surface

typedef struct SC_Surface_ SC_Surface

Definition at line 123 of file sclLib.h.

◆ SC_TableTempl

typedef struct SC_TableTempl_ SC_TableTempl

Definition at line 122 of file sclLib.h.

◆ SC_Timing

typedef struct SC_Timing_ SC_Timing

Definition at line 124 of file sclLib.h.

◆ SC_Timings

typedef struct SC_Timings_ SC_Timings

Definition at line 125 of file sclLib.h.

◆ SC_WireLoad

typedef struct SC_WireLoad_ SC_WireLoad

STRUCTURE DEFINITIONS ///.

Definition at line 120 of file sclLib.h.

◆ SC_WireLoadSel

Definition at line 121 of file sclLib.h.

Enumeration Type Documentation

◆ SC_Dir

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.

46{
52} SC_Dir;
SC_Dir
Definition sclLib.h:46
@ sc_dir_Output
Definition sclLib.h:49
@ sc_dir_Internal
Definition sclLib.h:51
@ sc_dir_InOut
Definition sclLib.h:50
@ sc_dir_NULL
Definition sclLib.h:47
@ sc_dir_Input
Definition sclLib.h:48

◆ SC_TSense

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{
60} SC_TSense;
SC_TSense
Definition sclLib.h:55
@ sc_ts_Neg
Definition sclLib.h:58
@ sc_ts_Non
Definition sclLib.h:59
@ sc_ts_NULL
Definition sclLib.h:56
@ sc_ts_Pos
Definition sclLib.h:57

Function Documentation

◆ Abc_SclCellFind()

int Abc_SclCellFind ( SC_Lib * p,
char * pName )
extern

Definition at line 81 of file sclLibUtil.c.

82{
83 int *pPlace = Abc_SclHashLookup( p, pName );
84 return pPlace ? *pPlace : -1;
85}
int * Abc_SclHashLookup(SC_Lib *p, char *pName)
Definition sclLibUtil.c:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclClassCellNum()

int Abc_SclClassCellNum ( SC_Cell * pClass)
extern

Definition at line 86 of file sclLibUtil.c.

87{
88 SC_Cell * pCell;
89 int i, Count = 0;
90 SC_RingForEachCell( pClass, pCell, i )
91 if ( !pCell->fSkip )
92 Count++;
93 return Count;
94}
#define SC_RingForEachCell(pRing, pCell, i)
Definition sclLib.h:277
int fSkip
Definition sclLib.h:204
Here is the caller graph for this function:

◆ Abc_SclComputeAverageSlew()

float Abc_SclComputeAverageSlew ( SC_Lib * p)
extern

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

Synopsis [Returns "average" slew.]

Description []

SideEffects []

SeeAlso []

Definition at line 452 of file sclLibUtil.c.

453{
454 SC_Cell * pCell;
455 SC_Timing * pTime;
456 Vec_Flt_t * vIndex;
457 pCell = Abc_SclFindInvertor(p, 0);
458 if ( pCell == NULL )
459 return 0;
460 pTime = Scl_CellPinTime( pCell, 0 );
461 if ( pTime == NULL )
462 return 0;
463 vIndex = &pTime->pCellRise.vIndex0; // slew
464 return Vec_FltEntry( vIndex, Vec_FltSize(vIndex)/3 );
465}
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition sclLibUtil.c:332
struct SC_Timing_ SC_Timing
Definition sclLib.h:124
Vec_Flt_t vIndex0
Definition sclLib.h:157
SC_Surface pCellRise
Definition sclLib.h:171
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
Definition vecFlt.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclConvertLeakageIntoArea()

void Abc_SclConvertLeakageIntoArea ( SC_Lib * p,
float A,
float B )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 719 of file sclLibUtil.c.

720{
721 SC_Cell * pCell; int i;
722 SC_LibForEachCell( p, pCell, i )
723 pCell->area = A * pCell->area + B * pCell->leakage;
724}
#define SC_LibForEachCell(p, pCell, i)
Definition sclLib.h:269
float area
Definition sclLib.h:207
float leakage
Definition sclLib.h:208

◆ Abc_SclDumpGenlib()

void Abc_SclDumpGenlib ( char * pFileName,
SC_Lib * p,
float Slew,
float Gain,
int nGatesMin )
extern

Definition at line 1055 of file sclLibUtil.c.

1056{
1057 int nCellCount = 0;
1058 char FileName[1000];
1059 float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
1060 Vec_Str_t * vStr;
1061 FILE * pFile;
1062 if ( pFileName == NULL )
1063 sprintf( FileName, "%s_s%03d_g%03d_m%d.genlib", p->pName, (int)Slew, (int)Gain, nGatesMin );
1064 else
1065 sprintf( FileName, "%s", pFileName );
1066 pFile = fopen( FileName, "wb" );
1067 if ( pFile == NULL )
1068 {
1069 printf( "Cannot open file \"%s\" for writing.\n", FileName );
1070 return;
1071 }
1072 vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, 0, &nCellCount );
1073 fprintf( pFile, "%s", Vec_StrArray(vStr) );
1074 Vec_StrFree( vStr );
1075 fclose( pFile );
1076 printf( "Written GENLIB library with %d gates into file \"%s\".\n", nCellCount, FileName );
1077}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
Vec_Str_t * Abc_SclProduceGenlibStr(SC_Lib *p, float Slew, float Gain, int nGatesMin, int fUseAll, int *pnCellCount)
Definition sclLibUtil.c:870
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition sclLibUtil.c:452
char * sprintf()
Here is the call graph for this function:

◆ Abc_SclFetchWireLoadModel()

SC_WireLoad * Abc_SclFetchWireLoadModel ( SC_Lib * p,
char * pWLoadUsed )
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 365 of file sclLibUtil.c.

366{
367 SC_WireLoad * pWL = NULL;
368 int i;
369 // Get the actual table and reformat it for 'wire_cap' output:
370 assert( pWLoadUsed != NULL );
371 SC_LibForEachWireLoad( p, pWL, i )
372 if ( !strcmp(pWL->pName, pWLoadUsed) )
373 break;
374 if ( i == Vec_PtrSize(&p->vWireLoads) )
375 {
376 Abc_Print( -1, "Cannot find wire load model \"%s\".\n", pWLoadUsed );
377 exit(1);
378 }
379// printf( "Using wireload model \"%s\".\n", pWL->pName );
380 return pWL;
381}
#define SC_LibForEachWireLoad(p, pWL, i)
Definition sclLib.h:271
char * pName
Definition sclLib.h:132
#define assert(ex)
Definition util_old.h:213
int strcmp()
VOID_HACK exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclFindInvertor()

SC_Cell * Abc_SclFindInvertor ( SC_Lib * p,
int fFindBuff )
extern

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

Synopsis [Returns the largest inverter.]

Description []

SideEffects []

SeeAlso []

Definition at line 332 of file sclLibUtil.c.

333{
334 SC_Cell * pCell = NULL;
335 word Truth = fFindBuff ? ABC_CONST(0xAAAAAAAAAAAAAAAA) : ABC_CONST(0x5555555555555555);
336 int k;
337 SC_LibForEachCellClass( p, pCell, k )
338 if ( pCell->n_inputs == 1 && Vec_WrdEntry(&SC_CellPin(pCell, 1)->vFunc, 0) == Truth )
339 break;
340 // take representative
341 return pCell ? pCell->pRepr : NULL;
342}
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define SC_LibForEachCellClass(p, pCell, i)
Definition sclLib.h:270
int n_inputs
Definition sclLib.h:213
SC_Cell * pRepr
Definition sclLib.h:217
Here is the caller graph for this function:

◆ Abc_SclFindSmallestGate()

SC_Cell * Abc_SclFindSmallestGate ( SC_Cell * p,
float CinMin )
extern

Definition at line 343 of file sclLibUtil.c.

344{
345 SC_Cell * pRes = NULL;
346 int i;
347 SC_RingForEachCell( p->pRepr, pRes, i )
348 if ( SC_CellPinCapAve(pRes) > CinMin )
349 return pRes;
350 // take the largest gate
351 return p->pRepr->pPrev;
352}
Here is the caller graph for this function:

◆ Abc_SclFindWireLoadModel()

SC_WireLoad * Abc_SclFindWireLoadModel ( SC_Lib * p,
float Area )
extern

Definition at line 382 of file sclLibUtil.c.

383{
384 char * pWLoadUsed = NULL;
385 int i;
386 if ( p->default_wire_load_sel && strlen(p->default_wire_load_sel) )
387 {
388 SC_WireLoadSel * pWLS = NULL;
389 SC_LibForEachWireLoadSel( p, pWLS, i )
390 if ( !strcmp(pWLS->pName, p->default_wire_load_sel) )
391 break;
392 if ( i == Vec_PtrSize(&p->vWireLoadSels) )
393 {
394 Abc_Print( -1, "Cannot find wire load selection model \"%s\".\n", p->default_wire_load_sel );
395 exit(1);
396 }
397 for ( i = 0; i < Vec_FltSize(&pWLS->vAreaFrom); i++)
398 if ( Area >= Vec_FltEntry(&pWLS->vAreaFrom, i) && Area < Vec_FltEntry(&pWLS->vAreaTo, i) )
399 {
400 pWLoadUsed = (char *)Vec_PtrEntry(&pWLS->vWireLoadModel, i);
401 break;
402 }
403 if ( i == Vec_FltSize(&pWLS->vAreaFrom) )
404 pWLoadUsed = (char *)Vec_PtrEntryLast(&pWLS->vWireLoadModel);
405 }
406 else if ( p->default_wire_load && strlen(p->default_wire_load) )
407 pWLoadUsed = p->default_wire_load;
408 else
409 {
410// Abc_Print( 0, "No wire model given.\n" );
411 return NULL;
412 }
413 return Abc_SclFetchWireLoadModel( p, pWLoadUsed );
414}
SC_WireLoad * Abc_SclFetchWireLoadModel(SC_Lib *p, char *pWLoadUsed)
Definition sclLibUtil.c:365
#define SC_LibForEachWireLoadSel(p, pWLS, i)
Definition sclLib.h:272
Vec_Flt_t vAreaFrom
Definition sclLib.h:142
char * pName
Definition sclLib.h:141
Vec_Flt_t vAreaTo
Definition sclLib.h:143
Vec_Ptr_t vWireLoadModel
Definition sclLib.h:144
int strlen()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclHasDelayInfo()

int Abc_SclHasDelayInfo ( void * pScl)
extern

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 427 of file sclLibUtil.c.

428{
429 SC_Lib * p = (SC_Lib *)pScl;
430 SC_Cell * pCell;
431 SC_Timing * pTime;
432 pCell = Abc_SclFindInvertor(p, 0);
433 if ( pCell == NULL )
434 return 0;
435 pTime = Scl_CellPinTime( pCell, 0 );
436 if ( pTime == NULL )
437 return 0;
438 return 1;
439}
struct SC_Lib_ SC_Lib
Definition sclLib.h:128
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclHashCells()

void Abc_SclHashCells ( SC_Lib * p)
extern

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 if ( *pPlace != -1 && pCell->pName )
76 printf( "There are two standard cells with the same name (%s).\n", pCell->pName );
77 assert( *pPlace == -1 );
78 *pPlace = i;
79 }
80}
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
char * pName
Definition sclLib.h:202
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclInstallGenlib()

void Abc_SclInstallGenlib ( void * pScl,
float SlewInit,
float Gain,
int fUseAll,
int nGatesMin )
extern

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

Synopsis [Install library.]

Description []

SideEffects []

SeeAlso []

Definition at line 1109 of file sclLibUtil.c.

1110{
1111 SC_Lib * p = (SC_Lib *)pScl;
1112 Vec_Str_t * vStr, * vStr2;
1113 float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
1114 int RetValue, nGateCount = SC_LibCellNum(p);
1115 if ( Gain == 0 )
1117 else
1118 vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, fUseAll, &nGateCount );
1119 vStr2 = Vec_StrDup( vStr );
1120 RetValue = Mio_UpdateGenlib2( vStr, vStr2, p->pName, 0 );
1121 Vec_StrFree( vStr );
1122 Vec_StrFree( vStr2 );
1123 if ( !RetValue )
1124 printf( "Reading library has filed.\n" );
1125 else if ( Gain != 0 )
1126 printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nGateCount, Slew, Gain );
1127// else
1128// printf( "Derived unit-delay GENLIB library \"%s\" with %d gates.\n", p->pName, nGateCount );
1129}
int Mio_UpdateGenlib2(Vec_Str_t *vStr, Vec_Str_t *vStr2, char *pFileName, int fVerbose)
Definition mio.c:260
Vec_Str_t * Abc_SclProduceGenlibStrSimple(SC_Lib *p)
Definition sclLibUtil.c:798
Here is the call graph for this function:

◆ Abc_SclLibClassNum()

int Abc_SclLibClassNum ( SC_Lib * pLib)
extern

Definition at line 95 of file sclLibUtil.c.

96{
97 SC_Cell * pRepr;
98 int i, Count = 0;
99 SC_LibForEachCellClass( pLib, pRepr, i )
100 Count++;
101 return Count;
102}
Here is the caller graph for this function:

◆ Abc_SclLibNormalize()

void Abc_SclLibNormalize ( SC_Lib * p)
extern

Definition at line 750 of file sclLibUtil.c.

751{
752 SC_WireLoad * pWL;
753 SC_Cell * pCell;
754 SC_Pin * pPin;
755 SC_Timings * pTimings;
756 SC_Timing * pTiming;
757 int i, k, m, n;
758 float Time = 1.0 * pow(10.0, 12 - p->unit_time);
759 float Load = p->unit_cap_fst * pow(10.0, 15 - p->unit_cap_snd);
760 if ( Time == 1 && Load == 1 )
761 return;
762 p->unit_time = 12;
763 p->unit_cap_fst = 1;
764 p->unit_cap_snd = 15;
765 p->default_max_out_slew *= Time;
766 SC_LibForEachWireLoad( p, pWL, i )
767 pWL->cap *= Load;
768 SC_LibForEachCell( p, pCell, i )
769 SC_CellForEachPin( pCell, pPin, k )
770 {
771 pPin->cap *= Load;
772 pPin->rise_cap *= Load;
773 pPin->fall_cap *= Load;
774 pPin->max_out_cap *= Load;
775 pPin->max_out_slew *= Time;
776 SC_PinForEachRTiming( pPin, pTimings, m )
777 Vec_PtrForEachEntry( SC_Timing *, &pTimings->vTimings, pTiming, n )
778 {
779 Abc_SclLibNormalizeSurface( &pTiming->pCellRise, Time, Load );
780 Abc_SclLibNormalizeSurface( &pTiming->pCellFall, Time, Load );
781 Abc_SclLibNormalizeSurface( &pTiming->pRiseTrans, Time, Load );
782 Abc_SclLibNormalizeSurface( &pTiming->pFallTrans, Time, Load );
783 }
784 }
785}
void Abc_SclLibNormalizeSurface(SC_Surface *p, float Time, float Load)
Definition sclLibUtil.c:738
#define SC_CellForEachPin(p, pPin, i)
Definition sclLib.h:274
#define SC_PinForEachRTiming(p, pRTime, i)
Definition sclLib.h:279
float max_out_cap
Definition sclLib.h:192
float rise_cap
Definition sclLib.h:188
float fall_cap
Definition sclLib.h:189
float cap
Definition sclLib.h:187
float max_out_slew
Definition sclLib.h:193
SC_Surface pRiseTrans
Definition sclLib.h:173
SC_Surface pFallTrans
Definition sclLib.h:174
SC_Surface pCellFall
Definition sclLib.h:172
Vec_Ptr_t vTimings
Definition sclLib.h:180
float cap
Definition sclLib.h:133
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclLinkCells()

void Abc_SclLinkCells ( SC_Lib * p)
extern

Definition at line 264 of file sclLibUtil.c.

265{
266 Vec_Ptr_t * vList;
267 SC_Cell * pCell, * pRepr = NULL;
268 int i, k;
269 assert( Vec_PtrSize(&p->vCellClasses) == 0 );
270 SC_LibForEachCell( p, pCell, i )
271 {
272 // find gate with the same function
273 SC_LibForEachCellClass( p, pRepr, k )
274 if ( pCell->n_inputs == pRepr->n_inputs &&
275 pCell->n_outputs == pRepr->n_outputs &&
276 Vec_WrdEqual(SC_CellFunc(pCell), SC_CellFunc(pRepr)) )
277 break;
278 if ( k == Vec_PtrSize(&p->vCellClasses) )
279 {
280 Vec_PtrPush( &p->vCellClasses, pCell );
281 pCell->pNext = pCell->pPrev = pCell;
282 continue;
283 }
284 // add it to the list before the cell
285 pRepr->pPrev->pNext = pCell; pCell->pNext = pRepr;
286 pCell->pPrev = pRepr->pPrev; pRepr->pPrev = pCell;
287 }
288 // sort cells by size then by name
289 qsort( (void *)Vec_PtrArray(&p->vCellClasses), Vec_PtrSize(&p->vCellClasses), sizeof(void *), (int(*)(const void *,const void *))Abc_SclCompareCells );
290 // sort cell lists
291 vList = Vec_PtrAlloc( 100 );
292 SC_LibForEachCellClass( p, pRepr, k )
293 {
294 Vec_PtrClear( vList );
295 SC_RingForEachCell( pRepr, pCell, i )
296 Vec_PtrPush( vList, pCell );
297 qsort( (void *)Vec_PtrArray(vList), (size_t)Vec_PtrSize(vList), sizeof(void *), (int(*)(const void *,const void *))Abc_SclCompareCells );
298 // create new representative
299 pRepr = (SC_Cell *)Vec_PtrEntry( vList, 0 );
300 pRepr->pNext = pRepr->pPrev = pRepr;
301 pRepr->pRepr = pRepr;
302 pRepr->pAve = (SC_Cell *)Vec_PtrEntry( vList, Vec_PtrSize(vList)/2 );
303 pRepr->Order = 0;
304 pRepr->nGates = Vec_PtrSize(vList);
305 // relink cells
306 Vec_PtrForEachEntryStart( SC_Cell *, vList, pCell, i, 1 )
307 {
308 pRepr->pPrev->pNext = pCell; pCell->pNext = pRepr;
309 pCell->pPrev = pRepr->pPrev; pRepr->pPrev = pCell;
310 pCell->pRepr = pRepr;
311 pCell->pAve = (SC_Cell *)Vec_PtrEntry( vList, Vec_PtrSize(vList)/2 );
312 pCell->Order = i;
313 pCell->nGates = Vec_PtrSize(vList);
314 }
315 // update list
316 Vec_PtrWriteEntry( &p->vCellClasses, k, pRepr );
317 }
318 Vec_PtrFree( vList );
319}
SC_Cell * pNext
Definition sclLib.h:215
int n_outputs
Definition sclLib.h:214
SC_Cell * pAve
Definition sclLib.h:218
SC_Cell * pPrev
Definition sclLib.h:216
int nGates
Definition sclLib.h:220
int Order
Definition sclLib.h:219
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the caller graph for this function:

◆ Abc_SclMergeLibraries()

SC_Lib * Abc_SclMergeLibraries ( SC_Lib * pLib1,
SC_Lib * pLib2,
int fUsePrefix )
extern

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

Synopsis [Appends cells of pLib2 to those of pLib1.]

Description []

SideEffects []

SeeAlso []

Definition at line 869 of file sclLibScl.c.

870{
871 Vec_Str_t * vOut = Vec_StrAlloc( 10000 );
872 int n_valid_cells2 = Abc_SclCountValidCells( pLib2 );
873 Abc_SclWriteLibrary( vOut, pLib1, n_valid_cells2, fUsePrefix );
874 Abc_SclWriteLibraryCellsOnly( vOut, pLib2, fUsePrefix ? 2 : 0 );
875 SC_Lib * p = Abc_SclReadFromStr( vOut );
876 p->pFileName = Abc_UtilStrsav( pLib1->pFileName );
877 p->pName = ABC_ALLOC( char, strlen(pLib1->pName) + strlen(pLib2->pName) + 10 );
878 sprintf( p->pName, "%s__and__%s", pLib1->pName, pLib2->pName );
879 Vec_StrFree( vOut );
880 printf( "Updated library \"%s\" with additional %d cells from library \"%s\".\n", pLib1->pName, n_valid_cells2, pLib2->pName );
881 return p;
882}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
int Abc_SclCountValidCells(SC_Lib *p)
Definition sclLibScl.c:564
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition sclLibScl.c:403
char * pFileName
Definition sclLib.h:226
char * pName
Definition sclLib.h:225
Here is the call graph for this function:

◆ Abc_SclPrintCells()

void Abc_SclPrintCells ( SC_Lib * p,
float Slew,
float Gain,
int fInvOnly,
int fShort )
extern

Definition at line 638 of file sclLibUtil.c.

639{
640 SC_Cell * pCell, * pRepr;
641 SC_Pin * pPin;
642 int i, j, k, nLength = 0;
643 float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
644 float LD = 0, PD = 0;
645 assert( Vec_PtrSize(&p->vCellClasses) > 0 );
646 printf( "Library \"%s\" ", p->pName );
647 printf( "has %d cells in %d classes. ",
648 Vec_PtrSize(&p->vCells), Vec_PtrSize(&p->vCellClasses) );
649 if ( !fShort )
650 printf( "Delay estimate is based on slew %.2f ps and gain %.2f.", Slew, Gain );
651 printf( "\n" );
653 // find the longest name
654 SC_LibForEachCellClass( p, pRepr, k )
655 SC_RingForEachCell( pRepr, pCell, i )
656 nLength = Abc_MaxInt( nLength, strlen(pRepr->pName) );
657 // print cells
658 SC_LibForEachCellClass( p, pRepr, k )
659 {
660 if ( fInvOnly && pRepr->n_inputs != 1 )
661 continue;
662 SC_CellForEachPinOut( pRepr, pPin, i )
663 {
664 if ( i == pRepr->n_inputs )
665 {
666 printf( "Class%4d : ", k );
667 printf( "Cells =%3d ", Abc_SclClassCellNum(pRepr) );
668 printf( "Ins =%2d ", pRepr->n_inputs );
669 printf( "Outs =%2d ", pRepr->n_outputs );
670 }
671 else
672 printf( " " );
673 if ( pPin->func_text )
674 printf( "%-30s", pPin->func_text );
675 printf( " " );
676 Kit_DsdPrintFromTruth( (unsigned *)Vec_WrdArray(&pPin->vFunc), pRepr->n_inputs );
677 printf( "\n" );
678 if ( fShort )
679 continue;
680 SC_RingForEachCell( pRepr, pCell, j )
681 {
682 printf( " %3d ", j+1 );
683 printf( "%s", pCell->fSkip ? "s" : " " );
684 printf( " : " );
685 printf( "%-*s ", nLength, pCell->pName );
686 printf( "%2d ", pCell->drive_strength );
687 printf( "A =%8.2f ", pCell->area );
688 printf( "L =%8.2f ", pCell->leakage );
689 if ( pCell->n_outputs == 1 )
690 {
691 if ( Abc_SclComputeParametersCell( p, pCell, Slew, &LD, &PD ) )
692 {
693 printf( "D =%6.1f ps ", 0.01 * Gain * LD + PD );
694 printf( "LD =%6.1f ps ", LD );
695 printf( "PD =%6.1f ps ", PD );
696 printf( "C =%5.1f ff ", SC_CellPinCapAve(pCell) );
697 printf( "Cm =%5.0f ff ", SC_CellPin(pCell, pCell->n_inputs)->max_out_cap );
698 printf( "Sm =%5.1f ps ", SC_CellPin(pCell, pCell->n_inputs)->max_out_slew );
699 }
700 }
701 printf( "\n" );
702 }
703 break;
704 }
705 }
706}
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition kitDsd.c:491
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition sclLibUtil.c:86
void Abc_SclMarkSkippedCells(SC_Lib *p)
Definition sclLibUtil.c:609
int Abc_SclComputeParametersCell(SC_Lib *p, SC_Cell *pCell, float Slew, float *pLD, float *pPD)
Definition sclLibUtil.c:515
#define SC_CellForEachPinOut(p, pPin, i)
Definition sclLib.h:276
int drive_strength
Definition sclLib.h:211
char * func_text
Definition sclLib.h:194
Vec_Wrd_t vFunc
Definition sclLib.h:195
Here is the call graph for this function:

◆ Abc_SclReadFromFile()

SC_Lib * Abc_SclReadFromFile ( char * pFileName)
extern

Definition at line 417 of file sclLibScl.c.

418{
419 SC_Lib * p;
420 FILE * pFile;
421 Vec_Str_t * vOut;
422 int nFileSize;
423 pFile = fopen( pFileName, "rb" );
424 if ( pFile == NULL )
425 {
426 printf( "Cannot open file \"%s\" for reading.\n", pFileName );
427 return NULL;
428 }
429 // get the file size, in bytes
430 fseek( pFile, 0, SEEK_END );
431 nFileSize = ftell( pFile );
432 rewind( pFile );
433 // load the contents
434 vOut = Vec_StrAlloc( nFileSize );
435 vOut->nSize = vOut->nCap;
436 assert( nFileSize == Vec_StrSize(vOut) );
437 nFileSize = fread( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
438 assert( nFileSize == Vec_StrSize(vOut) );
439 fclose( pFile );
440 // read the library
441 p = Abc_SclReadFromStr( vOut );
442 if ( p != NULL )
443 p->pFileName = Abc_UtilStrsav( pFileName );
444 if ( p != NULL )
446 Vec_StrFree( vOut );
447 return p;
448}
void Abc_SclLibNormalize(SC_Lib *p)
Definition sclLibUtil.c:750
int nCap
Definition bblif.c:49
int nSize
Definition bblif.c:50
VOID_HACK rewind()
#define SEEK_END
Definition zconf.h:392
Here is the call graph for this function:

◆ Abc_SclReadFromGenlib()

SC_Lib * Abc_SclReadFromGenlib ( void * pLib)
extern

Definition at line 169 of file sclLibScl.c.

170{
171 Mio_Library_t * pLib = (Mio_Library_t *)pLib0;
172 SC_Lib * p = Abc_SclLibAlloc();
173 if ( !Abc_SclReadLibraryGenlib( p, pLib ) )
174 return NULL;
175 // hash gates by name
178 return p;
179}
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
void Abc_SclHashCells(SC_Lib *p)
Definition sclLibUtil.c:65
void Abc_SclLinkCells(SC_Lib *p)
Definition sclLibUtil.c:264
Here is the call graph for this function:

◆ Abc_SclReadFromStr()

SC_Lib * Abc_SclReadFromStr ( Vec_Str_t * vOut)
extern

Definition at line 403 of file sclLibScl.c.

404{
405 SC_Lib * p;
406 int Pos = 0;
407 // read the library
408 p = Abc_SclLibAlloc();
409 if ( !Abc_SclReadLibrary( vOut, &Pos, p ) )
410 return NULL;
411 assert( Pos == Vec_StrSize(vOut) );
412 // hash gates by name
415 return p;
416}
ush Pos
Definition deflate.h:88
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclReadLiberty()

SC_Lib * Abc_SclReadLiberty ( char * pFileName,
int fVerbose,
int fVeryVerbose,
SC_DontUse dont_use,
int fSkipMultiOuts )
extern

Definition at line 1768 of file sclLiberty.c.

1769{
1770 SC_Lib * pLib;
1771 Scl_Tree_t * p;
1772 Vec_Str_t * vStr;
1773 p = Scl_LibertyParse( pFileName, fVeryVerbose );
1774 if ( p == NULL )
1775 return NULL;
1776// Scl_LibertyParseDump( p, "temp_.lib" );
1777 // collect relevant data
1778 vStr = Scl_LibertyReadSclStr( p, fVerbose, fVeryVerbose, dont_use, fSkipMultiOuts );
1779 Scl_LibertyStop( p, fVeryVerbose );
1780 if ( vStr == NULL )
1781 return NULL;
1782 // construct SCL data-structure
1783 pLib = Abc_SclReadFromStr( vStr );
1784 if ( pLib == NULL )
1785 return NULL;
1786 pLib->pFileName = Abc_UtilStrsav( pFileName );
1787 Abc_SclLibNormalize( pLib );
1788 Vec_StrFree( vStr );
1789// printf( "Average slew = %.2f ps\n", Abc_SclComputeAverageSlew(pLib) );
1790 return pLib;
1791}
SC_Lib * Abc_SclReadFromStr(Vec_Str_t *vOut)
Definition sclLibScl.c:403
void Scl_LibertyStop(Scl_Tree_t *p, int fVerbose)
Definition sclLiberty.c:659
Scl_Tree_t * Scl_LibertyParse(char *pFileName, int fVerbose)
Definition sclLiberty.c:673
struct Scl_Tree_t_ Scl_Tree_t
Definition sclLiberty.c:69
Vec_Str_t * Scl_LibertyReadSclStr(Scl_Tree_t *p, int fVerbose, int fVeryVerbose, SC_DontUse dont_use, int fSkipMultiOuts)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclShortNames()

void Abc_SclShortNames ( SC_Lib * p)
extern

Definition at line 195 of file sclLibUtil.c.

196{
197 char Buffer[10000];
198 SC_Cell * pClass, * pCell; SC_Pin * pPin;
199 int i, k, n, nClasses = Abc_SclLibClassNum(p);
200 unsigned char nDigits = (unsigned char)Abc_Base10Log( nClasses );
201 // itereate through classes
202 SC_LibForEachCellClass( p, pClass, i )
203 {
204 unsigned char nDigits2 = (unsigned char)Abc_Base10Log( Abc_SclClassCellNum(pClass) );
205 SC_RingForEachCell( pClass, pCell, k )
206 {
207 ABC_FREE( pCell->pName );
208 sprintf( Buffer, "g%0*d_%0*d", nDigits, i, nDigits2, k );
209 pCell->pName = Abc_UtilStrsav( Buffer );
210 // formula
211 SC_CellForEachPinOut( pCell, pPin, n )
212 Abc_SclPinUpdate( pCell, pPin, Buffer );
213 // pin names
214 SC_CellForEachPinIn( pCell, pPin, n )
215 {
216 ABC_FREE( pPin->pName );
217 sprintf( Buffer, "%c", (char)('a'+n) );
218 pPin->pName = Abc_UtilStrsav( Buffer );
219 }
220 SC_CellForEachPinOut( pCell, pPin, n )
221 {
222 ABC_FREE( pPin->pName );
223 sprintf( Buffer, "%c", (char)('z'-n+pCell->n_inputs) );
224 pPin->pName = Abc_UtilStrsav( Buffer );
225 }
226 }
227 }
228 p->nBins = 0;
229 ABC_FREE( p->pBins );
231 // update library name
232 printf( "Renaming library \"%s\" into \"%s%d\".\n", p->pName, "lib", SC_LibCellNum(p) );
233 ABC_FREE( p->pName );
234 sprintf( Buffer, "lib%d", SC_LibCellNum(p) );
235 p->pName = Abc_UtilStrsav( Buffer );
236}
#define ABC_FREE(obj)
Definition abc_global.h:267
int Abc_SclLibClassNum(SC_Lib *pLib)
Definition sclLibUtil.c:95
void Abc_SclHashCells(SC_Lib *p)
Definition sclLibUtil.c:65
#define SC_CellForEachPinIn(p, pPin, i)
Definition sclLib.h:275
char * pName
Definition sclLib.h:185
Here is the call graph for this function:

◆ Abc_SclWriteLiberty()

void Abc_SclWriteLiberty ( char * pFileName,
SC_Lib * p )
extern

Definition at line 845 of file sclLibScl.c.

846{
847 FILE * pFile = fopen( pFileName, "wb" );
848 if ( pFile == NULL )
849 printf( "Cannot open text file \"%s\" for writing.\n", pFileName );
850 else
851 {
852 Abc_SclWriteLibraryText( pFile, p );
853 fclose( pFile );
854 printf( "Dumped internal library with %d cells into Liberty file \"%s\".\n", SC_LibCellNum(p), pFileName );
855 }
856}

◆ Abc_SclWriteScl()

void Abc_SclWriteScl ( char * pFileName,
SC_Lib * p )
extern

Definition at line 629 of file sclLibScl.c.

630{
631 Vec_Str_t * vOut;
632 vOut = Vec_StrAlloc( 10000 );
633 Abc_SclWriteLibrary( vOut, p, 0, 0 );
634 if ( Vec_StrSize(vOut) > 0 )
635 {
636 FILE * pFile = fopen( pFileName, "wb" );
637 if ( pFile == NULL )
638 printf( "Cannot open file \"%s\" for writing.\n", pFileName );
639 else
640 {
641 fwrite( Vec_StrArray(vOut), 1, Vec_StrSize(vOut), pFile );
642 fclose( pFile );
643 }
644 }
645 Vec_StrFree( vOut );
646}