ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
place_base.c File Reference
#include <stdlib.h>
#include <limits.h>
#include <assert.h>
#include <string.h>
#include "place_base.h"
#include "place_gordian.h"
Include dependency graph for place_base.c:

Go to the source code of this file.

Functions

Rect getNetBBox (const ConcreteNet *net)
 Returns the bounding box of a net.
 
float getNetWirelength (const ConcreteNet *net)
 Returns the half-perimeter wirelength of a net.
 
float getTotalWirelength ()
 Returns the total HPWL of all nets.
 
float getCellArea (const ConcreteCell *cell)
 
void addConcreteNet (ConcreteNet *net)
 Adds a net to the placement database.
 
void delConcreteNet (ConcreteNet *net)
 Does not deallocate memory.
 
void addConcreteCell (ConcreteCell *cell)
 
void delCellFromPartition (ConcreteCell *cell, Partition *p)
 
void delConcreteCell (ConcreteCell *cell)
 Removes a cell from the placement database.
 
int netSortByL (const void *a, const void *b)
 Sorts nets by position of one of its corners.
 
int netSortByR (const void *a, const void *b)
 
int netSortByB (const void *a, const void *b)
 
int netSortByT (const void *a, const void *b)
 
int netSortByID (const void *a, const void *b)
 
int cellSortByX (const void *a, const void *b)
 Sorts cells by either position coordinate.
 
int cellSortByY (const void *a, const void *b)
 
int cellSortByID (const void *a, const void *b)
 

Variables

ABC_NAMESPACE_IMPL_START int g_place_numCells = 0
 
int g_place_numNets = 0
 
float g_place_rowHeight = 1.0
 
Rect g_place_coreBounds
 
Rect g_place_padBounds
 
ConcreteCell ** g_place_concreteCells = NULL
 
int g_place_concreteCellsSize = 0
 
ConcreteNet ** g_place_concreteNets = NULL
 
int g_place_concreteNetsSize = 0
 

Function Documentation

◆ addConcreteCell()

void addConcreteCell ( ConcreteCell * cell)

The cell object must already be allocated and the ID must be set appropriately.

Definition at line 155 of file place_base.c.

155 {
156 assert(cell);
157 assert(cell->m_id >= 0);
158 if (cell->m_id >= g_place_concreteCellsSize) {
166 }
167 if (cell->m_id >= g_place_numCells) {
169 sizeof(ConcreteCell*)*(cell->m_id+1-g_place_numCells));
170 g_place_numCells = cell->m_id+1;
171 }
172 g_place_concreteCells[cell->m_id] = cell;
173}
ConcreteCell ** g_place_concreteCells
Definition place_base.c:33
int g_place_concreteCellsSize
Definition place_base.c:34
ABC_NAMESPACE_IMPL_START int g_place_numCells
Definition place_base.c:26
#define assert(ex)
Definition util_old.h:213
char * memset()
char * realloc()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConcreteNet()

void addConcreteNet ( ConcreteNet * net)

Adds a net to the placement database.

The net object must already be allocated and the ID must be set appropriately.

Definition at line 114 of file place_base.c.

114 {
115 assert(net);
116 assert(net->m_id >= 0);
117 if (net->m_id >= g_place_concreteNetsSize) {
125 }
126 if (net->m_id >= g_place_numNets) {
128 sizeof(ConcreteNet*)*(net->m_id+1-g_place_numNets));
129 g_place_numNets = net->m_id+1;
131 }
132 g_place_concreteNets[net->m_id] = net;
133}
ConcreteNet ** g_place_concreteNets
Definition place_base.c:35
int g_place_concreteNetsSize
Definition place_base.c:36
int g_place_numNets
Definition place_base.c:27
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cellSortByID()

int cellSortByID ( const void * a,
const void * b )

Definition at line 338 of file place_base.c.

338 {
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}
Here is the caller graph for this function:

◆ cellSortByX()

int cellSortByX ( const void * a,
const void * b )

Sorts cells by either position coordinate.

These are for use with qsort().

Can tolerate pointers to NULL objects.

Definition at line 314 of file place_base.c.

314 {
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}
Here is the caller graph for this function:

◆ cellSortByY()

int cellSortByY ( const void * a,
const void * b )

Definition at line 326 of file place_base.c.

326 {
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}
Here is the caller graph for this function:

◆ delCellFromPartition()

void delCellFromPartition ( ConcreteCell * cell,
Partition * p )

Definition at line 180 of file place_base.c.

180 {
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}
Cube * p
Definition exorList.c:222
float getCellArea(const ConcreteCell *cell)
Definition place_base.c:99
void delCellFromPartition(ConcreteCell *cell, Partition *p)
Definition place_base.c:180
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delConcreteCell()

void delConcreteCell ( ConcreteCell * cell)

Removes a cell from the placement database.

Does not deallocate memory.

Important: does not modify nets that may point to this cell. If these are connections are not removed, segmentation faults and other nasty errors will occur.

Definition at line 216 of file place_base.c.

216 {
217 assert(cell);
218 g_place_concreteCells[cell->m_id] = 0;
220
222}
Partition * g_place_rootPartition
Here is the call graph for this function:

◆ delConcreteNet()

void delConcreteNet ( ConcreteNet * net)

Does not deallocate memory.

Definition at line 141 of file place_base.c.

141 {
142 assert(net);
143 g_place_concreteNets[net->m_id] = 0;
145}

◆ getCellArea()

float getCellArea ( const ConcreteCell * cell)

Definition at line 99 of file place_base.c.

99 {
100 assert(cell);
101 return cell->m_parent->m_width*cell->m_parent->m_height;
102}
float m_width
Definition place_base.h:45
float m_height
Definition place_base.h:45
AbstractCell * m_parent
Definition place_base.h:57
Here is the caller graph for this function:

◆ getNetBBox()

Rect getNetBBox ( const ConcreteNet * net)

Returns the bounding box of a net.

Definition at line 45 of file place_base.c.

45 {
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}
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
Here is the caller graph for this function:

◆ getNetWirelength()

float getNetWirelength ( const ConcreteNet * net)

Returns the half-perimeter wirelength of a net.

Definition at line 70 of file place_base.c.

70 {
71 Rect r;
72
73 assert(net);
74
75 r = getNetBBox(net);
76 return r.w+r.h;
77}
Rect getNetBBox(const ConcreteNet *net)
Returns the bounding box of a net.
Definition place_base.c:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTotalWirelength()

float getTotalWirelength ( )

Returns the total HPWL of all nets.

Definition at line 86 of file place_base.c.

86 {
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}
float getNetWirelength(const ConcreteNet *net)
Returns the half-perimeter wirelength of a net.
Definition place_base.c:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netSortByB()

int netSortByB ( const void * a,
const void * b )

Definition at line 263 of file place_base.c.

263 {
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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netSortByID()

int netSortByID ( const void * a,
const void * b )

Definition at line 291 of file place_base.c.

291 {
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}

◆ netSortByL()

int netSortByL ( const void * a,
const void * b )

Sorts nets by position of one of its corners.

These are for use with qsort().

Can tolerate pointers to NULL objects.

Definition at line 235 of file place_base.c.

235 {
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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netSortByR()

int netSortByR ( const void * a,
const void * b )

Definition at line 249 of file place_base.c.

249 {
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}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ netSortByT()

int netSortByT ( const void * a,
const void * b )

Definition at line 277 of file place_base.c.

277 {
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}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_place_concreteCells

ConcreteCell** g_place_concreteCells = NULL

Definition at line 33 of file place_base.c.

◆ g_place_concreteCellsSize

int g_place_concreteCellsSize = 0

Definition at line 34 of file place_base.c.

◆ g_place_concreteNets

ConcreteNet** g_place_concreteNets = NULL

Definition at line 35 of file place_base.c.

◆ g_place_concreteNetsSize

int g_place_concreteNetsSize = 0

Definition at line 36 of file place_base.c.

◆ g_place_coreBounds

Rect g_place_coreBounds

Definition at line 30 of file place_base.c.

◆ g_place_numCells

ABC_NAMESPACE_IMPL_START int g_place_numCells = 0

Definition at line 26 of file place_base.c.

◆ g_place_numNets

int g_place_numNets = 0

Definition at line 27 of file place_base.c.

◆ g_place_padBounds

Rect g_place_padBounds

Definition at line 31 of file place_base.c.

◆ g_place_rowHeight

float g_place_rowHeight = 1.0

Definition at line 28 of file place_base.c.