Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
uvahotspot
GitHub Repository: uvahotspot/HotSpot
Path: blob/master/flp.h
612 views
1
#ifndef __FLP_H_
2
#define __FLP_H_
3
4
#include "util.h"
5
6
#define MAX_UNITS 8192
7
#define MAX_MOVES 16
8
9
/* types of cuts */
10
#define CUT_NONE -1
11
#define CUT_VERTICAL -2
12
#define CUT_HORIZONTAL -3
13
14
/* wrap around L2 with extra arms */
15
#define L2_LEFT 0
16
#define L2_RIGHT 1
17
#define L2_ARMS 2
18
#define L2_LEFT_STR "_left"
19
#define L2_RIGHT_STR "_right"
20
/* L2 sizing ratio of arm width to base height */
21
#define WRAP_L2_RATIO 5
22
23
/*
24
* chip edge has true dead space, which is
25
* modeled by the following blocks
26
*/
27
#define RIM_LEFT 1
28
#define RIM_RIGHT 2
29
#define RIM_TOP 4
30
#define RIM_BOTTOM 8
31
#define RIM_PREFIX "RIM"
32
#define RIM_LEFT_STR RIM_PREFIX"_left"
33
#define RIM_RIGHT_STR RIM_PREFIX"_right"
34
#define RIM_TOP_STR RIM_PREFIX"_top"
35
#define RIM_BOTTOM_STR RIM_PREFIX"_bottom"
36
37
/* prefix denoting dead block */
38
#define DEAD_PREFIX "_"
39
40
/* flags denoting orientation */
41
/* rotated orientations */
42
#define ROT_0 0x01 /* normal */
43
#define ROT_90 0x02 /* 90 degrees anticlockwise */
44
#define ROT_180 0x04 /* 180 degrees anticlockwise */
45
#define ROT_270 0x08 /* 270 degrees anticlockwise */
46
/* flipped + rotated orientations */
47
#define FLIP_0 0x10 /* flip about y axis of ROT_0 */
48
#define FLIP_90 0x20 /* flip about y axis of ROT_90 */
49
#define FLIP_180 0x40 /* flip about y axis of ROT_180 */
50
#define FLIP_270 0x80 /* flip about y axis of ROT_270 */
51
#define ORIENTS_N 8 /* total no. of orientations */
52
#define ORIENT_NDEF 0xDF /* undefined orientation */
53
54
/* type for holding the above flags */
55
typedef unsigned char orient_t;
56
57
/* forward declarations */
58
struct RC_model_t_st; /* see temperature.h */
59
struct shape_t_st; /* see shape.h */
60
61
/* configuration parameters for the floorplan */
62
typedef struct flp_config_t_st
63
{
64
/* wrap around L2? */
65
int wrap_l2;
66
/* name of L2 to look for */
67
char l2_label[STR_SIZE];
68
69
/* model dead space around the rim of the chip? */
70
int model_rim;
71
double rim_thickness;
72
73
/* area ratio below which to ignore dead space */
74
double compact_ratio;
75
76
/*
77
* no. of discrete orientations for a shape curve.
78
* should be an even number greater than 1
79
*/
80
int n_orients;
81
82
/* annealing parameters */
83
double P0; /* initial acceptance probability */
84
double Davg; /* average change (delta) in cost */
85
double Kmoves; /* no. of moves to try in each step */
86
double Rcool; /* ratio for the cooling schedule */
87
double Rreject; /* ratio of rejects at which to stop annealing */
88
int Nmax; /* absolute max no. of annealing steps */
89
90
/* weights for the metric: lambdaA * A + lambdaT * T + lambdaW * W */
91
double lambdaA;
92
double lambdaT;
93
double lambdaW;
94
} flp_config_t;
95
96
/* unplaced unit */
97
typedef struct unplaced_t_st
98
{
99
char name[STR_SIZE];
100
/* can be rotated? */
101
int rotable;
102
double area;
103
/* minimum and maximum aspect ratios */
104
double min_aspect;
105
double max_aspect;
106
/* shape curve for this unit */
107
struct shape_t_st *shape;
108
}unplaced_t;
109
110
/* input description for floorplanning */
111
typedef struct flp_desc_t_st
112
{
113
unplaced_t *units;
114
/* density of wires between units */
115
double **wire_density;
116
/* configuration parameters */
117
flp_config_t config;
118
int n_units;
119
}flp_desc_t;
120
121
/* placed functional unit */
122
typedef struct unit_t_st
123
{
124
char name[STR_SIZE];
125
double width;
126
double height;
127
double leftx;
128
double bottomy;
129
//BU_3D: new parameters for each functional unit. Allows for specific R-C values at a block-level.
130
double specificheat;
131
double resistivity;
132
int hasRes;
133
int hasSh;
134
//end->BU_3D
135
}unit_t;
136
137
/* floorplan data structure */
138
typedef struct flp_t_st
139
{
140
unit_t *units;
141
int n_units;
142
/* density of wires between units */
143
double **wire_density;
144
} flp_t;
145
146
/* flp_config routines */
147
148
/* default flp_config */
149
flp_config_t default_flp_config(void);
150
/*
151
* parse a table of name-value string pairs and add the configuration
152
* parameters to 'config'
153
*/
154
void flp_config_add_from_strs(flp_config_t *config, str_pair *table, int size);
155
/*
156
* convert config into a table of name-value pairs. returns the no.
157
* of parameters converted
158
*/
159
int flp_config_to_strs(flp_config_t *config, str_pair *table, int max_entries);
160
161
/* flp_desc routines */
162
163
/* read floorplan description and allocate memory */
164
flp_desc_t *read_flp_desc(char *file, flp_config_t *config);
165
void free_flp_desc(flp_desc_t *flp_desc);
166
/* debug print */
167
void print_unplaced(unplaced_t *unit);
168
void print_flp_desc(flp_desc_t *flp_desc);
169
170
/* flp routines */
171
172
/* create a floorplan placeholder from description */
173
flp_t *flp_placeholder(flp_desc_t *flp_desc);
174
/* skip floorplanning and read floorplan directly from file */
175
flp_t *read_flp(char *file, int read_connects, int initialize_connects);
176
/*
177
* main flooplanning routine - allocates
178
* memory internally. returns the number
179
* of compacted blocks
180
*/
181
int floorplan(flp_t *flp, flp_desc_t *flp_desc,
182
struct RC_model_t_st *model, double *power);
183
/*
184
* print the floorplan in a FIG like format
185
* that can be read by tofig.pl to produce
186
* an xfig output
187
*/
188
void print_flp_fig (flp_t *flp);
189
/* debug print */
190
void print_flp (flp_t *flp, int print_connects);
191
/* print the statistics about this floorplan */
192
void print_flp_stats(flp_t *flp, struct RC_model_t_st *model,
193
char *l2_label, char *power_file,
194
char *connects_file);
195
/* wrap the L2 around this floorplan */
196
void flp_wrap_l2(flp_t *flp, flp_desc_t *flp_desc);
197
/* wrap the rim blocks around - returns the no. of blocks */
198
int flp_wrap_rim(flp_t *flp, double rim_thickness);
199
/* translate the floorplan to new origin (x,y) */
200
void flp_translate(flp_t *flp, double x, double y);
201
/* scale the floorplan by a factor 'factor' */
202
void flp_scale(flp_t *flp, double factor);
203
/*
204
* change the orientation of the floorplan by
205
* rotating and/or flipping. the target orientation
206
* is specified in 'target'. 'width', 'height', 'xorig'
207
* and 'yorig' are those of 'flp' respectively.
208
*/
209
void flp_change_orient(flp_t *flp, double xorig, double yorig,
210
double width, double height, orient_t target);
211
212
/*
213
* create a non-uniform grid-like floorplan equivalent to this.
214
* this function is mainly useful when using the HotSpot block
215
* model to model floorplans of drastically differing aspect
216
* ratios and granularity. an example for such a floorplan
217
* would be the standard ev6 floorplan that comes with HotSpot,
218
* where the register file is subdivided into say 128 entries.
219
* the HotSpot block model could result in inaccuracies while
220
* trying to model such floorplans of differing granularity.
221
* if such inaccuracies occur, use this function to create an
222
* equivalent floorplan that can be modeled accurately in
223
* HotSpot. 'map' is an output parameter to store the 2-d array
224
* allocated by the function.
225
*/
226
flp_t *flp_create_grid(flp_t *flp, int ***map);
227
/* free the map allocated by flp_create_grid */
228
void free_blkgrid_map(flp_t *flp, int **map);
229
/* translate power numbers to the grid created by flp_create_grid */
230
void xlate_power_blkgrid(flp_t *flp, flp_t *grid, \
231
double *bpower, double *gpower, int **map);
232
/* the metric used to evaluate the floorplan */
233
double flp_evaluate_metric(flp_t *flp, struct RC_model_t_st *model, double *power,
234
double lambdaA, double lambdaT, double lambdaW);
235
/* dump the floorplan onto a file */
236
void dump_flp(flp_t *flp, char *file, int dump_connects);
237
/* memory uninitialization */
238
void free_flp(flp_t *flp, int compacted, int free_connects);
239
240
241
/* placed floorplan access routines */
242
243
/* get unit index from its name */
244
int get_blk_index(flp_t *flp, char *name);
245
/* are the units horizontally adjacent? */
246
int is_horiz_adj(flp_t *flp, int i, int j);
247
/* are the units vertically adjacent? */
248
int is_vert_adj (flp_t *flp, int i, int j);
249
/* shared length between units */
250
double get_shared_len(flp_t *flp, int i, int j);
251
/* total chip width */
252
double get_total_width(flp_t *flp);
253
/* total chip height */
254
double get_total_height(flp_t *flp);
255
/* x and y origins */
256
double get_minx(flp_t *flp);
257
double get_miny(flp_t *flp);
258
/* precondition: L2 should have been wrapped around */
259
double get_core_width(flp_t *flp, char *l2_label);
260
/* precondition: L2 should have been wrapped around */
261
double get_core_height(flp_t *flp, char *l2_label);
262
/* other queries */
263
double get_manhattan_dist(flp_t *flp, int i, int j);
264
double get_total_area(flp_t *flp);
265
double get_core_area(flp_t *flp, char *l2_label);
266
double get_core_occupied_area(flp_t *flp, char *l2_label);
267
double get_wire_metric(flp_t *flp);
268
269
#endif
270
271