#ifndef __FLP_H_1#define __FLP_H_23#include "util.h"45#define MAX_UNITS 81926#define MAX_MOVES 1678/* types of cuts */9#define CUT_NONE -110#define CUT_VERTICAL -211#define CUT_HORIZONTAL -31213/* wrap around L2 with extra arms */14#define L2_LEFT 015#define L2_RIGHT 116#define L2_ARMS 217#define L2_LEFT_STR "_left"18#define L2_RIGHT_STR "_right"19/* L2 sizing ratio of arm width to base height */20#define WRAP_L2_RATIO 52122/*23* chip edge has true dead space, which is24* modeled by the following blocks25*/26#define RIM_LEFT 127#define RIM_RIGHT 228#define RIM_TOP 429#define RIM_BOTTOM 830#define RIM_PREFIX "RIM"31#define RIM_LEFT_STR RIM_PREFIX"_left"32#define RIM_RIGHT_STR RIM_PREFIX"_right"33#define RIM_TOP_STR RIM_PREFIX"_top"34#define RIM_BOTTOM_STR RIM_PREFIX"_bottom"3536/* prefix denoting dead block */37#define DEAD_PREFIX "_"3839/* flags denoting orientation */40/* rotated orientations */41#define ROT_0 0x01 /* normal */42#define ROT_90 0x02 /* 90 degrees anticlockwise */43#define ROT_180 0x04 /* 180 degrees anticlockwise */44#define ROT_270 0x08 /* 270 degrees anticlockwise */45/* flipped + rotated orientations */46#define FLIP_0 0x10 /* flip about y axis of ROT_0 */47#define FLIP_90 0x20 /* flip about y axis of ROT_90 */48#define FLIP_180 0x40 /* flip about y axis of ROT_180 */49#define FLIP_270 0x80 /* flip about y axis of ROT_270 */50#define ORIENTS_N 8 /* total no. of orientations */51#define ORIENT_NDEF 0xDF /* undefined orientation */5253/* type for holding the above flags */54typedef unsigned char orient_t;5556/* forward declarations */57struct RC_model_t_st; /* see temperature.h */58struct shape_t_st; /* see shape.h */5960/* configuration parameters for the floorplan */61typedef struct flp_config_t_st62{63/* wrap around L2? */64int wrap_l2;65/* name of L2 to look for */66char l2_label[STR_SIZE];6768/* model dead space around the rim of the chip? */69int model_rim;70double rim_thickness;7172/* area ratio below which to ignore dead space */73double compact_ratio;7475/*76* no. of discrete orientations for a shape curve.77* should be an even number greater than 178*/79int n_orients;8081/* annealing parameters */82double P0; /* initial acceptance probability */83double Davg; /* average change (delta) in cost */84double Kmoves; /* no. of moves to try in each step */85double Rcool; /* ratio for the cooling schedule */86double Rreject; /* ratio of rejects at which to stop annealing */87int Nmax; /* absolute max no. of annealing steps */8889/* weights for the metric: lambdaA * A + lambdaT * T + lambdaW * W */90double lambdaA;91double lambdaT;92double lambdaW;93} flp_config_t;9495/* unplaced unit */96typedef struct unplaced_t_st97{98char name[STR_SIZE];99/* can be rotated? */100int rotable;101double area;102/* minimum and maximum aspect ratios */103double min_aspect;104double max_aspect;105/* shape curve for this unit */106struct shape_t_st *shape;107}unplaced_t;108109/* input description for floorplanning */110typedef struct flp_desc_t_st111{112unplaced_t *units;113/* density of wires between units */114double **wire_density;115/* configuration parameters */116flp_config_t config;117int n_units;118}flp_desc_t;119120/* placed functional unit */121typedef struct unit_t_st122{123char name[STR_SIZE];124double width;125double height;126double leftx;127double bottomy;128//BU_3D: new parameters for each functional unit. Allows for specific R-C values at a block-level.129double specificheat;130double resistivity;131int hasRes;132int hasSh;133//end->BU_3D134}unit_t;135136/* floorplan data structure */137typedef struct flp_t_st138{139unit_t *units;140int n_units;141/* density of wires between units */142double **wire_density;143} flp_t;144145/* flp_config routines */146147/* default flp_config */148flp_config_t default_flp_config(void);149/*150* parse a table of name-value string pairs and add the configuration151* parameters to 'config'152*/153void flp_config_add_from_strs(flp_config_t *config, str_pair *table, int size);154/*155* convert config into a table of name-value pairs. returns the no.156* of parameters converted157*/158int flp_config_to_strs(flp_config_t *config, str_pair *table, int max_entries);159160/* flp_desc routines */161162/* read floorplan description and allocate memory */163flp_desc_t *read_flp_desc(char *file, flp_config_t *config);164void free_flp_desc(flp_desc_t *flp_desc);165/* debug print */166void print_unplaced(unplaced_t *unit);167void print_flp_desc(flp_desc_t *flp_desc);168169/* flp routines */170171/* create a floorplan placeholder from description */172flp_t *flp_placeholder(flp_desc_t *flp_desc);173/* skip floorplanning and read floorplan directly from file */174flp_t *read_flp(char *file, int read_connects, int initialize_connects);175/*176* main flooplanning routine - allocates177* memory internally. returns the number178* of compacted blocks179*/180int floorplan(flp_t *flp, flp_desc_t *flp_desc,181struct RC_model_t_st *model, double *power);182/*183* print the floorplan in a FIG like format184* that can be read by tofig.pl to produce185* an xfig output186*/187void print_flp_fig (flp_t *flp);188/* debug print */189void print_flp (flp_t *flp, int print_connects);190/* print the statistics about this floorplan */191void print_flp_stats(flp_t *flp, struct RC_model_t_st *model,192char *l2_label, char *power_file,193char *connects_file);194/* wrap the L2 around this floorplan */195void flp_wrap_l2(flp_t *flp, flp_desc_t *flp_desc);196/* wrap the rim blocks around - returns the no. of blocks */197int flp_wrap_rim(flp_t *flp, double rim_thickness);198/* translate the floorplan to new origin (x,y) */199void flp_translate(flp_t *flp, double x, double y);200/* scale the floorplan by a factor 'factor' */201void flp_scale(flp_t *flp, double factor);202/*203* change the orientation of the floorplan by204* rotating and/or flipping. the target orientation205* is specified in 'target'. 'width', 'height', 'xorig'206* and 'yorig' are those of 'flp' respectively.207*/208void flp_change_orient(flp_t *flp, double xorig, double yorig,209double width, double height, orient_t target);210211/*212* create a non-uniform grid-like floorplan equivalent to this.213* this function is mainly useful when using the HotSpot block214* model to model floorplans of drastically differing aspect215* ratios and granularity. an example for such a floorplan216* would be the standard ev6 floorplan that comes with HotSpot,217* where the register file is subdivided into say 128 entries.218* the HotSpot block model could result in inaccuracies while219* trying to model such floorplans of differing granularity.220* if such inaccuracies occur, use this function to create an221* equivalent floorplan that can be modeled accurately in222* HotSpot. 'map' is an output parameter to store the 2-d array223* allocated by the function.224*/225flp_t *flp_create_grid(flp_t *flp, int ***map);226/* free the map allocated by flp_create_grid */227void free_blkgrid_map(flp_t *flp, int **map);228/* translate power numbers to the grid created by flp_create_grid */229void xlate_power_blkgrid(flp_t *flp, flp_t *grid, \230double *bpower, double *gpower, int **map);231/* the metric used to evaluate the floorplan */232double flp_evaluate_metric(flp_t *flp, struct RC_model_t_st *model, double *power,233double lambdaA, double lambdaT, double lambdaW);234/* dump the floorplan onto a file */235void dump_flp(flp_t *flp, char *file, int dump_connects);236/* memory uninitialization */237void free_flp(flp_t *flp, int compacted, int free_connects);238239240/* placed floorplan access routines */241242/* get unit index from its name */243int get_blk_index(flp_t *flp, char *name);244/* are the units horizontally adjacent? */245int is_horiz_adj(flp_t *flp, int i, int j);246/* are the units vertically adjacent? */247int is_vert_adj (flp_t *flp, int i, int j);248/* shared length between units */249double get_shared_len(flp_t *flp, int i, int j);250/* total chip width */251double get_total_width(flp_t *flp);252/* total chip height */253double get_total_height(flp_t *flp);254/* x and y origins */255double get_minx(flp_t *flp);256double get_miny(flp_t *flp);257/* precondition: L2 should have been wrapped around */258double get_core_width(flp_t *flp, char *l2_label);259/* precondition: L2 should have been wrapped around */260double get_core_height(flp_t *flp, char *l2_label);261/* other queries */262double get_manhattan_dist(flp_t *flp, int i, int j);263double get_total_area(flp_t *flp);264double get_core_area(flp_t *flp, char *l2_label);265double get_core_occupied_area(flp_t *flp, char *l2_label);266double get_wire_metric(flp_t *flp);267268#endif269270271