• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/techModels/libHotSpot/flp.h

00001 #ifndef __FLP_H_
00002 #define __FLP_H_
00003 
00004 #include "util.h"
00005 
00006 #define MAX_UNITS               8192
00007 #define MAX_MOVES               16
00008 
00009 /* types of cuts        */
00010 #define CUT_NONE                -1
00011 #define CUT_VERTICAL    -2
00012 #define CUT_HORIZONTAL  -3
00013 
00014 /* wrap around L2 with extra arms       */
00015 #define L2_LEFT                 0
00016 #define L2_RIGHT                1
00017 #define L2_ARMS                 2
00018 #define L2_LEFT_STR             "_left"
00019 #define L2_RIGHT_STR    "_right"
00020 /* L2 sizing ratio of arm width to base height  */
00021 #define WRAP_L2_RATIO   5
00022 
00023 /* 
00024  * chip edge has true dead space, which is 
00025  * modeled by the following blocks
00026  */
00027 #define RIM_LEFT                1
00028 #define RIM_RIGHT               2
00029 #define RIM_TOP                 4
00030 #define RIM_BOTTOM              8
00031 #define RIM_PREFIX              "RIM"
00032 #define RIM_LEFT_STR    RIM_PREFIX"_left"
00033 #define RIM_RIGHT_STR   RIM_PREFIX"_right"
00034 #define RIM_TOP_STR             RIM_PREFIX"_top"
00035 #define RIM_BOTTOM_STR  RIM_PREFIX"_bottom"
00036 
00037 /* prefix denoting dead block   */
00038 #define DEAD_PREFIX             "_"
00039 
00040 /* flags denoting orientation   */
00041 /* rotated orientations */
00042 #define ROT_0           0x01    /* normal       */
00043 #define ROT_90          0x02    /* 90 degrees anticlockwise */
00044 #define ROT_180         0x04    /* 180 degrees anticlockwise */
00045 #define ROT_270         0x08    /* 270 degrees anticlockwise */
00046 /* flipped + rotated orientations       */
00047 #define FLIP_0          0x10    /* flip about y axis of ROT_0   */
00048 #define FLIP_90         0x20    /* flip about y axis of ROT_90  */
00049 #define FLIP_180        0x40    /* flip about y axis of ROT_180 */
00050 #define FLIP_270        0x80    /* flip about y axis of ROT_270 */
00051 #define ORIENTS_N       8               /* total no. of orientations    */
00052 #define ORIENT_NDEF     0xDF    /* undefined orientation        */
00053 
00054 /* type for holding the above flags     */
00055 typedef unsigned char orient_t;
00056 
00057 /* forward declarations */
00058 struct RC_model_t_st;   /* see temperature.h    */
00059 struct shape_t_st;              /* see shape.h  */
00060 
00061 /* configuration parameters for the floorplan   */
00062 typedef struct flp_config_t_st
00063 {
00064         /* wrap around L2?      */
00065         int wrap_l2;
00066         /* name of L2 to look for       */
00067         char l2_label[STR_SIZE];
00068 
00069         /* model dead space around the rim of the chip? */
00070         int model_rim;
00071         double rim_thickness;
00072 
00073         /* area ratio below which to ignore dead space  */
00074         double compact_ratio;
00075 
00076         /* 
00077          * no. of discrete orientations for a shape curve.
00078          * should be an even number greater than 1
00079          */
00080         int n_orients;
00081         
00082         /* annealing parameters */
00083         double P0;              /* initial acceptance probability       */
00084         double Davg;    /* average change (delta) in cost       */
00085         double Kmoves;          /* no. of moves to try in each step     */
00086         double Rcool;   /* ratio for the cooling schedule */
00087         double Rreject; /* ratio of rejects at which to stop annealing */
00088         int Nmax;               /* absolute max no. of annealing steps  */
00089 
00090         /* weights for the metric: lambdaA * A + lambdaT * T + lambdaW * W      */
00091         double lambdaA;
00092         double lambdaT;
00093         double lambdaW;
00094 } flp_config_t;
00095 
00096 /* unplaced unit        */
00097 typedef struct unplaced_t_st
00098 {
00099   char name[STR_SIZE];
00100   /* can be rotated?    */
00101   int rotable;
00102   double area;
00103   /* minimum and maximum aspect ratios  */
00104   double min_aspect;
00105   double max_aspect;
00106   /* shape curve for this unit  */
00107   struct shape_t_st *shape;
00108 }unplaced_t;
00109 
00110 /* input description for floorplanning  */
00111 typedef struct flp_desc_t_st
00112 {
00113   unplaced_t *units;
00114   /* density of wires between units     */
00115   double **wire_density;
00116   /* configuration parameters   */
00117   flp_config_t config;
00118   int n_units;
00119 }flp_desc_t;
00120 
00121 /* placed functional unit */
00122 typedef struct unit_t_st
00123 {
00124         char name[STR_SIZE];
00125         double width;
00126         double height;
00127         double leftx;
00128         double bottomy;
00129         /* ----- SoM ----- */
00130         int id;
00131         /* ----- EoM ----- */
00132 }unit_t;
00133 
00134 /* floorplan data structure     */
00135 typedef struct flp_t_st
00136 {
00137         unit_t *units;
00138         int n_units;
00139         /* density of wires between units       */
00140         double **wire_density;
00141 } flp_t;
00142 
00143 /* flp_config routines  */
00144 
00145 /* default flp_config   */
00146 flp_config_t default_flp_config(void);
00147 /* 
00148  * parse a table of name-value string pairs and add the configuration
00149  * parameters to 'config'
00150  */
00151 void flp_config_add_from_strs(flp_config_t *config, str_pair *table, int size);
00152 /* 
00153  * convert config into a table of name-value pairs. returns the no.
00154  * of parameters converted
00155  */
00156 int flp_config_to_strs(flp_config_t *config, str_pair *table, int max_entries);
00157 
00158 /* flp_desc routines    */
00159 
00160 /* read floorplan description and allocate memory       */
00161 flp_desc_t *read_flp_desc(char *file, flp_config_t *config);
00162 void free_flp_desc(flp_desc_t *flp_desc);
00163 /* debug print  */
00164 void print_unplaced(unplaced_t *unit);
00165 void print_flp_desc(flp_desc_t *flp_desc);
00166 
00167 /* flp routines */
00168 
00169 /* create a floorplan placeholder from description      */
00170 flp_t *flp_placeholder(flp_desc_t *flp_desc);
00171 /* skip floorplanning and read floorplan directly from file */
00172 flp_t *read_flp(char *file, int read_connects);
00173 /* 
00174  * main flooplanning routine - allocates 
00175  * memory internally. returns the number
00176  * of compacted blocks
00177  */ 
00178 int floorplan(flp_t *flp, flp_desc_t *flp_desc,
00179                           struct RC_model_t_st *model, double *power);
00180 /* 
00181  * print the floorplan in a FIG like format 
00182  * that can be read by tofig.pl to produce 
00183  * an xfig output 
00184  */
00185 flp_t *flp_alloc_init_mem(int count);
00186 
00187 void print_flp_fig2();
00188 void print_flp_fig (flp_t *flp);
00189 /* debug print  */
00190 void print_flp (flp_t *flp);
00191 /* print the statistics about this floorplan    */
00192 void print_flp_stats(flp_t *flp, struct RC_model_t_st *model,
00193                                          char *l2_label, char *power_file, 
00194                                          char *connects_file);
00195 /* wrap the L2 around this floorplan    */                         
00196 void flp_wrap_l2(flp_t *flp, flp_desc_t *flp_desc);
00197 /* wrap the rim blocks around - returns the no. of blocks       */
00198 int flp_wrap_rim(flp_t *flp, double rim_thickness);
00199 /* translate the floorplan to new origin (x,y)  */
00200 void flp_translate(flp_t *flp, double x, double y);
00201 /* scale the floorplan by a factor 'factor'     */
00202 void flp_scale(flp_t *flp, double factor);
00203 /* 
00204  * change the orientation of the floorplan by
00205  * rotating and/or flipping. the target orientation
00206  * is specified in 'target'. 'width', 'height', 'xorig'
00207  * and 'yorig' are those of 'flp' respectively.
00208  */
00209 void flp_change_orient(flp_t *flp, double xorig, double yorig,
00210                                            double width, double height, orient_t target);
00211 
00212 /* 
00213  * create a non-uniform grid-like floorplan equivalent to this.
00214  * this function is mainly useful when using the HotSpot block
00215  * model to model floorplans of drastically differing aspect
00216  * ratios and granularity. an example for such a floorplan
00217  * would be the standard ev6 floorplan that comes with HotSpot,
00218  * where the register file is subdivided into say 128 entries.
00219  * the HotSpot block model could result in inaccuracies while
00220  * trying to model such floorplans of differing granularity.
00221  * if such inaccuracies occur, use this function to create an 
00222  * equivalent floorplan that can be modeled accurately in 
00223  * HotSpot. 'map' is an output parameter to store the 2-d array 
00224  * allocated by the function.
00225  */
00226 flp_t *flp_create_grid(flp_t *flp, int ***map);
00227 /* free the map allocated by flp_create_grid    */
00228 void free_blkgrid_map(flp_t *flp, int **map);
00229 /* translate power numbers to the grid created by flp_create_grid       */
00230 void xlate_power_blkgrid(flp_t *flp, flp_t *grid, \
00231                                                  double *bpower, double *gpower, int **map);
00232 /* the metric used to evaluate the floorplan    */
00233 double flp_evaluate_metric(flp_t *flp, struct RC_model_t_st *model, double *power, 
00234                                                    double lambdaA, double lambdaT, double lambdaW);
00235 /* dump the floorplan onto a file       */
00236 void dump_flp(flp_t *flp, char *file, int dump_connects);
00237 /* memory uninitialization      */
00238 void free_flp(flp_t *flp, int compacted);
00239 
00240 
00241 /* placed floorplan access routines     */
00242 
00243 /* get unit index from its name */
00244 int get_blk_index(flp_t *flp, char *name);
00245 /* are the units horizontally adjacent? */
00246 int is_horiz_adj(flp_t *flp, int i, int j);
00247 /* are the units vertically adjacent?   */
00248 int is_vert_adj (flp_t *flp, int i, int j);
00249 /* shared length between units  */
00250 double get_shared_len(flp_t *flp, int i, int j);
00251 /* total chip width     */
00252 double get_total_width(flp_t *flp);
00253 /* total chip height */
00254 double get_total_height(flp_t *flp);
00255 /* x and y origins      */
00256 double get_minx(flp_t *flp);
00257 double get_miny(flp_t *flp);
00258 /* precondition: L2 should have been wrapped around     */
00259 double get_core_width(flp_t *flp, char *l2_label);
00260 /* precondition: L2 should have been wrapped around     */
00261 double get_core_height(flp_t *flp, char *l2_label);
00262 /* other queries        */
00263 double get_manhattan_dist(flp_t *flp, int i, int j);
00264 double get_total_area(flp_t *flp);
00265 double get_core_area(flp_t *flp, char *l2_label);
00266 double get_core_occupied_area(flp_t *flp, char *l2_label);
00267 double get_wire_metric(flp_t *flp);
00268 
00269 #endif

Generated on Fri Oct 22 2010 11:02:14 for SST by  doxygen 1.7.1