abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
timTime.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [timTime.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Hierarchy/timing manager.]
8 
9  Synopsis [Setting and resetting timing information of the boxes.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: timTime.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "timInt.h"
22 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// DECLARATIONS ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// FUNCTION DEFINITIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 /**Function*************************************************************
34 
35  Synopsis [Initializes arrival time of the PI.]
36 
37  Description []
38 
39  SideEffects []
40 
41  SeeAlso []
42 
43 ***********************************************************************/
44 void Tim_ManInitPiArrival( Tim_Man_t * p, int iPi, float Delay )
45 {
46  assert( iPi < p->nCis );
47  p->pCis[iPi].timeArr = Delay;
48 }
49 
50 /**Function*************************************************************
51 
52  Synopsis [Initializes required time of the PO.]
53 
54  Description []
55 
56  SideEffects []
57 
58  SeeAlso []
59 
60 ***********************************************************************/
61 void Tim_ManInitPoRequired( Tim_Man_t * p, int iPo, float Delay )
62 {
63  assert( iPo < p->nCos );
64  p->pCos[iPo].timeReq = Delay;
65 }
66 
67 /**Function*************************************************************
68 
69  Synopsis [Sets arrival times of all PIs.]
70 
71  Description []
72 
73  SideEffects []
74 
75  SeeAlso []
76 
77 ***********************************************************************/
78 void Tim_ManInitPiArrivalAll( Tim_Man_t * p, float Delay )
79 {
80  Tim_Obj_t * pObj;
81  int i;
82  Tim_ManForEachPi( p, pObj, i )
83  Tim_ManInitPiArrival( p, i, Delay );
84 }
85 
86 /**Function*************************************************************
87 
88  Synopsis [Sets required times of all POs.]
89 
90  Description []
91 
92  SideEffects []
93 
94  SeeAlso []
95 
96 ***********************************************************************/
97 void Tim_ManInitPoRequiredAll( Tim_Man_t * p, float Delay )
98 {
99  Tim_Obj_t * pObj;
100  int i;
101  Tim_ManForEachPo( p, pObj, i )
102  Tim_ManSetCoRequired( p, i, Delay );
103 }
104 
105 /**Function*************************************************************
106 
107  Synopsis [Updates arrival time of the CO.]
108 
109  Description []
110 
111  SideEffects []
112 
113  SeeAlso []
114 
115 ***********************************************************************/
116 void Tim_ManSetCoArrival( Tim_Man_t * p, int iCo, float Delay )
117 {
118  assert( iCo < p->nCos );
119  assert( !p->fUseTravId || p->pCos[iCo].TravId != p->nTravIds );
120  p->pCos[iCo].timeArr = Delay;
121  p->pCos[iCo].TravId = p->nTravIds;
122 }
123 
124 /**Function*************************************************************
125 
126  Synopsis [Updates required time of the CI.]
127 
128  Description []
129 
130  SideEffects []
131 
132  SeeAlso []
133 
134 ***********************************************************************/
135 void Tim_ManSetCiRequired( Tim_Man_t * p, int iCi, float Delay )
136 {
137  assert( iCi < p->nCis );
138  assert( !p->fUseTravId || p->pCis[iCi].TravId != p->nTravIds );
139  p->pCis[iCi].timeReq = Delay;
140  p->pCis[iCi].TravId = p->nTravIds;
141 }
142 
143 /**Function*************************************************************
144 
145  Synopsis [Updates required time of the CO.]
146 
147  Description []
148 
149  SideEffects []
150 
151  SeeAlso []
152 
153 ***********************************************************************/
154 void Tim_ManSetCoRequired( Tim_Man_t * p, int iCo, float Delay )
155 {
156  assert( iCo < p->nCos );
157  assert( !p->fUseTravId || !p->nTravIds || p->pCos[iCo].TravId != p->nTravIds );
158  p->pCos[iCo].timeReq = Delay;
159  p->pCos[iCo].TravId = p->nTravIds;
160 }
161 
162 
163 /**Function*************************************************************
164 
165  Synopsis [Returns CO arrival time.]
166 
167  Description []
168 
169  SideEffects []
170 
171  SeeAlso []
172 
173 ***********************************************************************/
174 float Tim_ManGetCiArrival( Tim_Man_t * p, int iCi )
175 {
176  Tim_Box_t * pBox;
177  Tim_Obj_t * pObjThis, * pObj, * pObjRes;
178  float * pTable, * pDelays, DelayBest;
179  int i, k;
180  // consider the already processed PI
181  pObjThis = Tim_ManCi( p, iCi );
182  if ( p->fUseTravId && pObjThis->TravId == p->nTravIds )
183  return pObjThis->timeArr;
184  pObjThis->TravId = p->nTravIds;
185  // consider the main PI
186  pBox = Tim_ManCiBox( p, iCi );
187  if ( pBox == NULL )
188  return pObjThis->timeArr;
189  // update box timing
190  pBox->TravId = p->nTravIds;
191  // get the arrival times of the inputs of the box (POs)
192  if ( p->fUseTravId )
193  Tim_ManBoxForEachInput( p, pBox, pObj, i )
194  if ( pObj->TravId != p->nTravIds )
195  printf( "Tim_ManGetCiArrival(): Input arrival times of the box are not up to date!\n" );
196  // compute the arrival times for each output of the box (PIs)
197  pTable = Tim_ManBoxDelayTable( p, pBox->iBox );
198  Tim_ManBoxForEachOutput( p, pBox, pObjRes, i )
199  {
200  pDelays = pTable + 3 + i * pBox->nInputs;
201  DelayBest = -TIM_ETERNITY;
202  Tim_ManBoxForEachInput( p, pBox, pObj, k )
203  if ( pDelays[k] != -ABC_INFINITY )
204  DelayBest = Abc_MaxInt( DelayBest, pObj->timeArr + pDelays[k] );
205  pObjRes->timeArr = DelayBest;
206  pObjRes->TravId = p->nTravIds;
207  }
208  return pObjThis->timeArr;
209 }
210 
211 /**Function*************************************************************
212 
213  Synopsis [Returns CO required time.]
214 
215  Description []
216 
217  SideEffects []
218 
219  SeeAlso []
220 
221 ***********************************************************************/
222 float Tim_ManGetCoRequired( Tim_Man_t * p, int iCo )
223 {
224  Tim_Box_t * pBox;
225  Tim_Obj_t * pObjThis, * pObj, * pObjRes;
226  float * pTable, * pDelays, DelayBest;
227  int i, k;
228  // consider the already processed PO
229  pObjThis = Tim_ManCo( p, iCo );
230  if ( p->fUseTravId && pObjThis->TravId == p->nTravIds )
231  return pObjThis->timeReq;
232  pObjThis->TravId = p->nTravIds;
233  // consider the main PO
234  pBox = Tim_ManCoBox( p, iCo );
235  if ( pBox == NULL )
236  return pObjThis->timeReq;
237  // update box timing
238  pBox->TravId = p->nTravIds;
239  // get the required times of the outputs of the box (PIs)
240  if ( p->fUseTravId )
241  Tim_ManBoxForEachOutput( p, pBox, pObj, i )
242  if ( pObj->TravId != p->nTravIds )
243  printf( "Tim_ManGetCoRequired(): Output required times of output %d the box %d are not up to date!\n", i, pBox->iBox );
244  // compute the required times for each input of the box (POs)
245  pTable = Tim_ManBoxDelayTable( p, pBox->iBox );
246  Tim_ManBoxForEachInput( p, pBox, pObjRes, i )
247  {
248  DelayBest = TIM_ETERNITY;
249  Tim_ManBoxForEachOutput( p, pBox, pObj, k )
250  {
251  pDelays = pTable + 3 + k * pBox->nInputs;
252  if ( pDelays[k] != -ABC_INFINITY )
253  DelayBest = Abc_MinFloat( DelayBest, pObj->timeReq - pDelays[i] );
254  }
255  pObjRes->timeReq = DelayBest;
256  pObjRes->TravId = p->nTravIds;
257  }
258  return pObjThis->timeReq;
259 }
260 
261 ////////////////////////////////////////////////////////////////////////
262 /// END OF FILE ///
263 ////////////////////////////////////////////////////////////////////////
264 
265 
267 
ABC_NAMESPACE_IMPL_START void Tim_ManInitPiArrival(Tim_Man_t *p, int iPi, float Delay)
DECLARATIONS ///.
Definition: timTime.c:44
float timeArr
Definition: timInt.h:85
static float Abc_MinFloat(float a, float b)
Definition: abc_global.h:244
void Tim_ManSetCiRequired(Tim_Man_t *p, int iCi, float Delay)
Definition: timTime.c:135
#define Tim_ManBoxForEachOutput(p, pBox, pObj, i)
Definition: timInt.h:122
void Tim_ManInitPoRequiredAll(Tim_Man_t *p, float Delay)
Definition: timTime.c:97
static Llb_Mgr_t * p
Definition: llb3Image.c:950
float Tim_ManGetCiArrival(Tim_Man_t *p, int iCi)
Definition: timTime.c:174
static Tim_Box_t * Tim_ManCiBox(Tim_Man_t *p, int i)
Definition: timInt.h:97
static Tim_Box_t * Tim_ManCoBox(Tim_Man_t *p, int i)
Definition: timInt.h:98
#define Tim_ManForEachPo(p, pObj, i)
Definition: timInt.h:114
void Tim_ManInitPiArrivalAll(Tim_Man_t *p, float Delay)
Definition: timTime.c:78
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
float timeReq
Definition: timInt.h:86
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define Tim_ManBoxForEachInput(p, pBox, pObj, i)
Definition: timInt.h:120
void Tim_ManInitPoRequired(Tim_Man_t *p, int iPo, float Delay)
Definition: timTime.c:61
void Tim_ManSetCoArrival(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:116
static Tim_Obj_t * Tim_ManCi(Tim_Man_t *p, int i)
MACRO DEFINITIONS ///.
Definition: timInt.h:93
int TravId
Definition: timInt.h:82
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
float Tim_ManGetCoRequired(Tim_Man_t *p, int iCo)
Definition: timTime.c:222
#define Tim_ManForEachPi(p, pObj, i)
Definition: timInt.h:112
#define TIM_ETERNITY
MACRO DEFINITIONS ///.
Definition: tim.h:98
static Tim_Obj_t * Tim_ManCo(Tim_Man_t *p, int i)
Definition: timInt.h:94
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define assert(ex)
Definition: util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition: tim.h:92
typedefABC_NAMESPACE_HEADER_START struct Tim_Box_t_ Tim_Box_t
INCLUDES ///.
Definition: timInt.h:48
void Tim_ManSetCoRequired(Tim_Man_t *p, int iCo, float Delay)
Definition: timTime.c:154
float * Tim_ManBoxDelayTable(Tim_Man_t *p, int iBox)
Definition: timBox.c:234