abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sclTime.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [sclTime.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Standard-cell library representation.]
8 
9  Synopsis [Timing/gate-sizing manager.]
10 
11  Author [Alan Mishchenko, Niklas Een]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - August 24, 2012.]
16 
17  Revision [$Id: sclTime.h,v 1.0 2012/08/24 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__map__scl__sclTime_h
22 #define ABC__map__scl__sclTime_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include "misc/vec/vec.h"
30 #include "sclLib.h"
31 
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// PARAMETERS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// STRUCTURE DEFINITIONS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 typedef struct SC_Time_ SC_Time;
43 struct SC_Time_
44 {
45  SC_Lib * pLib; // library
46  Vec_Int_t * vCis; // comb inputs
47  Vec_Int_t * vCos; // comb outputs
48  int nObjs; // allocated size
49  // get assignment
50  Vec_Int_t * vGates; // mapping of objId into gateId
51  // timing information
52  SC_Pair * pLoads; // loads for each gate
53  SC_Pair * pLoads2; // loads for each gate
54  SC_Pair * pDepts; // departures for each gate
55  SC_Pair * pTimes; // arrivals for each gate
56  SC_Pair * pSlews; // slews for each gate
57  SC_Pair * pTimes2; // arrivals for each gate
58  SC_Pair * pSlews2; // slews for each gate
59  float * pSlack; // slacks for each gate
60  SC_WireLoad * pWLoadUsed; // name of the used WireLoad model
61  // optimization parameters
62  float SumArea; // total area
63  float MaxDelay; // max delay
64  float SumArea0; // total area at the begining
65  float MaxDelay0; // max delay at the begining
66  float BestDelay; // best delay in the middle
67 };
68 
69 ////////////////////////////////////////////////////////////////////////
70 /// GLOBAL VARIABLES ///
71 ////////////////////////////////////////////////////////////////////////
72 
73 ////////////////////////////////////////////////////////////////////////
74 /// MACRO DEFINITIONS ///
75 ////////////////////////////////////////////////////////////////////////
76 
77 static inline SC_Cell * Scl_ObjCell( SC_Time * p, int i ) { return SC_LibCell( p->pLib, Vec_IntEntry(p->vGates, i) ); }
78 static inline void Scl_ObjSetCell( SC_Time * p, int i, SC_Cell * pCell ) { Vec_IntWriteEntry( p->vGates, i, pCell->Id ); }
79 
80 static inline SC_Pair * Scl_ObjLoad( SC_Time * p, int i ) { return p->pLoads + i; }
81 static inline SC_Pair * Scl_ObjLoad2( SC_Time * p, int i ) { return p->pLoads2 + i; }
82 static inline SC_Pair * Scl_ObjDept( SC_Time * p, int i ) { return p->pDepts + i; }
83 static inline SC_Pair * Scl_ObjTime( SC_Time * p, int i ) { return p->pTimes + i; }
84 static inline SC_Pair * Scl_ObjSlew( SC_Time * p, int i ) { return p->pSlews + i; }
85 static inline SC_Pair * Scl_ObjTime2( SC_Time * p, int i ) { return p->pTimes2 + i; }
86 static inline SC_Pair * Scl_ObjSlew2( SC_Time * p, int i ) { return p->pSlews2 + i; }
87 
88 static inline float Scl_ObjTimeMax( SC_Time * p, int i ) { return Abc_MaxFloat(Scl_ObjTime(p, i)->rise, Scl_ObjTime(p, i)->fall); }
89 static inline float Scl_ObjDepthMax( SC_Time * p, int i ) { return Abc_MaxFloat(Scl_ObjDept(p, i)->rise, Scl_ObjDept(p, i)->fall); }
90 static inline float Scl_ObjGetSlack( SC_Time * p, int i, float D ) { return D - Abc_MaxFloat(Scl_ObjTime(p, i)->rise + Scl_ObjDept(p, i)->rise, Scl_ObjTime(p, i)->fall + Scl_ObjDept(p, i)->fall); }
91 static inline float Scl_ObjGetSlackR( SC_Time * p, int i, float D ) { return D - (Scl_ObjTime(p, i)->rise + Scl_ObjDept(p, i)->rise); }
92 static inline float Scl_ObjGetSlackF( SC_Time * p, int i, float D ) { return D - (Scl_ObjTime(p, i)->fall + Scl_ObjDept(p, i)->fall); }
93 static inline float Scl_ObjSlack( SC_Time * p, int i ) { return p->pSlack[i]; }
94 
95 static inline void Scl_ObjDupFanin( SC_Time * p, int i, int iFanin ) { *Scl_ObjTime(p, i) = *Scl_ObjTime(p, iFanin); }
96 static inline float Scl_ObjGain( SC_Time * p, int i ) { return 0.5*((Scl_ObjTime2(p, i)->rise - Scl_ObjTime(p, i)->rise) + (Scl_ObjTime2(p, i)->fall - Scl_ObjTime(p, i)->fall)); }
97 static inline int Scl_ObjLegal( SC_Time * p, int i, float D ) { return Scl_ObjTime(p, i)->rise <= Scl_ObjTime2(p, i)->rise + Scl_ObjGetSlackR(p, i, D) && Scl_ObjTime(p, i)->fall <= Scl_ObjTime2(p, i)->fall + Scl_ObjGetSlackF(p, i, D); }
98 
99 static inline double Scl_ObjLoadFf( SC_Time * p, int i, int fRise ) { return fRise ? Scl_ObjLoad(p, i)->rise : Scl_ObjLoad(p, i)->fall; }
100 static inline double Scl_ObjTimePs( SC_Time * p, int i, int fRise ) { return fRise ? Scl_ObjTime(p, i)->rise : Scl_ObjTime(p, i)->fall; }
101 static inline double Scl_ObjSlewPs( SC_Time * p, int i, int fRise ) { return fRise ? Scl_ObjSlew(p, i)->rise : Scl_ObjSlew(p, i)->fall; }
102 
103 ////////////////////////////////////////////////////////////////////////
104 /// FUNCTION DEFINITIONS ///
105 ////////////////////////////////////////////////////////////////////////
106 
107 /**Function*************************************************************
108 
109  Synopsis [Constructor/destructor of STA manager.]
110 
111  Description []
112 
113  SideEffects []
114 
115  SeeAlso []
116 
117 ***********************************************************************/
118 static inline SC_Time * Scl_ManAlloc( SC_Lib * pLib, Vec_Int_t * vCis, Vec_Int_t * vCos, int nObjs )
119 {
120  SC_Time * p;
121  p = ABC_CALLOC( SC_Time, 1 );
122  p->pLib = pLib;
123  p->vCis = vCis;
124  p->vCos = vCos;
125  p->nObjs = nObjs;
126  p->pLoads = ABC_CALLOC( SC_Pair, p->nObjs );
127  p->pLoads2 = ABC_CALLOC( SC_Pair, p->nObjs );
128  p->pDepts = ABC_CALLOC( SC_Pair, p->nObjs );
129  p->pTimes = ABC_CALLOC( SC_Pair, p->nObjs );
130  p->pSlews = ABC_CALLOC( SC_Pair, p->nObjs );
131  p->pTimes2 = ABC_CALLOC( SC_Pair, p->nObjs );
132  p->pSlews2 = ABC_CALLOC( SC_Pair, p->nObjs );
133  p->pSlack = ABC_FALLOC( float, p->nObjs );
134  return p;
135 }
136 static inline void Scl_ManFree( SC_Time * p )
137 {
138  Vec_IntFreeP( &p->vGates );
139  ABC_FREE( p->pLoads );
140  ABC_FREE( p->pLoads2 );
141  ABC_FREE( p->pDepts );
142  ABC_FREE( p->pTimes );
143  ABC_FREE( p->pSlews );
144  ABC_FREE( p->pTimes2 );
145  ABC_FREE( p->pSlews2 );
146  ABC_FREE( p->pSlack );
147  ABC_FREE( p );
148 }
149 static inline void Scl_ManCleanTime( SC_Time * p )
150 {
151  memset( p->pDepts, 0, sizeof(SC_Pair) * p->nObjs );
152  memset( p->pTimes, 0, sizeof(SC_Pair) * p->nObjs );
153  memset( p->pSlews, 0, sizeof(SC_Pair) * p->nObjs );
154 }
155 
156 
157 /**Function*************************************************************
158 
159  Synopsis [Stores/retrieves timing information for the logic cone.]
160 
161  Description []
162 
163  SideEffects []
164 
165  SeeAlso []
166 
167 ***********************************************************************/
168 static inline void Scl_ConeStore( SC_Time * p, Vec_Int_t * vCone )
169 {
170  int i, iObj;
171  Vec_IntForEachEntry( vCone, iObj, i )
172  {
173  *Scl_ObjTime2(p, iObj) = *Scl_ObjTime(p, iObj);
174  *Scl_ObjSlew2(p, iObj) = *Scl_ObjSlew(p, iObj);
175  }
176 }
177 static inline void Scl_ConeRestore( SC_Time * p, Vec_Int_t * vCone )
178 {
179  int i, iObj;
180  Vec_IntForEachEntry( vCone, iObj, i )
181  {
182  *Scl_ObjTime(p, iObj) = *Scl_ObjTime2(p, iObj);
183  *Scl_ObjSlew(p, iObj) = *Scl_ObjSlew2(p, iObj);
184  }
185 }
186 static inline void Scl_ConeClear( SC_Time * p, Vec_Int_t * vCone )
187 {
188  SC_Pair Zero = { 0.0, 0.0 };
189  int i, iObj;
190  Vec_IntForEachEntry( vCone, iObj, i )
191  {
192  *Scl_ObjTime(p, iObj) = Zero;
193  *Scl_ObjSlew(p, iObj) = Zero;
194  }
195 }
196 
197 /**Function*************************************************************
198 
199  Synopsis [Timing computation for pin/gate/cone/network.]
200 
201  Description []
202 
203  SideEffects []
204 
205  SeeAlso []
206 
207 ***********************************************************************/
208 static inline void Scl_PinTimeArrival( SC_Time * p, SC_Timing * pTime, int iObj, int iFanin )
209 {
210  SC_Pair * pArrIn = Scl_ObjTime( p, iFanin );
211  SC_Pair * pSlewIn = Scl_ObjSlew( p, iFanin );
212  SC_Pair * pLoad = Scl_ObjLoad( p, iObj );
213  SC_Pair * pArrOut = Scl_ObjTime( p, iObj ); // modified
214  SC_Pair * pSlewOut = Scl_ObjSlew( p, iObj ); // modified
215  Scl_LibPinArrival( pTime, pArrIn, pSlewIn, pLoad, pArrOut, pSlewOut );
216 }
217 static inline void Scl_PinTimeDeparture( SC_Time * p, SC_Timing * pTime, int iObj, int iFanin )
218 {
219  SC_Pair * pDepIn = Scl_ObjDept( p, iFanin ); // modified
220  SC_Pair * pSlewIn = Scl_ObjSlew( p, iFanin );
221  SC_Pair * pLoad = Scl_ObjLoad( p, iObj );
222  SC_Pair * pDepOut = Scl_ObjDept( p, iObj );
223  Scl_LibPinDeparture( pTime, pDepIn, pSlewIn, pLoad, pDepOut );
224 }
225 
226 
227 
229 
230 #endif
231 
232 ////////////////////////////////////////////////////////////////////////
233 /// END OF FILE ///
234 ////////////////////////////////////////////////////////////////////////
SC_Pair * pTimes2
Definition: sclTime.h:57
char * memset()
float SumArea0
Definition: sclTime.h:64
SC_WireLoad * pWLoadUsed
Definition: sclTime.h:60
SC_Pair * pSlews2
Definition: sclTime.h:58
static float Scl_ObjGetSlack(SC_Time *p, int i, float D)
Definition: sclTime.h:90
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static float Scl_ObjSlack(SC_Time *p, int i)
Definition: sclTime.h:93
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static double Scl_ObjTimePs(SC_Time *p, int i, int fRise)
Definition: sclTime.h:100
static SC_Pair * Scl_ObjTime2(SC_Time *p, int i)
Definition: sclTime.h:85
static SC_Time * Scl_ManAlloc(SC_Lib *pLib, Vec_Int_t *vCis, Vec_Int_t *vCos, int nObjs)
FUNCTION DEFINITIONS ///.
Definition: sclTime.h:118
static void Scl_ConeStore(SC_Time *p, Vec_Int_t *vCone)
Definition: sclTime.h:168
Vec_Int_t * vCos
Definition: sclTime.h:47
static void Scl_LibPinDeparture(SC_Timing *pTime, SC_Pair *pDepIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pDepOut)
Definition: sclLib.h:540
static SC_Pair * Scl_ObjLoad(SC_Time *p, int i)
Definition: sclTime.h:80
SC_Pair * pSlews
Definition: sclTime.h:56
static double Scl_ObjSlewPs(SC_Time *p, int i, int fRise)
Definition: sclTime.h:101
float BestDelay
Definition: sclTime.h:66
Vec_Int_t * vGates
Definition: sclTime.h:50
static float Abc_MaxFloat(float a, float b)
Definition: abc_global.h:243
static void Scl_ManCleanTime(SC_Time *p)
Definition: sclTime.h:149
SC_Pair * pTimes
Definition: sclTime.h:55
static SC_Pair * Scl_ObjDept(SC_Time *p, int i)
Definition: sclTime.h:82
static void Scl_ManFree(SC_Time *p)
Definition: sclTime.h:136
static double Scl_ObjLoadFf(SC_Time *p, int i, int fRise)
Definition: sclTime.h:99
SC_Pair * pLoads2
Definition: sclTime.h:53
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static SC_Pair * Scl_ObjSlew(SC_Time *p, int i)
Definition: sclTime.h:84
static SC_Pair * Scl_ObjLoad2(SC_Time *p, int i)
Definition: sclTime.h:81
typedefABC_NAMESPACE_HEADER_START struct SC_Time_ SC_Time
INCLUDES ///.
Definition: sclTime.h:42
float rise
Definition: sclLib.h:65
static float Scl_ObjGain(SC_Time *p, int i)
Definition: sclTime.h:96
float fall
Definition: sclLib.h:66
SC_Pair * pDepts
Definition: sclTime.h:54
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
int Id
Definition: sclLib.h:184
static SC_Cell * Scl_ObjCell(SC_Time *p, int i)
GLOBAL VARIABLES ///.
Definition: sclTime.h:77
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
SC_Pair * pLoads
Definition: sclTime.h:52
static SC_Cell * SC_LibCell(SC_Lib *p, int i)
Definition: sclLib.h:240
float MaxDelay
Definition: sclTime.h:63
SC_Lib * pLib
Definition: sclTime.h:45
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
static void Scl_ObjSetCell(SC_Time *p, int i, SC_Cell *pCell)
Definition: sclTime.h:78
static void Scl_PinTimeDeparture(SC_Time *p, SC_Timing *pTime, int iObj, int iFanin)
Definition: sclTime.h:217
static float Scl_ObjDepthMax(SC_Time *p, int i)
Definition: sclTime.h:89
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Int_t * vCis
Definition: sclTime.h:46
static int Scl_ObjLegal(SC_Time *p, int i, float D)
Definition: sclTime.h:97
float SumArea
Definition: sclTime.h:62
static void Scl_PinTimeArrival(SC_Time *p, SC_Timing *pTime, int iObj, int iFanin)
Definition: sclTime.h:208
static float Scl_ObjGetSlackR(SC_Time *p, int i, float D)
Definition: sclTime.h:91
float * pSlack
Definition: sclTime.h:59
static void Scl_LibPinArrival(SC_Timing *pTime, SC_Pair *pArrIn, SC_Pair *pSlewIn, SC_Pair *pLoad, SC_Pair *pArrOut, SC_Pair *pSlewOut)
Definition: sclLib.h:523
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static SC_Pair * Scl_ObjSlew2(SC_Time *p, int i)
Definition: sclTime.h:86
static SC_Pair * Scl_ObjTime(SC_Time *p, int i)
Definition: sclTime.h:83
static float Scl_ObjGetSlackF(SC_Time *p, int i, float D)
Definition: sclTime.h:92
static float Scl_ObjTimeMax(SC_Time *p, int i)
Definition: sclTime.h:88
static void Scl_ConeClear(SC_Time *p, Vec_Int_t *vCone)
Definition: sclTime.h:186
static void Scl_ConeRestore(SC_Time *p, Vec_Int_t *vCone)
Definition: sclTime.h:177
int nObjs
Definition: sclTime.h:48
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
float MaxDelay0
Definition: sclTime.h:65
#define ABC_FALLOC(type, num)
Definition: abc_global.h:231
static void Scl_ObjDupFanin(SC_Time *p, int i, int iFanin)
Definition: sclTime.h:95