place_base.h 3.83 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8
/*===================================================================*/
//  
//     place_base.h
//
//        Aaron P. Hurst, 2003-2007
//              ahurst@eecs.berkeley.edu
//
/*===================================================================*/
Alan Mishchenko committed
9

Alan Mishchenko committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#if !defined(PLACE_BASE_H_)
#define PLACE_BASE_H_

// --------------------------------------------------------------------
// Data structures
//
// --------------------------------------------------------------------

// --- a C++ bool-like type
//typedef char bool;
#ifndef bool
#define bool int
#endif

#define true 1
#define false 0


// --- Rect - rectangle

typedef struct Rect {
  float x, y;
  float w, h;
} Rect;


// --- AbstractCell - a definition of a cell type

typedef struct AbstractCell {
  char *m_label;            // string description
Alan Mishchenko committed
40

Alan Mishchenko committed
41
  float m_width, m_height;  // dimensions
Alan Mishchenko committed
42

Alan Mishchenko committed
43 44 45 46 47 48 49 50
  bool  m_pad;              // a pad (external I/O) cell?
} AbstractCell;


// --- ConcreteCell - a design object

typedef struct ConcreteCell {
  int           m_id;       // a unique ID (see below)
Alan Mishchenko committed
51 52 53 54
  char         *m_label;    // string description

  AbstractCell *m_parent;   // cell type

Alan Mishchenko committed
55 56
  bool          m_fixed;    // position is fixed?
  float         m_x, m_y;   // center of cell
Alan Mishchenko committed
57 58

  int           m_data;
Alan Mishchenko committed
59 60 61 62 63 64 65
} ConcreteCell;


// --- ConcreteNet - a design net

typedef struct ConcreteNet {
  int            m_id;       // a unique ID (see below)
Alan Mishchenko committed
66

Alan Mishchenko committed
67 68
  int            m_numTerms; // num. of connected cells
  ConcreteCell **m_terms;    // connected cells
Alan Mishchenko committed
69

Alan Mishchenko committed
70
  float          m_weight;   // relative weight
Alan Mishchenko committed
71 72

  int            m_data;
Alan Mishchenko committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
} ConcreteNet;


// A note about IDs - the IDs are non-nonegative integers. They need not
// be contiguous, but this is certainly a good idea, as they are stored
// in a non-sparse array.
// Cells and nets have separate ID spaces.

// --------------------------------------------------------------------
// Global variable prototypes
//
// --------------------------------------------------------------------

// NOTE: None of these need to be managed externally.

extern int   g_place_numCells;   // number of cells
extern int   g_place_numNets;    // number of nets
extern float g_place_rowHeight;  // height of placement row
extern Rect  g_place_coreBounds; // border of placeable area
                                 // (x,y) = corner
extern Rect  g_place_padBounds;  // border of total die area
                                 // (x,y) = corner

extern ConcreteCell **g_place_concreteCells; // all concrete cells
extern ConcreteNet  **g_place_concreteNets;  // all concrete nets


// --------------------------------------------------------------------
// Function prototypes
//
// --------------------------------------------------------------------

void   addConcreteNet(ConcreteNet *net);
void   addConcreteCell(ConcreteCell *cell);
void   delConcreteNet(ConcreteNet *net);
void   delConcreteCell(ConcreteCell *cell);

void   globalPreplace(float utilization);
void   globalPlace();
void   globalIncremental();
void   globalFixDensity(int numBins, float maxMovement);

Alan Mishchenko committed
115 116 117 118
float fastEstimate(ConcreteCell *cell,
                   int numNets, ConcreteNet *nets[]);
float fastTopoPlace(int numCells, ConcreteCell *cells[], 
                    int numNets, ConcreteNet *nets[]);
Alan Mishchenko committed
119 120 121 122 123 124

Rect   getNetBBox(const ConcreteNet *net);
float  getNetWirelength(const ConcreteNet *net);
float  getTotalWirelength();
float  getCellArea(const ConcreteCell *cell);

Alan Mishchenko committed
125
void   writeBookshelf(const char *filename);
Alan Mishchenko committed
126 127 128 129 130 131 132 133 134 135 136 137

// comparative qsort-style functions
int    netSortByL(const void *a, const void *b);
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);
int    cellSortByY(const void *a, const void *b);
int    cellSortByID(const void *a, const void *b);

#endif