2012-08-25 06:31:46 +02:00
|
|
|
/**CFile****************************************************************
|
|
|
|
|
|
2013-07-22 02:55:15 +02:00
|
|
|
FileName [sclLib.h]
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
SystemName [ABC: Logic synthesis and verification system.]
|
|
|
|
|
|
2012-08-30 01:20:39 +02:00
|
|
|
PackageName [Standard-cell library representation.]
|
|
|
|
|
|
|
|
|
|
Synopsis [Simplified library representation for STA.]
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
Author [Alan Mishchenko, Niklas Een]
|
|
|
|
|
|
|
|
|
|
Affiliation [UC Berkeley]
|
|
|
|
|
|
|
|
|
|
Date [Ver. 1.0. Started - August 24, 2012.]
|
|
|
|
|
|
2013-07-22 02:55:15 +02:00
|
|
|
Revision [$Id: sclLib.h,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
2013-07-22 02:55:15 +02:00
|
|
|
#ifndef ABC__map__scl__sclLib_h
|
|
|
|
|
#define ABC__map__scl__sclLib_h
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// INCLUDES ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <assert.h>
|
2012-08-29 09:48:36 +02:00
|
|
|
#include <math.h>
|
2013-07-22 02:55:15 +02:00
|
|
|
#include "misc/vec/vec.h"
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
ABC_NAMESPACE_HEADER_START
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// PARAMETERS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-03-27 04:19:50 +01:00
|
|
|
#define ABC_SCL_CUR_VERSION 6
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
sc_dir_NULL,
|
|
|
|
|
sc_dir_Input,
|
|
|
|
|
sc_dir_Output,
|
|
|
|
|
sc_dir_InOut,
|
|
|
|
|
sc_dir_Internal,
|
|
|
|
|
} SC_Dir;
|
|
|
|
|
|
|
|
|
|
typedef enum // -- timing sense, positive-, negative- or non-unate
|
|
|
|
|
{
|
|
|
|
|
sc_ts_NULL,
|
|
|
|
|
sc_ts_Pos,
|
|
|
|
|
sc_ts_Neg,
|
|
|
|
|
sc_ts_Non,
|
|
|
|
|
} SC_TSense;
|
|
|
|
|
|
2012-09-04 21:22:59 +02:00
|
|
|
typedef struct SC_SizePars_ SC_SizePars;
|
|
|
|
|
struct SC_SizePars_
|
2012-10-10 06:14:32 +02:00
|
|
|
{
|
|
|
|
|
int nIters;
|
|
|
|
|
int nIterNoChange;
|
2013-07-21 23:56:30 +02:00
|
|
|
int Window; // used for upsizing
|
|
|
|
|
int Ratio; // used for upsizing
|
2012-10-10 06:14:32 +02:00
|
|
|
int Notches;
|
2013-07-21 23:56:30 +02:00
|
|
|
int DelayUser;
|
|
|
|
|
int DelayGap;
|
2013-07-21 04:11:29 +02:00
|
|
|
int TimeOut;
|
|
|
|
|
int fUseDept;
|
|
|
|
|
int fDumpStats;
|
2013-07-21 08:19:28 +02:00
|
|
|
int fUseWireLoads;
|
2013-07-21 04:11:29 +02:00
|
|
|
int fVerbose;
|
|
|
|
|
int fVeryVerbose;
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-22 02:55:15 +02:00
|
|
|
typedef struct SC_Pair_ SC_Pair;
|
|
|
|
|
struct SC_Pair_
|
|
|
|
|
{
|
|
|
|
|
float rise;
|
|
|
|
|
float fall;
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-25 06:31:46 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// STRUCTURE DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
typedef struct SC_WireLoad_ SC_WireLoad;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
struct SC_WireLoad_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-27 22:50:33 +02:00
|
|
|
float res; // (currently not used)
|
|
|
|
|
float cap; // }- multiply estimation in 'fanout_len[].snd' with this value
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Int_t * vFanout; // Vec<Pair<uint,float> > -- pairs '(#fanouts, est-wire-len)'
|
|
|
|
|
Vec_Flt_t * vLen;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_WireLoadSel_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Flt_t * vAreaFrom; // Vec<Trip<float,float,Str> > -- triplets '(from-area, upto-area, wire-load-model)'; range is [from, upto[
|
|
|
|
|
Vec_Flt_t * vAreaTo;
|
|
|
|
|
Vec_Ptr_t * vWireLoadModel;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_TableTempl_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Ptr_t * vVars; // Vec<Str> -- name of variable (numbered from 0, not 1 as in the Liberty file)
|
|
|
|
|
Vec_Ptr_t * vIndex; // Vec<Vec<float> > -- this is the point of measurement in table for the given variable
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Surface_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Flt_t * vIndex0; // Vec<float> -- correspondes to "index_1" in the liberty file (for timing: slew)
|
|
|
|
|
Vec_Flt_t * vIndex1; // Vec<float> -- correspondes to "index_2" in the liberty file (for timing: load)
|
|
|
|
|
Vec_Ptr_t * vData; // Vec<Vec<float> > -- 'data[i0][i1]' gives value at '(index0[i0], index1[i1])'
|
2012-08-25 21:34:54 +02:00
|
|
|
float approx[3][6];
|
2012-08-25 06:31:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Timing_
|
|
|
|
|
{
|
|
|
|
|
char * related_pin; // -- related pin
|
|
|
|
|
SC_TSense tsense; // -- timing sense (positive_unate, negative_unate, non_unate)
|
2012-08-27 22:50:33 +02:00
|
|
|
char * when_text; // -- logic condition on inputs triggering this delay model for the output (currently not used)
|
2012-08-25 06:31:46 +02:00
|
|
|
SC_Surface * pCellRise; // -- Used to compute pin-to-pin delay
|
|
|
|
|
SC_Surface * pCellFall;
|
|
|
|
|
SC_Surface * pRiseTrans; // -- Used to compute output slew
|
|
|
|
|
SC_Surface * pFallTrans;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Timings_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName; // -- the 'related_pin' field
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Ptr_t * vTimings; // structures of type SC_Timing
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Pin_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-25 06:31:46 +02:00
|
|
|
SC_Dir dir;
|
2012-08-27 22:50:33 +02:00
|
|
|
float cap; // -- this value is used if 'rise_cap' and 'fall_cap' is missing (copied by 'postProcess()'). (not used)
|
2012-08-25 06:31:46 +02:00
|
|
|
float rise_cap; // }- used for input pins ('cap' too).
|
|
|
|
|
float fall_cap; // }
|
2012-08-27 22:50:33 +02:00
|
|
|
float max_out_cap; // } (not used)
|
|
|
|
|
float max_out_slew; // }- used only for output pins (max values must not be exceeded or else mapping is illegal) (not used)
|
2012-08-25 06:31:46 +02:00
|
|
|
char * func_text; // }
|
|
|
|
|
Vec_Wrd_t * vFunc; // }
|
|
|
|
|
Vec_Ptr_t * vRTimings; // -- for output pins
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Cell_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-09-18 22:23:58 +02:00
|
|
|
int Id;
|
2013-07-30 03:55:13 +02:00
|
|
|
int fSkip; // skip this cell during genlib computation
|
2012-08-25 06:31:46 +02:00
|
|
|
int seq; // -- set to TRUE by parser if a sequential element
|
|
|
|
|
int unsupp; // -- set to TRUE by parser if cell contains information we cannot handle
|
|
|
|
|
float area;
|
2012-08-27 22:50:33 +02:00
|
|
|
int drive_strength; // -- some library files provide this field (currently unused, but may be a good hint for sizing) (not used)
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Ptr_t * vPins; // NamedSet<SC_Pin>
|
|
|
|
|
int n_inputs; // -- 'pins[0 .. n_inputs-1]' are input pins
|
|
|
|
|
int n_outputs; // -- 'pins[n_inputs .. n_inputs+n_outputs-1]' are output pins
|
2012-08-28 04:58:15 +02:00
|
|
|
SC_Cell * pNext; // same-functionality cells linked into a ring by area
|
|
|
|
|
SC_Cell * pPrev; // same-functionality cells linked into a ring by area
|
2012-08-30 21:34:53 +02:00
|
|
|
int Order; // order of the gate in the list
|
2012-08-25 06:31:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SC_Lib_
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
char * pName;
|
2012-08-25 06:31:46 +02:00
|
|
|
char * default_wire_load;
|
|
|
|
|
char * default_wire_load_sel;
|
2012-08-27 22:50:33 +02:00
|
|
|
float default_max_out_slew; // -- 'default_max_transition'; this is copied to each output pin where 'max_transition' is not defined (not used)
|
2012-08-25 06:31:46 +02:00
|
|
|
int unit_time; // -- Valid 9..12. Unit is '10^(-val)' seconds (e.g. 9=1ns, 10=100ps, 11=10ps, 12=1ps)
|
2012-08-25 21:34:54 +02:00
|
|
|
float unit_cap_fst; // -- First part is a multiplier, second either 12 or 15 for 'pf' or 'ff'.
|
|
|
|
|
int unit_cap_snd;
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_Ptr_t * vWireLoads; // NamedSet<SC_WireLoad>
|
|
|
|
|
Vec_Ptr_t * vWireLoadSels; // NamedSet<SC_WireLoadSel>
|
|
|
|
|
Vec_Ptr_t * vTempls; // NamedSet<SC_TableTempl>
|
2012-08-26 04:00:26 +02:00
|
|
|
Vec_Ptr_t * vCells; // NamedSet<SC_Cell>
|
2012-09-01 22:47:41 +02:00
|
|
|
Vec_Ptr_t * vCellClasses; // NamedSet<SC_Cell>
|
2012-08-26 04:00:26 +02:00
|
|
|
int * pBins; // hashing gateName -> gateId
|
|
|
|
|
int nBins;
|
2012-08-25 06:31:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// GLOBAL VARIABLES ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// MACRO DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-07-21 04:11:29 +02:00
|
|
|
static inline SC_Cell * SC_LibCell( SC_Lib * p, int i ) { return (SC_Cell *)Vec_PtrEntry(p->vCells, i); }
|
|
|
|
|
static inline SC_Pin * SC_CellPin( SC_Cell * p, int i ) { return (SC_Pin *)Vec_PtrEntry(p->vPins, i); }
|
|
|
|
|
static inline Vec_Wrd_t * SC_CellFunc( SC_Cell * p ) { return SC_CellPin(p, p->n_inputs)->vFunc; }
|
2013-07-22 22:25:51 +02:00
|
|
|
static inline float SC_CellPinCap( SC_Cell * p, int i ) { return 0.5 * (SC_CellPin(p, i)->rise_cap + SC_CellPin(p, i)->fall_cap); }
|
|
|
|
|
static inline char * SC_CellPinOutFunc( SC_Cell * p, int i ) { return SC_CellPin(p, p->n_inputs + i)->func_text; }
|
|
|
|
|
static inline char * SC_CellPinName( SC_Cell * p, int i ) { return SC_CellPin(p, i)->pName; }
|
2012-08-29 09:48:36 +02:00
|
|
|
|
2013-07-21 04:11:29 +02:00
|
|
|
static inline double SC_LibCapFf( SC_Lib * p, double cap ) { return cap * p->unit_cap_fst * pow(10.0, 15 - p->unit_cap_snd); }
|
2013-07-21 10:01:53 +02:00
|
|
|
static inline double SC_LibCapFromFf( SC_Lib * p, double cap ) { return cap / p->unit_cap_fst / pow(10.0, 15 - p->unit_cap_snd); }
|
2013-07-21 04:11:29 +02:00
|
|
|
static inline double SC_LibTimePs( SC_Lib * p, double time ) { return time * pow(10.0, 12 - p->unit_time); }
|
|
|
|
|
static inline double SC_LibTimeFromPs( SC_Lib * p, double ps ) { return ps / pow(10.0, 12 - p->unit_time); }
|
2012-08-28 04:58:15 +02:00
|
|
|
|
2013-07-22 22:25:51 +02:00
|
|
|
|
|
|
|
|
|
2012-09-01 22:47:41 +02:00
|
|
|
#define SC_LibForEachCell( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, p->vCells, pCell, i )
|
|
|
|
|
#define SC_LibForEachCellClass( p, pCell, i ) Vec_PtrForEachEntry( SC_Cell *, p->vCellClasses, pCell, i )
|
|
|
|
|
#define SC_LibForEachWireLoad( p, pWL, i ) Vec_PtrForEachEntry( SC_WireLoad *, p->vWireLoads, pWL, i )
|
|
|
|
|
#define SC_LibForEachWireLoadSel( p, pWLS, i ) Vec_PtrForEachEntry( SC_WireLoadSel *, p->vWireLoadSels, pWLS, i )
|
|
|
|
|
#define SC_LibForEachTempl( p, pTempl, i ) Vec_PtrForEachEntry( SC_TableTempl *, p->vTempls, pTempl, i )
|
|
|
|
|
#define SC_CellForEachPin( p, pPin, i ) Vec_PtrForEachEntry( SC_Pin *, p->vPins, pPin, i )
|
|
|
|
|
#define SC_CellForEachPinIn( p, pPin, i ) Vec_PtrForEachEntryStop( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
|
|
|
|
|
#define SC_CellForEachPinOut( p, pPin, i ) Vec_PtrForEachEntryStart( SC_Pin *, p->vPins, pPin, i, p->n_inputs )
|
|
|
|
|
#define SC_RingForEachCell( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pNext, i++ )
|
2013-07-21 23:56:30 +02:00
|
|
|
#define SC_RingForEachCellRev( pRing, pCell, i ) for ( i = 0, pCell = pRing; i == 0 || pCell != pRing; pCell = pCell->pPrev, i++ )
|
2012-09-01 22:47:41 +02:00
|
|
|
#define SC_PinForEachRTiming( p, pRTime, i ) Vec_PtrForEachEntry( SC_Timings *, p->vRTimings, pRTime, i )
|
2012-08-28 04:58:15 +02:00
|
|
|
|
2012-08-26 04:00:26 +02:00
|
|
|
|
2012-08-25 06:31:46 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// FUNCTION DEFINITIONS ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-08-30 01:20:39 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Constructors of the library data-structures.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2012-08-25 06:31:46 +02:00
|
|
|
static inline SC_WireLoad * Abc_SclWireLoadAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_WireLoad * p;
|
|
|
|
|
p = ABC_CALLOC( SC_WireLoad, 1 );
|
|
|
|
|
p->vFanout = Vec_IntAlloc( 0 );
|
|
|
|
|
p->vLen = Vec_FltAlloc( 0 );
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_WireLoadSel * Abc_SclWireLoadSelAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_WireLoadSel * p;
|
|
|
|
|
p = ABC_CALLOC( SC_WireLoadSel, 1 );
|
|
|
|
|
p->vAreaFrom = Vec_FltAlloc( 0 );
|
|
|
|
|
p->vAreaTo = Vec_FltAlloc( 0 );
|
|
|
|
|
p->vWireLoadModel = Vec_PtrAlloc( 0 );
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_TableTempl * Abc_SclTableTemplAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_TableTempl * p;
|
|
|
|
|
p = ABC_CALLOC( SC_TableTempl, 1 );
|
|
|
|
|
p->vVars = Vec_PtrAlloc( 0 );
|
|
|
|
|
p->vIndex = Vec_PtrAlloc( 0 );
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Surface * Abc_SclSurfaceAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Surface * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Surface, 1 );
|
|
|
|
|
p->vIndex0 = Vec_FltAlloc( 0 );
|
|
|
|
|
p->vIndex1 = Vec_FltAlloc( 0 );
|
|
|
|
|
p->vData = Vec_PtrAlloc( 0 );
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Timing * Abc_SclTimingAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Timing * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Timing, 1 );
|
|
|
|
|
p->pCellRise = Abc_SclSurfaceAlloc();
|
|
|
|
|
p->pCellFall = Abc_SclSurfaceAlloc();
|
|
|
|
|
p->pRiseTrans = Abc_SclSurfaceAlloc();
|
|
|
|
|
p->pFallTrans = Abc_SclSurfaceAlloc();
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Timings * Abc_SclTimingsAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Timings * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Timings, 1 );
|
2012-08-25 21:34:54 +02:00
|
|
|
p->vTimings = Vec_PtrAlloc( 0 );
|
2012-08-25 06:31:46 +02:00
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Pin * Abc_SclPinAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Pin * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Pin, 1 );
|
|
|
|
|
p->max_out_slew = -1;
|
2012-08-25 21:34:54 +02:00
|
|
|
p->vFunc = Vec_WrdAlloc( 0 );
|
|
|
|
|
p->vRTimings = Vec_PtrAlloc( 0 );
|
2012-08-25 06:31:46 +02:00
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Cell * Abc_SclCellAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Cell * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Cell, 1 );
|
|
|
|
|
p->vPins = Vec_PtrAlloc( 0 );
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
static inline SC_Lib * Abc_SclLibAlloc()
|
|
|
|
|
{
|
|
|
|
|
SC_Lib * p;
|
|
|
|
|
p = ABC_CALLOC( SC_Lib, 1 );
|
|
|
|
|
p->default_max_out_slew = -1;
|
|
|
|
|
p->unit_time = 9;
|
2012-08-25 21:34:54 +02:00
|
|
|
p->unit_cap_fst = 1;
|
|
|
|
|
p->unit_cap_snd = 12;
|
2012-08-25 06:31:46 +02:00
|
|
|
p->vWireLoads = Vec_PtrAlloc( 0 );
|
|
|
|
|
p->vWireLoadSels = Vec_PtrAlloc( 0 );
|
|
|
|
|
p->vTempls = Vec_PtrAlloc( 0 );
|
|
|
|
|
p->vCells = Vec_PtrAlloc( 0 );
|
2012-09-01 22:47:41 +02:00
|
|
|
p->vCellClasses = Vec_PtrAlloc( 0 );
|
2012-08-25 06:31:46 +02:00
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-08-30 01:20:39 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Destructors of the library data-structures.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
2012-08-25 06:31:46 +02:00
|
|
|
static inline void Abc_SclWireLoadFree( SC_WireLoad * p )
|
|
|
|
|
{
|
|
|
|
|
Vec_IntFree( p->vFanout );
|
|
|
|
|
Vec_FltFree( p->vLen );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclWireLoadSelFree( SC_WireLoadSel * p )
|
|
|
|
|
{
|
|
|
|
|
Vec_FltFree( p->vAreaFrom );
|
|
|
|
|
Vec_FltFree( p->vAreaTo );
|
|
|
|
|
Vec_PtrFreeFree( p->vWireLoadModel );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclTableTemplFree( SC_TableTempl * p )
|
|
|
|
|
{
|
|
|
|
|
Vec_PtrFreeFree( p->vVars );
|
|
|
|
|
Vec_VecFree( (Vec_Vec_t *)p->vIndex );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclSurfaceFree( SC_Surface * p )
|
|
|
|
|
{
|
|
|
|
|
Vec_FltFree( p->vIndex0 );
|
|
|
|
|
Vec_FltFree( p->vIndex1 );
|
|
|
|
|
Vec_VecFree( (Vec_Vec_t *)p->vData );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclTimingFree( SC_Timing * p )
|
|
|
|
|
{
|
|
|
|
|
Abc_SclSurfaceFree( p->pCellRise );
|
|
|
|
|
Abc_SclSurfaceFree( p->pCellFall );
|
|
|
|
|
Abc_SclSurfaceFree( p->pRiseTrans );
|
|
|
|
|
Abc_SclSurfaceFree( p->pFallTrans );
|
|
|
|
|
ABC_FREE( p->related_pin );
|
|
|
|
|
ABC_FREE( p->when_text );
|
|
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclTimingsFree( SC_Timings * p )
|
|
|
|
|
{
|
|
|
|
|
SC_Timing * pTemp;
|
|
|
|
|
int i;
|
|
|
|
|
Vec_PtrForEachEntry( SC_Timing *, p->vTimings, pTemp, i )
|
|
|
|
|
Abc_SclTimingFree( pTemp );
|
|
|
|
|
Vec_PtrFree( p->vTimings );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclPinFree( SC_Pin * p )
|
|
|
|
|
{
|
|
|
|
|
SC_Timings * pTemp;
|
|
|
|
|
int i;
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_PinForEachRTiming( p, pTemp, i )
|
2012-08-25 06:31:46 +02:00
|
|
|
Abc_SclTimingsFree( pTemp );
|
|
|
|
|
Vec_PtrFree( p->vRTimings );
|
|
|
|
|
Vec_WrdFree( p->vFunc );
|
|
|
|
|
ABC_FREE( p->func_text );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclCellFree( SC_Cell * p )
|
|
|
|
|
{
|
|
|
|
|
SC_Pin * pTemp;
|
|
|
|
|
int i;
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_CellForEachPin( p, pTemp, i )
|
2012-08-25 06:31:46 +02:00
|
|
|
Abc_SclPinFree( pTemp );
|
|
|
|
|
Vec_PtrFree( p->vPins );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
static inline void Abc_SclLibFree( SC_Lib * p )
|
|
|
|
|
{
|
2012-08-30 01:20:39 +02:00
|
|
|
SC_WireLoad * pWL;
|
|
|
|
|
SC_WireLoadSel * pWLS;
|
|
|
|
|
SC_TableTempl * pTempl;
|
|
|
|
|
SC_Cell * pCell;
|
2012-08-25 06:31:46 +02:00
|
|
|
int i;
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_LibForEachWireLoad( p, pWL, i )
|
2012-08-30 01:20:39 +02:00
|
|
|
Abc_SclWireLoadFree( pWL );
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_PtrFree( p->vWireLoads );
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_LibForEachWireLoadSel( p, pWLS, i )
|
2012-08-30 01:20:39 +02:00
|
|
|
Abc_SclWireLoadSelFree( pWLS );
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_PtrFree( p->vWireLoadSels );
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_LibForEachTempl( p, pTempl, i )
|
2012-08-30 01:20:39 +02:00
|
|
|
Abc_SclTableTemplFree( pTempl );
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_PtrFree( p->vTempls );
|
2012-09-01 22:47:41 +02:00
|
|
|
SC_LibForEachCell( p, pCell, i )
|
2012-08-30 01:20:39 +02:00
|
|
|
Abc_SclCellFree( pCell );
|
2012-08-25 06:31:46 +02:00
|
|
|
Vec_PtrFree( p->vCells );
|
2012-09-01 22:47:41 +02:00
|
|
|
Vec_PtrFree( p->vCellClasses );
|
2012-08-30 01:20:39 +02:00
|
|
|
ABC_FREE( p->pName );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p->default_wire_load );
|
|
|
|
|
ABC_FREE( p->default_wire_load_sel );
|
2012-08-26 04:00:26 +02:00
|
|
|
ABC_FREE( p->pBins );
|
2012-08-25 06:31:46 +02:00
|
|
|
ABC_FREE( p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-07-22 22:25:51 +02:00
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Lookup table delay computation.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
static inline float Scl_LibLookup( SC_Surface * p, float slew, float load )
|
|
|
|
|
{
|
|
|
|
|
float * pIndex0, * pIndex1, * pDataS, * pDataS1;
|
|
|
|
|
float sfrac, lfrac, p0, p1;
|
|
|
|
|
int s, l;
|
|
|
|
|
|
|
|
|
|
// Find closest sample points in surface:
|
|
|
|
|
pIndex0 = Vec_FltArray(p->vIndex0);
|
|
|
|
|
for ( s = 1; s < Vec_FltSize(p->vIndex0)-1; s++ )
|
|
|
|
|
if ( pIndex0[s] > slew )
|
|
|
|
|
break;
|
|
|
|
|
s--;
|
|
|
|
|
|
|
|
|
|
pIndex1 = Vec_FltArray(p->vIndex1);
|
|
|
|
|
for ( l = 1; l < Vec_FltSize(p->vIndex1)-1; l++ )
|
|
|
|
|
if ( pIndex1[l] > load )
|
|
|
|
|
break;
|
|
|
|
|
l--;
|
|
|
|
|
|
|
|
|
|
// Interpolate (or extrapolate) function value from sample points:
|
|
|
|
|
sfrac = (slew - pIndex0[s]) / (pIndex0[s+1] - pIndex0[s]);
|
|
|
|
|
lfrac = (load - pIndex1[l]) / (pIndex1[l+1] - pIndex1[l]);
|
|
|
|
|
|
|
|
|
|
pDataS = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(p->vData, s) );
|
|
|
|
|
pDataS1 = Vec_FltArray( (Vec_Flt_t *)Vec_PtrEntry(p->vData, s+1) );
|
|
|
|
|
|
|
|
|
|
p0 = pDataS [l] + lfrac * (pDataS [l+1] - pDataS [l]);
|
|
|
|
|
p1 = pDataS1[l] + lfrac * (pDataS1[l+1] - pDataS1[l]);
|
|
|
|
|
|
|
|
|
|
return p0 + sfrac * (p1 - p0); // <<== multiply result with K factor here
|
|
|
|
|
}
|
|
|
|
|
static inline void Scl_LibPinArrival( SC_Timing * pTime, SC_Pair * pArrIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pArrOut, SC_Pair * pSlewOut )
|
|
|
|
|
{
|
|
|
|
|
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
|
|
|
|
|
{
|
|
|
|
|
pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
|
|
|
|
|
pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
|
|
|
|
|
pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(pTime->pRiseTrans, pSlewIn->rise, pLoad->rise) );
|
|
|
|
|
pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(pTime->pFallTrans, pSlewIn->fall, pLoad->fall) );
|
|
|
|
|
}
|
|
|
|
|
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
|
|
|
|
|
{
|
|
|
|
|
pArrOut->rise = Abc_MaxFloat( pArrOut->rise, pArrIn->fall + Scl_LibLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
|
|
|
|
|
pArrOut->fall = Abc_MaxFloat( pArrOut->fall, pArrIn->rise + Scl_LibLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
|
|
|
|
|
pSlewOut->rise = Abc_MaxFloat( pSlewOut->rise, Scl_LibLookup(pTime->pRiseTrans, pSlewIn->fall, pLoad->rise) );
|
|
|
|
|
pSlewOut->fall = Abc_MaxFloat( pSlewOut->fall, Scl_LibLookup(pTime->pFallTrans, pSlewIn->rise, pLoad->fall) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
static inline void Scl_LibPinDeparture( SC_Timing * pTime, SC_Pair * pDepIn, SC_Pair * pSlewIn, SC_Pair * pLoad, SC_Pair * pDepOut )
|
|
|
|
|
{
|
|
|
|
|
if (pTime->tsense == sc_ts_Pos || pTime->tsense == sc_ts_Non)
|
|
|
|
|
{
|
|
|
|
|
pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->rise, pLoad->rise) );
|
|
|
|
|
pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->fall, pLoad->fall) );
|
|
|
|
|
}
|
|
|
|
|
if (pTime->tsense == sc_ts_Neg || pTime->tsense == sc_ts_Non)
|
|
|
|
|
{
|
|
|
|
|
pDepIn->fall = Abc_MaxFloat( pDepIn->fall, pDepOut->rise + Scl_LibLookup(pTime->pCellRise, pSlewIn->fall, pLoad->rise) );
|
|
|
|
|
pDepIn->rise = Abc_MaxFloat( pDepIn->rise, pDepOut->fall + Scl_LibLookup(pTime->pCellFall, pSlewIn->rise, pLoad->fall) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Function*************************************************************
|
|
|
|
|
|
|
|
|
|
Synopsis [Computes input capacitance.]
|
|
|
|
|
|
|
|
|
|
Description []
|
|
|
|
|
|
|
|
|
|
SideEffects []
|
|
|
|
|
|
|
|
|
|
SeeAlso []
|
|
|
|
|
|
|
|
|
|
***********************************************************************/
|
|
|
|
|
static inline float Abc_SclGatePinCapAve( SC_Lib * p, SC_Cell * pCell )
|
|
|
|
|
{
|
|
|
|
|
SC_Pin * pPin;
|
|
|
|
|
int k;
|
|
|
|
|
float Cap = 0.0;
|
|
|
|
|
SC_CellForEachPinIn( pCell, pPin, k )
|
|
|
|
|
Cap += 0.5 * (pPin->rise_cap + pPin->fall_cap);
|
|
|
|
|
return Cap / pCell->n_inputs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-07-22 02:55:15 +02:00
|
|
|
/*=== sclLib.c ===============================================================*/
|
2012-10-09 06:20:13 +02:00
|
|
|
extern SC_Lib * Abc_SclRead( char * pFileName );
|
|
|
|
|
extern void Abc_SclWrite( char * pFileName, SC_Lib * p );
|
|
|
|
|
extern void Abc_SclWriteText( char * pFileName, SC_Lib * p );
|
|
|
|
|
extern void Abc_SclLoad( char * pFileName, SC_Lib ** ppScl );
|
|
|
|
|
extern void Abc_SclSave( char * pFileName, SC_Lib * pScl );
|
|
|
|
|
extern void Abc_SclHashCells( SC_Lib * p );
|
|
|
|
|
extern int Abc_SclCellFind( SC_Lib * p, char * pName );
|
2013-07-24 01:15:03 +02:00
|
|
|
extern int Abc_SclClassCellNum( SC_Cell * pClass );
|
2012-10-09 06:20:13 +02:00
|
|
|
extern void Abc_SclLinkCells( SC_Lib * p );
|
2013-07-24 01:15:03 +02:00
|
|
|
extern void Abc_SclPrintCells( SC_Lib * p, float Slew, float Gain );
|
2013-07-22 02:55:15 +02:00
|
|
|
extern SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area );
|
2013-07-24 01:15:03 +02:00
|
|
|
extern void Abc_SclDumpGenlib( char * pFileName, SC_Lib * p, float Slew, float Gain, int nGatesMin );
|
2012-08-25 06:31:46 +02:00
|
|
|
|
|
|
|
|
ABC_NAMESPACE_HEADER_END
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
/// END OF FILE ///
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|