abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
place_inc.c
Go to the documentation of this file.
1 /*===================================================================*/
2 //
3 // place_inc.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 inline int sqHashId(int id, int max) {
22  return ((id * (id+17)) % max);
23 }
24 
25 #if 0
26 // --------------------------------------------------------------------
27 // fastPlace()
28 //
29 /// The first cell is assumed to be the "output".
30 // --------------------------------------------------------------------
31 float fastPlace(int numCells, ConcreteCell *cells[],
32  int numNets, ConcreteNet *nets[]) {
33 
34  int n, t, c, i, local_id = 0, pass;
35  const int NUM_PASSES = 4;
36  int *cell_numTerms = calloc(numCells, sizeof(int));
37  ConcreteNet **cell_terms;
38  ConcreteNet *net;
39  Rect outputBox;
40 
41  outputBox = getNetBBox(nets[0]);
42 
43  // assign local ids
44  // put cells in reasonable initial location
45  for(n=0; n<numNets; n++)
46  for(t=0; nets[n]->m_numTerms; t++)
47  nets[n]->m_terms[t]->m_data = -1;
48 
49  for(c=0; c<numCells; c++) {
50  cells[c]->m_data = local_id;
51  cells[c]->m_x = outputBox.x + 0.5*outputBox.w;
52  cells[c]->m_y = outputBox.y + 0.5*outputBox.h;
53  }
54 
55  // build reverse map of cells to nets
56  for(n=0; n<numNets; n++)
57  for(t=0; nets[n]->m_numTerms; t++) {
58  local_id = nets[n]->m_terms[t]->m_data;
59  if (local_id >= 0)
60  cell_numTerms[local_id]++;
61  }
62 
63  for(c=0; c<numCells; c++) {
64  cell_terms[c] = malloc(sizeof(ConcreteNet*)*cell_numTerms[c]);
65  cell_numTerms[c] = 0;
66  }
67 
68  for(n=0; n<numNets; n++)
69  for(t=0; nets[n]->m_numTerms; t++) {
70  local_id = nets[n]->m_terms[t]->m_data;
71  if (local_id >= 0)
72  cell_terms[cell_numTerms[local_id]++] = nets[n];
73  }
74 
75  // topological order?
76 
77  // iterative linear
78  for(pass=0; pass<NUM_PASSES; pass++)
79  for(c=0; c<numCells; c++) {
80  for(n=0; n<cell_numTerms[c]; n++) {
81  net = cell_terms[c];
82  for(t=0; t<net->m_numTerms; t++);
83  }
84  }
85 }
86 #endif
87 
88 // --------------------------------------------------------------------
89 // fastEstimate()
90 //
91 // --------------------------------------------------------------------
93  int numNets, ConcreteNet *nets[]) {
94  float len = 0;
95  int n;
96  Rect box;
97 
98  assert(cell);
99 
100  for(n=0; n<numNets; n++) {
101  box = getNetBBox(nets[n]);
102  if (cell->m_x < box.x) len += (box.x - cell->m_x);
103  if (cell->m_x > box.x+box.w) len += (cell->m_x-box.x-box.w);
104  if (cell->m_y < box.y) len += (box.x - cell->m_y);
105  if (cell->m_y > box.y+box.h) len += (cell->m_y-box.y-box.h);
106  }
107 
108  return len;
109 }
111 
char * malloc()
ConcreteCell * cells
Definition: abcPlace.c:34
float h
Definition: place_base.h:36
float x
Definition: place_base.h:35
ABC_NAMESPACE_IMPL_START int sqHashId(int id, int max)
Definition: place_inc.c:21
float fastEstimate(ConcreteCell *cell, int numNets, ConcreteNet *nets[])
Definition: place_inc.c:92
float y
Definition: place_base.h:35
ConcreteNet * nets
Definition: abcPlace.c:35
ConcreteCell ** m_terms
Definition: place_base.h:72
int numNets
Definition: place_test.c:68
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static double max
Definition: cuddSubsetHB.c:134
int m_numTerms
Definition: place_base.h:71
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
float w
Definition: place_base.h:36
int numCells
Definition: place_test.c:68
char * calloc()
Rect getNetBBox(const ConcreteNet *net)
Returns the bounding box of a net.
Definition: place_base.c:45
#define assert(ex)
Definition: util_old.h:213