abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
timBox.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [timBox.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Hierarchy/timing manager.]
8 
9  Synopsis [Manipulation of timing 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: timBox.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 [Creates the new timing box.]
36 
37  Description []
38 
39  SideEffects []
40 
41  SeeAlso []
42 
43 ***********************************************************************/
44 void Tim_ManCreateBox( Tim_Man_t * p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable )
45 {
46  Tim_Box_t * pBox;
47  int i;
48  if ( p->vBoxes == NULL )
49  p->vBoxes = Vec_PtrAlloc( 100 );
50  pBox = (Tim_Box_t *)Mem_FlexEntryFetch( p->pMemObj, sizeof(Tim_Box_t) + sizeof(int) * (nIns+nOuts) );
51  memset( pBox, 0, sizeof(Tim_Box_t) );
52  pBox->iBox = Vec_PtrSize( p->vBoxes );
53  Vec_PtrPush( p->vBoxes, pBox );
54  pBox->iDelayTable = iDelayTable;
55  pBox->nInputs = nIns;
56  pBox->nOutputs = nOuts;
57  for ( i = 0; i < nIns; i++ )
58  {
59  assert( firstIn+i < p->nCos );
60  pBox->Inouts[i] = firstIn+i;
61  p->pCos[firstIn+i].iObj2Box = pBox->iBox;
62  p->pCos[firstIn+i].iObj2Num = i;
63  }
64  for ( i = 0; i < nOuts; i++ )
65  {
66  assert( firstOut+i < p->nCis );
67  pBox->Inouts[nIns+i] = firstOut+i;
68  p->pCis[firstOut+i].iObj2Box = pBox->iBox;
69  p->pCis[firstOut+i].iObj2Num = i;
70  }
71 // if ( pBox->iBox < 20 )
72 // printf( "%4d %4d %4d %4d \n", firstIn, nIns, firstOut, nOuts );
73 }
74 
75 /**Function*************************************************************
76 
77  Synopsis [Returns the box number for the given input.]
78 
79  Description []
80 
81  SideEffects []
82 
83  SeeAlso []
84 
85 ***********************************************************************/
86 int Tim_ManBoxForCi( Tim_Man_t * p, int iCi )
87 {
88  if ( iCi >= p->nCis )
89  return -1;
90  return p->pCis[iCi].iObj2Box;
91 }
92 
93 /**Function*************************************************************
94 
95  Synopsis [Returns the box number for the given output.]
96 
97  Description []
98 
99  SideEffects []
100 
101  SeeAlso []
102 
103 ***********************************************************************/
104 int Tim_ManBoxForCo( Tim_Man_t * p, int iCo )
105 {
106  if ( iCo >= p->nCos )
107  return -1;
108  return p->pCos[iCo].iObj2Box;
109 }
110 
111 /**Function*************************************************************
112 
113  Synopsis [Returns the first input of the box.]
114 
115  Description []
116 
117  SideEffects []
118 
119  SeeAlso []
120 
121 ***********************************************************************/
122 int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox )
123 {
124  return Tim_ManBox(p, iBox)->Inouts[0];
125 }
126 
127 /**Function*************************************************************
128 
129  Synopsis [Returns the last input of the box.]
130 
131  Description []
132 
133  SideEffects []
134 
135  SeeAlso []
136 
137 ***********************************************************************/
138 int Tim_ManBoxInputLast( Tim_Man_t * p, int iBox )
139 {
140  return Tim_ManBox(p, iBox)->Inouts[0] + Tim_ManBoxInputNum(p, iBox) - 1;
141 }
142 
143 /**Function*************************************************************
144 
145  Synopsis [Returns the first output of the box.]
146 
147  Description []
148 
149  SideEffects []
150 
151  SeeAlso []
152 
153 ***********************************************************************/
155 {
156  return Tim_ManBox(p, iBox)->Inouts[Tim_ManBox(p, iBox)->nInputs];
157 }
158 
159 /**Function*************************************************************
160 
161  Synopsis [Returns the last output of the box.]
162 
163  Description []
164 
165  SideEffects []
166 
167  SeeAlso []
168 
169 ***********************************************************************/
170 int Tim_ManBoxOutputLast( Tim_Man_t * p, int iBox )
171 {
172  return Tim_ManBox(p, iBox)->Inouts[Tim_ManBox(p, iBox)->nInputs] + Tim_ManBoxOutputNum(p, iBox) - 1;
173 }
174 
175 /**Function*************************************************************
176 
177  Synopsis [Returns the number of box inputs.]
178 
179  Description []
180 
181  SideEffects []
182 
183  SeeAlso []
184 
185 ***********************************************************************/
186 int Tim_ManBoxInputNum( Tim_Man_t * p, int iBox )
187 {
188  return Tim_ManBox(p, iBox)->nInputs;
189 }
190 
191 /**Function*************************************************************
192 
193  Synopsis [Returns the number of box outputs.]
194 
195  Description []
196 
197  SideEffects []
198 
199  SeeAlso []
200 
201 ***********************************************************************/
202 int Tim_ManBoxOutputNum( Tim_Man_t * p, int iBox )
203 {
204  return Tim_ManBox(p, iBox)->nOutputs;
205 }
206 
207 /**Function*************************************************************
208 
209  Synopsis [Return the delay table id.]
210 
211  Description []
212 
213  SideEffects []
214 
215  SeeAlso []
216 
217 ***********************************************************************/
219 {
220  return Tim_ManBox(p, iBox)->iDelayTable;
221 }
222 
223 /**Function*************************************************************
224 
225  Synopsis [Return the delay table.]
226 
227  Description []
228 
229  SideEffects []
230 
231  SeeAlso []
232 
233 ***********************************************************************/
234 float * Tim_ManBoxDelayTable( Tim_Man_t * p, int iBox )
235 {
236  float * pTable;
237  Tim_Box_t * pBox = Tim_ManBox(p, iBox);
238  if ( pBox->iDelayTable < 0 )
239  return NULL;
240  pTable = (float *)Vec_PtrEntry( p->vDelayTables, pBox->iDelayTable );
241  assert( (int)pTable[1] == pBox->nInputs );
242  assert( (int)pTable[2] == pBox->nOutputs );
243  return pTable;
244 }
245 
246 /**Function*************************************************************
247 
248  Synopsis [Return 1 if the box is black.]
249 
250  Description []
251 
252  SideEffects []
253 
254  SeeAlso []
255 
256 ***********************************************************************/
257 int Tim_ManBoxIsBlack( Tim_Man_t * p, int iBox )
258 {
259  return Tim_ManBox(p, iBox)->fBlack;
260 }
261 
262 
263 /**Function*************************************************************
264 
265  Synopsis [Returns the copy of the box.]
266 
267  Description []
268 
269  SideEffects []
270 
271  SeeAlso []
272 
273 ***********************************************************************/
274 int Tim_ManBoxCopy( Tim_Man_t * p, int iBox )
275 {
276  return Tim_ManBox(p, iBox)->iCopy;
277 }
278 
279 /**Function*************************************************************
280 
281  Synopsis [Sets the copy of the box.]
282 
283  Description []
284 
285  SideEffects []
286 
287  SeeAlso []
288 
289 ***********************************************************************/
290 void Tim_ManBoxSetCopy( Tim_Man_t * p, int iBox, int iCopy )
291 {
292  Tim_ManBox(p, iBox)->iCopy = iCopy;
293 }
294 
295 /**Function*************************************************************
296 
297  Synopsis []
298 
299  Description []
300 
301  SideEffects []
302 
303  SeeAlso []
304 
305 ***********************************************************************/
306 int Tim_ManBoxFindFromCiNum( Tim_Man_t * p, int iCiNum )
307 {
308  Tim_Box_t * pBox;
309  int i;
310  assert( iCiNum >= 0 && iCiNum < Tim_ManCiNum(p) );
311  if ( iCiNum < Tim_ManPiNum(p) )
312  return -1;
313  Tim_ManForEachBox( p, pBox, i )
314  if ( iCiNum < Tim_ManBoxOutputFirst(p, i) )
315  return i - 1;
316  return -2;
317 }
318 
319 ////////////////////////////////////////////////////////////////////////
320 /// END OF FILE ///
321 ////////////////////////////////////////////////////////////////////////
322 
323 
325 
int Tim_ManBoxCopy(Tim_Man_t *p, int iBox)
Definition: timBox.c:274
char * memset()
int Tim_ManBoxOutputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:154
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Tim_ManBoxSetCopy(Tim_Man_t *p, int iBox, int iCopy)
Definition: timBox.c:290
int nCos
Definition: timInt.h:60
#define Tim_ManForEachBox(p, pBox, i)
Definition: timInt.h:117
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:186
int Tim_ManBoxIsBlack(Tim_Man_t *p, int iBox)
Definition: timBox.c:257
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int Tim_ManBoxFindFromCiNum(Tim_Man_t *p, int iCiNum)
Definition: timBox.c:306
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
Definition: mem.c:372
int Tim_ManPiNum(Tim_Man_t *p)
Definition: timMan.c:688
int Tim_ManBoxForCo(Tim_Man_t *p, int iCo)
Definition: timBox.c:104
float * Tim_ManBoxDelayTable(Tim_Man_t *p, int iBox)
Definition: timBox.c:234
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int Tim_ManCiNum(Tim_Man_t *p)
Definition: timMan.c:680
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition: timBox.c:122
int Tim_ManBoxOutputLast(Tim_Man_t *p, int iBox)
Definition: timBox.c:170
ABC_NAMESPACE_IMPL_START void Tim_ManCreateBox(Tim_Man_t *p, int firstIn, int nIns, int firstOut, int nOuts, int iDelayTable)
DECLARATIONS ///.
Definition: timBox.c:44
int Tim_ManBoxInputLast(Tim_Man_t *p, int iBox)
Definition: timBox.c:138
static Tim_Box_t * Tim_ManBox(Tim_Man_t *p, int i)
Definition: timInt.h:95
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int nCis
Definition: timInt.h:59
int Tim_ManBoxDelayTableId(Tim_Man_t *p, int iBox)
Definition: timBox.c:218
#define assert(ex)
Definition: util_old.h:213
int Tim_ManBoxForCi(Tim_Man_t *p, int iCi)
Definition: timBox.c:86
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
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
Definition: timBox.c:202