ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
place_base.c
Go to the documentation of this file.
1/*===================================================================*/
2//
3// place_base.c
4//
5// Aaron P. Hurst, 2003-2007
6// ahurst@eecs.berkeley.edu
7//
8/*===================================================================*/
9
10#include <stdlib.h>
11#include <limits.h>
12#include <assert.h>
13#include <string.h>
14
15#include "place_base.h"
16#include "place_gordian.h"
17
19
20
21// --------------------------------------------------------------------
22// Global variables
23//
24// --------------------------------------------------------------------
25
29
32
37
38
39// --------------------------------------------------------------------
40// getNetBBox()
41//
43//
44// --------------------------------------------------------------------
46 int t;
47 Rect r;
48
49 assert(net);
50
51 r.x = r.y = INT_MAX;
52 r.w = r.h = -INT_MAX;
53 for(t=0; t<net->m_numTerms; t++) {
54 r.x = net->m_terms[t]->m_x < r.x ? net->m_terms[t]->m_x : r.x;
55 r.y = net->m_terms[t]->m_y < r.y ? net->m_terms[t]->m_y : r.y;
56 r.w = net->m_terms[t]->m_x > r.w ? net->m_terms[t]->m_x : r.w;
57 r.h = net->m_terms[t]->m_y > r.h ? net->m_terms[t]->m_y : r.h;
58 }
59 r.w -= r.x; r.h -= r.y;
60 return r;
61}
62
63
64// --------------------------------------------------------------------
65// getNetWirelength()
66//
68//
69// --------------------------------------------------------------------
70float getNetWirelength(const ConcreteNet *net) {
71 Rect r;
72
73 assert(net);
74
75 r = getNetBBox(net);
76 return r.w+r.h;
77}
78
79
80// --------------------------------------------------------------------
81// getTotalWirelength()
82//
84//
85// --------------------------------------------------------------------
87 float r = 0;
88 int n;
89 for(n=0; n<g_place_numNets; n++) if (g_place_concreteNets[n])
91 return r;
92}
93
94
95// --------------------------------------------------------------------
96// getCellArea()
97//
98// --------------------------------------------------------------------
99float getCellArea(const ConcreteCell *cell) {
100 assert(cell);
101 return cell->m_parent->m_width*cell->m_parent->m_height;
102}
103
104
105// --------------------------------------------------------------------
106// addConcreteNet()
107//
112//
113// --------------------------------------------------------------------
134
135
136// --------------------------------------------------------------------
137// delConcreteNet()
138//
140// --------------------------------------------------------------------
146
147
148// --------------------------------------------------------------------
149// addConcreteCell()
150//
153//
154// --------------------------------------------------------------------
174
175
176// --------------------------------------------------------------------
177// delCellFromPartition()
178//
179// --------------------------------------------------------------------
181 int c;
182 bool found = false;
183
184 assert(cell);
185 assert(p);
186
187 for(c=0; c<p->m_numMembers; c++)
188 if (p->m_members[c] == cell) {
189 p->m_members[c] = 0;
190 p->m_area -= getCellArea(cell);
191 found = true;
192 break;
193 }
194
195 if (!found) return;
196
197 if (!p->m_leaf) {
198 delCellFromPartition(cell, p->m_sub1);
199 delCellFromPartition(cell, p->m_sub2);
200 }
201}
202
203
204// --------------------------------------------------------------------
205// delConcreteCell()
206//
214//
215// --------------------------------------------------------------------
223
224
225// --------------------------------------------------------------------
226// netSortByX...
227//
229//
234// --------------------------------------------------------------------
235int netSortByL(const void *a, const void *b) {
236 const ConcreteNet *pa = *(const ConcreteNet **)a;
237 const ConcreteNet *pb = *(const ConcreteNet **)b;
238 Rect ba, bb;
239
240 if (!pa && !pb) return 0;
241 else if (!pa) return -1;
242 else if (!pb) return 1;
243 ba = getNetBBox(pa), bb = getNetBBox(pb);
244 if (ba.x < bb.x) return -1;
245 if (ba.x > bb.x) return 1;
246 return 0;
247}
248
249int netSortByR(const void *a, const void *b) {
250 const ConcreteNet *pa = *(const ConcreteNet **)a;
251 const ConcreteNet *pb = *(const ConcreteNet **)b;
252 Rect ba, bb;
253
254 if (!pa && !pb) return 0;
255 else if (!pa) return -1;
256 else if (!pb) return 1;
257 ba = getNetBBox(pa), bb = getNetBBox(pb);
258 if (ba.x + ba.w < bb.x + bb.w) return -1;
259 if (ba.x + ba.w > bb.x + bb.w) return 1;
260 return 0;
261}
262
263int netSortByB(const void *a, const void *b) {
264 const ConcreteNet *pa = *(const ConcreteNet **)a;
265 const ConcreteNet *pb = *(const ConcreteNet **)b;
266 Rect ba, bb;
267
268 if (!pa && !pb) return 0;
269 else if (!pa) return -1;
270 else if (!pb) return 1;
271 ba = getNetBBox(pa), bb = getNetBBox(pb);
272 if (ba.y + ba.h < bb.y + bb.h) return -1;
273 if (ba.y + ba.h > bb.y + bb.h) return 1;
274 return 0;
275}
276
277int netSortByT(const void *a, const void *b) {
278 const ConcreteNet *pa = *(const ConcreteNet **)a;
279 const ConcreteNet *pb = *(const ConcreteNet **)b;
280 Rect ba, bb;
281
282 if (!pa && !pb) return 0;
283 else if (!pa) return -1;
284 else if (!pb) return 1;
285 ba = getNetBBox(pa), bb = getNetBBox(pb);
286 if (ba.y < bb.y) return -1;
287 if (ba.y > bb.y) return 1;
288 return 0;
289}
290
291int netSortByID(const void *a, const void *b) {
292 const ConcreteNet *pa = *(const ConcreteNet **)a;
293 const ConcreteNet *pb = *(const ConcreteNet **)b;
294
295 if (!pa && !pb) return 0;
296 else if (!pa) return -1;
297 else if (!pb) return 1;
298 if (pa->m_id < pb->m_id) return -1;
299 if (pa->m_id > pb->m_id) return 1;
300 return 0;
301}
302
303
304// --------------------------------------------------------------------
305// cellSortByX...
306//
308//
312//
313// --------------------------------------------------------------------
314int cellSortByX(const void *a, const void *b) {
315 const ConcreteCell *pa = *(const ConcreteCell **)a;
316 const ConcreteCell *pb = *(const ConcreteCell **)b;
317
318 if (!pa && !pb) return 0;
319 else if (!pa) return -1;
320 else if (!pb) return 1;
321 if (pa->m_x < pb->m_x) return -1;
322 if (pa->m_x > pb->m_x) return 1;
323 return 0;
324}
325
326int cellSortByY(const void *a, const void *b) {
327 const ConcreteCell *pa = *(const ConcreteCell **)a;
328 const ConcreteCell *pb = *(const ConcreteCell **)b;
329
330 if (!pa && !pb) return 0;
331 else if (!pa) return -1;
332 else if (!pb) return 1;
333 if (pa->m_y < pb->m_y) return -1;
334 if (pa->m_y > pb->m_y) return 1;
335 return 0;
336}
337
338int cellSortByID(const void *a, const void *b) {
339 const ConcreteCell *pa = *(const ConcreteCell **)a;
340 const ConcreteCell *pb = *(const ConcreteCell **)b;
341
342 if (!pa && !pb) return 0;
343 else if (!pa) return -1;
344 else if (!pb) return 1;
345 if (pa->m_id < pb->m_id) return -1;
346 if (pa->m_id > pb->m_id) return 1;
347 return 0;
348}
350
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
float getTotalWirelength()
Returns the total HPWL of all nets.
Definition place_base.c:86
ConcreteCell ** g_place_concreteCells
Definition place_base.c:33
Rect getNetBBox(const ConcreteNet *net)
Returns the bounding box of a net.
Definition place_base.c:45
ConcreteNet ** g_place_concreteNets
Definition place_base.c:35
int netSortByB(const void *a, const void *b)
Definition place_base.c:263
int netSortByR(const void *a, const void *b)
Definition place_base.c:249
Rect g_place_padBounds
Definition place_base.c:31
float getNetWirelength(const ConcreteNet *net)
Returns the half-perimeter wirelength of a net.
Definition place_base.c:70
int g_place_concreteNetsSize
Definition place_base.c:36
int cellSortByID(const void *a, const void *b)
Definition place_base.c:338
int g_place_concreteCellsSize
Definition place_base.c:34
void delConcreteCell(ConcreteCell *cell)
Removes a cell from the placement database.
Definition place_base.c:216
float getCellArea(const ConcreteCell *cell)
Definition place_base.c:99
void addConcreteNet(ConcreteNet *net)
Adds a net to the placement database.
Definition place_base.c:114
int cellSortByY(const void *a, const void *b)
Definition place_base.c:326
int netSortByID(const void *a, const void *b)
Definition place_base.c:291
int g_place_numNets
Definition place_base.c:27
void delCellFromPartition(ConcreteCell *cell, Partition *p)
Definition place_base.c:180
ABC_NAMESPACE_IMPL_START int g_place_numCells
Definition place_base.c:26
float g_place_rowHeight
Definition place_base.c:28
int netSortByT(const void *a, const void *b)
Definition place_base.c:277
Rect g_place_coreBounds
Definition place_base.c:30
int netSortByL(const void *a, const void *b)
Sorts nets by position of one of its corners.
Definition place_base.c:235
void delConcreteNet(ConcreteNet *net)
Does not deallocate memory.
Definition place_base.c:141
void addConcreteCell(ConcreteCell *cell)
Definition place_base.c:155
int cellSortByX(const void *a, const void *b)
Sorts cells by either position coordinate.
Definition place_base.c:314
Partition * g_place_rootPartition
float m_width
Definition place_base.h:45
float m_height
Definition place_base.h:45
AbstractCell * m_parent
Definition place_base.h:57
ConcreteCell ** m_terms
Definition place_base.h:72
float w
Definition place_base.h:36
float x
Definition place_base.h:35
float y
Definition place_base.h:35
float h
Definition place_base.h:36
#define assert(ex)
Definition util_old.h:213
char * memset()
char * realloc()