ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sclLibUtil.c File Reference
#include "sclLib.h"
#include "misc/st/st.h"
#include "map/mio/mio.h"
#include "bool/kit/kit.h"
Include dependency graph for sclLibUtil.c:

Go to the source code of this file.

Functions

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)
 
void Abc_SclShortFormula (SC_Cell *pCell, char *pForm, char *pBuffer)
 
void Abc_SclShortNames (SC_Lib *p)
 
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 fUseAll, int *pnCellCount)
 
Vec_Str_tAbc_SclProduceGenlibStrProfile (SC_Lib *p, Mio_Library_t *pLib, 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, void *pMio, float SlewInit, float Gain, int nGatesMin, int fVerbose)
 
void Abc_SclInstallGenlib (void *pScl, float SlewInit, float Gain, int fUseAll, int nGatesMin)
 

Function Documentation

◆ Abc_SclCellFind()

int Abc_SclCellFind ( SC_Lib * p,
char * pName )

Definition at line 81 of file sclLibUtil.c.

82{
83 int *pPlace = Abc_SclHashLookup( p, pName );
84 return pPlace ? *pPlace : -1;
85}
Cube * p
Definition exorList.c:222
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)

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
struct SC_Cell_ SC_Cell
Definition sclLib.h:127
int fSkip
Definition sclLib.h:204
Here is the caller graph for this function:

◆ Abc_SclComputeAreaClass()

float Abc_SclComputeAreaClass ( SC_Cell * pRepr)

Definition at line 583 of file sclLibUtil.c.

584{
585 SC_Cell * pCell;
586 float Area = 0;
587 int i, Count = 0;
588 SC_RingForEachCell( pRepr, pCell, i )
589 {
590 if ( pCell->fSkip )
591 continue;
592 Area += pCell->area;
593 Count++;
594 }
595 return Area / Abc_MaxInt(1, Count);
596}
float area
Definition sclLib.h:207

◆ Abc_SclComputeAverageSlew()

float Abc_SclComputeAverageSlew ( SC_Lib * p)

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_SclComputeDelayCellPin()

float Abc_SclComputeDelayCellPin ( SC_Lib * p,
SC_Cell * pCell,
int iPin,
float Slew,
float Gain )

Definition at line 561 of file sclLibUtil.c.

562{
563 float LD = 0, PD = 0;
564 Abc_SclComputeParametersPin( p, pCell, iPin, Slew, &LD, &PD );
565 return 0.01 * LD * Gain + PD;
566}
int Abc_SclComputeParametersPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float *pLD, float *pPD)
Definition sclLibUtil.c:478
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclComputeDelayClassPin()

float Abc_SclComputeDelayClassPin ( SC_Lib * p,
SC_Cell * pRepr,
int iPin,
float Slew,
float Gain )

Definition at line 567 of file sclLibUtil.c.

568{
569 SC_Cell * pCell;
570 float Delay = 0;
571 int i, Count = 0;
572 SC_RingForEachCell( pRepr, pCell, i )
573 {
574 if ( pCell->fSkip )
575 continue;
576// if ( pRepr == pCell ) // skip the first gate
577// continue;
578 Delay += Abc_SclComputeDelayCellPin( p, pCell, iPin, Slew, Gain );
579 Count++;
580 }
581 return Delay / Abc_MaxInt(1, Count);
582}
float Abc_SclComputeDelayCellPin(SC_Lib *p, SC_Cell *pCell, int iPin, float Slew, float Gain)
Definition sclLibUtil.c:561
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclComputeParametersCell()

int Abc_SclComputeParametersCell ( SC_Lib * p,
SC_Cell * pCell,
float Slew,
float * pLD,
float * pPD )

Definition at line 515 of file sclLibUtil.c.

516{
517 SC_Pin * pPin;
518 float LD, PD, ld, pd;
519 int i;
520 LD = PD = ld = pd = 0;
521 SC_CellForEachPinIn( pCell, pPin, i )
522 {
523 if ( !Abc_SclComputeParametersPin( p, pCell, i, Slew, &ld, &pd ) )
524 return 0;
525 LD += ld; PD += pd;
526 }
527 *pLD = LD / Abc_MaxInt(1, pCell->n_inputs);
528 *pPD = PD / Abc_MaxInt(1, pCell->n_inputs);
529 return 1;
530}
#define SC_CellForEachPinIn(p, pPin, i)
Definition sclLib.h:275
struct SC_Pin_ SC_Pin
Definition sclLib.h:126
int n_inputs
Definition sclLib.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclComputeParametersClass()

void Abc_SclComputeParametersClass ( SC_Lib * p,
SC_Cell * pRepr,
float Slew,
float * pLD,
float * pPD )

Definition at line 531 of file sclLibUtil.c.

532{
533 SC_Cell * pCell;
534 float LD, PD, ld, pd;
535 int i, Count = 0;
536 LD = PD = ld = pd = 0;
537 SC_RingForEachCell( pRepr, pCell, i )
538 {
539 Abc_SclComputeParametersCell( p, pCell, Slew, &ld, &pd );
540 LD += ld; PD += pd;
541 Count++;
542 }
543 *pLD = LD / Abc_MaxInt(1, Count);
544 *pPD = PD / Abc_MaxInt(1, Count);
545}
int Abc_SclComputeParametersCell(SC_Lib *p, SC_Cell *pCell, float Slew, float *pLD, float *pPD)
Definition sclLibUtil.c:515
Here is the call graph for this function:

◆ Abc_SclComputeParametersClassPin()

void Abc_SclComputeParametersClassPin ( SC_Lib * p,
SC_Cell * pRepr,
int iPin,
float Slew,
float * pLD,
float * pPD )

Definition at line 546 of file sclLibUtil.c.

547{
548 SC_Cell * pCell;
549 float LD, PD, ld, pd;
550 int i, Count = 0;
551 LD = PD = ld = pd = 0;
552 SC_RingForEachCell( pRepr, pCell, i )
553 {
554 Abc_SclComputeParametersPin( p, pCell, iPin, Slew, &ld, &pd );
555 LD += ld; PD += pd;
556 Count++;
557 }
558 *pLD = LD / Abc_MaxInt(1, Count);
559 *pPD = PD / Abc_MaxInt(1, Count);
560}
Here is the call graph for this function:

◆ Abc_SclComputeParametersPin()

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 478 of file sclLibUtil.c.

479{
480 SC_Pair Load0, Load1, Load2;
481 SC_Pair ArrIn = { 0.0, 0.0 };
482 SC_Pair SlewIn = { Slew, Slew };
483 SC_Pair ArrOut0 = { 0.0, 0.0 };
484 SC_Pair ArrOut1 = { 0.0, 0.0 };
485 SC_Pair ArrOut2 = { 0.0, 0.0 };
486 SC_Pair SlewOut = { 0.0, 0.0 };
487 SC_Timing * pTime = Scl_CellPinTime( pCell, iPin );
488 Vec_Flt_t * vIndex = pTime ? &pTime->pCellRise.vIndex1 : NULL; // capacitance
489 if ( vIndex == NULL )
490 return 0;
491 // handle constant table
492 if ( Vec_FltSize(vIndex) == 1 )
493 {
494 *pLD = 0;
495 *pPD = Vec_FltEntry( (Vec_Flt_t *)Vec_PtrEntry(&pTime->pCellRise.vData, 0), 0 );
496 return 1;
497 }
498 // get load points
499 Load0.rise = Load0.fall = 0.0;
500 Load1.rise = Load1.fall = Vec_FltEntry( vIndex, 0 );
501 Load2.rise = Load2.fall = Vec_FltEntry( vIndex, Vec_FltSize(vIndex) - 2 );
502 // compute delay
503 Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load0, &ArrOut0, &SlewOut );
504 Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load1, &ArrOut1, &SlewOut );
505 Scl_LibPinArrival( pTime, &ArrIn, &SlewIn, &Load2, &ArrOut2, &SlewOut );
506 ArrOut0.rise = 0.5 * ArrOut0.rise + 0.5 * ArrOut0.fall;
507 ArrOut1.rise = 0.5 * ArrOut1.rise + 0.5 * ArrOut1.fall;
508 ArrOut2.rise = 0.5 * ArrOut2.rise + 0.5 * ArrOut2.fall;
509 // get tangent
510 *pLD = (ArrOut2.rise - ArrOut1.rise) / ((Load2.rise - Load1.rise) / SC_CellPinCap(pCell, iPin));
511 // get constant
512 *pPD = ArrOut0.rise;
513 return 1;
514}
struct SC_Pair_ SC_Pair
Definition sclLib.h:69
float fall
Definition sclLib.h:73
float rise
Definition sclLib.h:72
Vec_Ptr_t vData
Definition sclLib.h:159
Vec_Flt_t vIndex1
Definition sclLib.h:158
Here is the caller graph for this function:

◆ Abc_SclConvertLeakageIntoArea()

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

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 leakage
Definition sclLib.h:208

◆ Abc_SclDeriveGenlib()

Mio_Library_t * Abc_SclDeriveGenlib ( void * pScl,
void * pMio,
float SlewInit,
float Gain,
int nGatesMin,
int fVerbose )

Definition at line 1078 of file sclLibUtil.c.

1079{
1080 int nCellCount = 0;
1081 SC_Lib * p = (SC_Lib *)pScl;
1082 float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
1083 Vec_Str_t * vStr;
1084 Mio_Library_t * pLib;
1085 if ( pMio == NULL )
1086 vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, 0, &nCellCount );
1087 else
1088 vStr = Abc_SclProduceGenlibStrProfile( p, (Mio_Library_t *)pMio, Slew, Gain, nGatesMin, &nCellCount );
1089 pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0, 0 );
1090 Vec_StrFree( vStr );
1091 if ( !pLib )
1092 printf( "Reading library has filed.\n" );
1093 else if ( fVerbose )
1094 printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nCellCount, Slew, Gain );
1095 return pLib;
1096}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int nFaninLimit, int fVerbose)
Definition mioRead.c:54
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
Vec_Str_t * Abc_SclProduceGenlibStrProfile(SC_Lib *p, Mio_Library_t *pLib, float Slew, float Gain, int nGatesMin, int *pnCellCount)
Definition sclLibUtil.c:987
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_SclDeriveGenlibSimple()

Mio_Library_t * Abc_SclDeriveGenlibSimple ( void * pScl)

Definition at line 845 of file sclLibUtil.c.

846{
847 SC_Lib * p = (SC_Lib *)pScl;
849 Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0, 0 );
850 Vec_StrFree( vStr );
851 if ( pLib )
852 printf( "Derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) );
853 else
854 printf( "Reading library has filed.\n" );
855 return pLib;
856}
Vec_Str_t * Abc_SclProduceGenlibStrSimple(SC_Lib *p)
Definition sclLibUtil.c:798
Here is the call graph for this function:

◆ Abc_SclDumpGenlib()

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

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}
char * sprintf()
Here is the call graph for this function:

◆ Abc_SclFetchWireLoadModel()

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 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
struct SC_WireLoad_ SC_WireLoad
STRUCTURE DEFINITIONS ///.
Definition sclLib.h:120
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 )

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
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 )

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 )

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
struct SC_WireLoadSel_ SC_WireLoadSel
Definition sclLib.h:121
#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)

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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclHashCells()

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 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_SclHashLookup()

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}
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 )

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
Here is the call graph for this function:

◆ Abc_SclLibClassNum()

int Abc_SclLibClassNum ( SC_Lib * pLib)

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)

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
struct SC_Timings_ SC_Timings
Definition sclLib.h:125
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
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclLibNormalizeSurface()

void Abc_SclLibNormalizeSurface ( SC_Surface * p,
float Time,
float Load )

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

Synopsis [Print cells]

Description []

SideEffects []

SeeAlso []

Definition at line 738 of file sclLibUtil.c.

739{
740 Vec_Flt_t * vArray;
741 int i, k; float Entry;
742 Vec_FltForEachEntry( &p->vIndex0, Entry, i ) // slew
743 Vec_FltWriteEntry( &p->vIndex0, i, Time * Entry );
744 Vec_FltForEachEntry( &p->vIndex1, Entry, i ) // load
745 Vec_FltWriteEntry( &p->vIndex1, i, Load * Entry );
746 Vec_PtrForEachEntry( Vec_Flt_t *, &p->vData, vArray, k )
747 Vec_FltForEachEntry( vArray, Entry, i ) // delay/slew
748 Vec_FltWriteEntry( vArray, i, Time * Entry );
749}
#define Vec_FltForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecFlt.h:54
Here is the caller graph for this function:

◆ Abc_SclLinkCells()

void Abc_SclLinkCells ( SC_Lib * p)

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
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
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_SclMarkSkippedCells()

void Abc_SclMarkSkippedCells ( SC_Lib * p)

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

Synopsis [Print cells]

Description []

SideEffects []

SeeAlso []

Definition at line 609 of file sclLibUtil.c.

610{
611 char FileName[1000];
612 char Buffer[1000], * pName;
613 SC_Cell * pCell;
614 FILE * pFile;
615 int CellId, nSkipped = 0;
616 sprintf( FileName, "%s.skip", p->pName );
617 pFile = fopen( FileName, "rb" );
618 if ( pFile == NULL )
619 return;
620 while ( fgets( Buffer, 999, pFile ) != NULL )
621 {
622 pName = strtok( Buffer, "\r\n\t " );
623 if ( pName == NULL )
624 continue;
625 CellId = Abc_SclCellFind( p, pName );
626 if ( CellId == -1 )
627 {
628 printf( "Cannot find cell \"%s\" in the library \"%s\".\n", pName, p->pName );
629 continue;
630 }
631 pCell = SC_LibCell( p, CellId );
632 pCell->fSkip = 1;
633 nSkipped++;
634 }
635 fclose( pFile );
636 printf( "Marked %d cells for skipping in the library \"%s\".\n", nSkipped, p->pName );
637}
int Abc_SclCellFind(SC_Lib *p, char *pName)
Definition sclLibUtil.c:81
char * strtok()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclPrintCells()

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

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
#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_SclProduceGenlibStr()

Vec_Str_t * Abc_SclProduceGenlibStr ( SC_Lib * p,
float Slew,
float Gain,
int nGatesMin,
int fUseAll,
int * pnCellCount )

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

Synopsis [Derive GENLIB library.]

Description []

SideEffects []

SeeAlso []

Definition at line 870 of file sclLibUtil.c.

871{
872 char Buffer[200];
873 Vec_Str_t * vStr;
874 SC_Cell * pRepr;
875 SC_Pin * pPin, * pPinOut;
876 int i, j, k, Count = 2, nClassMax = 0;
877 // find the largest number of cells in a class
878 SC_LibForEachCellClass( p, pRepr, i )
879 if ( pRepr->n_outputs == 1 )
880 nClassMax = Abc_MaxInt( nClassMax, Abc_SclClassCellNum(pRepr) );
881 // update the number
882 if ( nGatesMin && nGatesMin >= nClassMax )
883 nGatesMin = 0;
884 // mark skipped cells
886 vStr = Vec_StrAlloc( 1000 );
887 Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
888 Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
889 if ( fUseAll )
890 {
891 SC_LibForEachCell( p, pRepr, i )
892 {
893 if ( pRepr->n_inputs == 0 )
894 continue;
895 //if ( pRepr->n_outputs > 1 )
896 // continue;
897 if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
898 continue;
899 SC_CellForEachPinOut( pRepr, pPinOut, j )
900 {
901 SC_CellForEachPinIn( pRepr, pPin, k )
902 {
903 float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
904 if ( Delay <= 0 ) {
905 printf( "Cell %s cannot be used because delay of a pin is <= 0.\n", pRepr->pName );
906 break;
907 }
908 }
909 if ( k < pRepr->n_inputs )
910 break;
911 }
912 if ( j < pRepr->n_outputs )
913 continue;
914 SC_CellForEachPinOut( pRepr, pPinOut, j )
915 {
916 assert( strlen(pRepr->pName) < 200 );
917 Vec_StrPrintStr( vStr, "GATE " );
918 sprintf( Buffer, "%-16s", pRepr->pName );
919 Vec_StrPrintStr( vStr, Buffer );
920 Vec_StrPrintStr( vStr, " " );
921 // sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
922 sprintf( Buffer, "%7.2f", pRepr->area );
923 Vec_StrPrintStr( vStr, Buffer );
924 Vec_StrPrintStr( vStr, " " );
925 Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, j) );
926 Vec_StrPrintStr( vStr, "=" );
927 Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, j-pRepr->n_inputs) ? SC_CellPinOutFunc(pRepr, j-pRepr->n_inputs) : "?" );
928 Vec_StrPrintStr( vStr, ";\n" );
929 SC_CellForEachPinIn( pRepr, pPin, k )
930 {
931 float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
932 assert( Delay > 0 );
933 Vec_StrPrintStr( vStr, " PIN " );
934 sprintf( Buffer, "%-4s", pPin->pName );
935 Vec_StrPrintStr( vStr, Buffer );
936 sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
937 Vec_StrPrintStr( vStr, Buffer );
938 }
939 Count++;
940 }
941 }
942 }
943 else
944 {
945 SC_LibForEachCellClass( p, pRepr, i )
946 {
947 if ( pRepr->n_inputs == 0 )
948 continue;
949 if ( pRepr->n_outputs > 1 )
950 continue;
951 if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
952 continue;
953 assert( strlen(pRepr->pName) < 200 );
954 Vec_StrPrintStr( vStr, "GATE " );
955 sprintf( Buffer, "%-16s", pRepr->pName );
956 Vec_StrPrintStr( vStr, Buffer );
957 Vec_StrPrintStr( vStr, " " );
958 // sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
959 sprintf( Buffer, "%7.2f", pRepr->area );
960 Vec_StrPrintStr( vStr, Buffer );
961 Vec_StrPrintStr( vStr, " " );
962 Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
963 Vec_StrPrintStr( vStr, "=" );
964 Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
965 Vec_StrPrintStr( vStr, ";\n" );
966 SC_CellForEachPinIn( pRepr, pPin, k )
967 {
968 float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
969 assert( Delay > 0 );
970 Vec_StrPrintStr( vStr, " PIN " );
971 sprintf( Buffer, "%-4s", pPin->pName );
972 Vec_StrPrintStr( vStr, Buffer );
973 sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
974 Vec_StrPrintStr( vStr, Buffer );
975 }
976 Count++;
977 }
978 }
979 Vec_StrPrintStr( vStr, "\n.end\n" );
980 Vec_StrPush( vStr, '\0' );
981// printf( "GENLIB library with %d gates is produced:\n", Count );
982// printf( "%s", Vec_StrArray(vStr) );
983 if ( pnCellCount )
984 *pnCellCount = Count;
985 return vStr;
986}
float Abc_SclComputeDelayClassPin(SC_Lib *p, SC_Cell *pRepr, int iPin, float Slew, float Gain)
Definition sclLibUtil.c:567
int Abc_SclClassCellNum(SC_Cell *pClass)
Definition sclLibUtil.c:86
char * pName
Definition sclLib.h:185
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclProduceGenlibStrProfile()

Vec_Str_t * Abc_SclProduceGenlibStrProfile ( SC_Lib * p,
Mio_Library_t * pLib,
float Slew,
float Gain,
int nGatesMin,
int * pnCellCount )

Definition at line 987 of file sclLibUtil.c.

988{
989 char Buffer[200];
990 Vec_Str_t * vStr;
991 SC_Cell * pRepr;
992 SC_Pin * pPin;
993 int i, k, Count = 2, nClassMax = 0;
994 // find the largest number of cells in a class
995 SC_LibForEachCellClass( p, pRepr, i )
996 if ( pRepr->n_outputs == 1 )
997 nClassMax = Abc_MaxInt( nClassMax, Abc_SclClassCellNum(pRepr) );
998 // update the number
999 if ( nGatesMin && nGatesMin >= nClassMax )
1000 nGatesMin = 0;
1001 // mark skipped cells
1003 vStr = Vec_StrAlloc( 1000 );
1004 Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
1005 Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
1006 SC_LibForEachCell( p, pRepr, i )
1007 {
1008 if ( pRepr->n_inputs == 0 )
1009 continue;
1010 if ( pRepr->n_outputs > 1 )
1011 continue;
1012 if ( nGatesMin && pRepr->n_inputs > 2 && Abc_SclClassCellNum(pRepr) < nGatesMin )
1013 continue;
1014 // check if the gate is in the profile
1015 if ( pRepr->n_inputs > 1 )
1016 {
1017 Mio_Gate_t * pGate = Mio_LibraryReadGateByName( pLib, pRepr->pName, NULL );
1018 if ( pGate == NULL || Mio_GateReadProfile(pGate) == 0 )
1019 continue;
1020 }
1021 // process gate
1022 assert( strlen(pRepr->pName) < 200 );
1023 Vec_StrPrintStr( vStr, "GATE " );
1024 sprintf( Buffer, "%-16s", pRepr->pName );
1025 Vec_StrPrintStr( vStr, Buffer );
1026 Vec_StrPrintStr( vStr, " " );
1027// sprintf( Buffer, "%7.2f", Abc_SclComputeAreaClass(pRepr) );
1028 sprintf( Buffer, "%7.2f", pRepr->area );
1029 Vec_StrPrintStr( vStr, Buffer );
1030 Vec_StrPrintStr( vStr, " " );
1031 Vec_StrPrintStr( vStr, SC_CellPinName(pRepr, pRepr->n_inputs) );
1032 Vec_StrPrintStr( vStr, "=" );
1033 Vec_StrPrintStr( vStr, SC_CellPinOutFunc(pRepr, 0) ? SC_CellPinOutFunc(pRepr, 0) : "?" );
1034 Vec_StrPrintStr( vStr, ";\n" );
1035 SC_CellForEachPinIn( pRepr, pPin, k )
1036 {
1037 float Delay = Abc_SclComputeDelayClassPin( p, pRepr, k, Slew, Gain );
1038 assert( Delay > 0 );
1039 Vec_StrPrintStr( vStr, " PIN " );
1040 sprintf( Buffer, "%-4s", pPin->pName );
1041 Vec_StrPrintStr( vStr, Buffer );
1042 sprintf( Buffer, " UNKNOWN 1 999 %7.2f 0.00 %7.2f 0.00\n", Delay, Delay );
1043 Vec_StrPrintStr( vStr, Buffer );
1044 }
1045 Count++;
1046 }
1047 Vec_StrPrintStr( vStr, "\n.end\n" );
1048 Vec_StrPush( vStr, '\0' );
1049// printf( "GENLIB library with %d gates is produced:\n", Count );
1050// printf( "%s", Vec_StrArray(vStr) );
1051 if ( pnCellCount )
1052 *pnCellCount = Count;
1053 return vStr;
1054}
int Mio_GateReadProfile(Mio_Gate_t *pGate)
Definition mioApi.c:185
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition mioApi.c:105
struct Mio_GateStruct_t_ Mio_Gate_t
Definition mio.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclProduceGenlibStrSimple()

Vec_Str_t * Abc_SclProduceGenlibStrSimple ( SC_Lib * p)

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

Synopsis [Derives simple GENLIB library.]

Description []

SideEffects []

SeeAlso []

Definition at line 798 of file sclLibUtil.c.

799{
800 char Buffer[200];
801 Vec_Str_t * vStr;
802 SC_Cell * pCell;
803 SC_Pin * pPin, * pPinOut;
804 int i, j, k, Count = 2;
805 // mark skipped cells
806// Abc_SclMarkSkippedCells( p );
807 vStr = Vec_StrAlloc( 1000 );
808 Vec_StrPrintStr( vStr, "GATE _const0_ 0.00 z=CONST0;\n" );
809 Vec_StrPrintStr( vStr, "GATE _const1_ 0.00 z=CONST1;\n" );
810 SC_LibForEachCell( p, pCell, i )
811 {
812 if ( pCell->n_inputs == 0 )
813 continue;
814 assert( strlen(pCell->pName) < 200 );
815 SC_CellForEachPinOut( pCell, pPinOut, j )
816 {
817 Vec_StrPrintStr( vStr, "GATE " );
818 sprintf( Buffer, "%-16s", pCell->pName );
819 Vec_StrPrintStr( vStr, Buffer );
820 Vec_StrPrintStr( vStr, " " );
821 sprintf( Buffer, "%7.2f", pCell->area );
822 Vec_StrPrintStr( vStr, Buffer );
823 Vec_StrPrintStr( vStr, " " );
824 Vec_StrPrintStr( vStr, pPinOut->pName );
825 Vec_StrPrintStr( vStr, "=" );
826 Vec_StrPrintStr( vStr, pPinOut->func_text ? pPinOut->func_text : "?" );
827 Vec_StrPrintStr( vStr, ";\n" );
828 SC_CellForEachPinIn( pCell, pPin, k )
829 {
830 Vec_StrPrintStr( vStr, " PIN " );
831 sprintf( Buffer, "%-4s", pPin->pName );
832 Vec_StrPrintStr( vStr, Buffer );
833 sprintf( Buffer, " UNKNOWN 1 999 1.00 0.00 1.00 0.00\n" );
834 Vec_StrPrintStr( vStr, Buffer );
835 }
836 Count++;
837 }
838 }
839 Vec_StrPrintStr( vStr, "\n.end\n" );
840 Vec_StrPush( vStr, '\0' );
841// printf( "GENLIB library with %d gates is produced:\n", Count );
842// printf( "%s", Vec_StrArray(vStr) );
843 return vStr;
844}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_SclShortFormula()

void Abc_SclShortFormula ( SC_Cell * pCell,
char * pForm,
char * pBuffer )

Definition at line 134 of file sclLibUtil.c.

135{
136 SC_Pin * pPin; int i;
137 char * pTemp, * pLimit;
138 for ( pTemp = pForm; *pTemp; )
139 {
140 if ( !Abc_SclIsChar(*pTemp) )
141 {
142 *pBuffer++ = *pTemp++;
143 continue;
144 }
145 pLimit = Abc_SclFindLimit( pTemp );
146 SC_CellForEachPinIn( pCell, pPin, i )
147 if ( Abc_SclAreEqual( pPin->pName, pTemp, pLimit ) )
148 {
149 *pBuffer++ = 'a' + i;
150 break;
151 }
152 assert( i < pCell->n_inputs );
153 pTemp = pLimit;
154 }
155 *pBuffer++ = 0;
156}

◆ Abc_SclShortNames()

void Abc_SclShortNames ( SC_Lib * p)

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
Here is the call graph for this function: