|
48 | 48 | #include "route_common.h"
|
49 | 49 | #include "breakpoint.h"
|
50 | 50 |
|
51 |
| -#ifdef VTR_ENABLE_DEBUG_LOGGING |
52 |
| -# include "move_utils.h" |
53 |
| -#endif |
| 51 | +#include "move_utils.h" |
54 | 52 |
|
55 | 53 | #ifdef WIN32 /* For runtime tracking in WIN32. The clock() function defined in time.h will *
|
56 | 54 | * track CPU runtime. */
|
|
78 | 76 | /****************************** Define Macros *******************************/
|
79 | 77 |
|
80 | 78 | # define DEFAULT_RR_NODE_COLOR ezgl::BLACK
|
| 79 | +# define OLD_BLK_LOC_COLOR blk_GOLD |
| 80 | +# define NEW_BLK_LOC_COLOR blk_GREEN |
81 | 81 | //#define TIME_DRAWSCREEN /* Enable if want to track runtime for drawscreen() */
|
82 | 82 |
|
83 | 83 | /********************** Subroutines local to this module ********************/
|
@@ -993,56 +993,33 @@ static void drawplace(ezgl::renderer* g) {
|
993 | 993 | /* Fill background for the clb. Do not fill if "show_blk_internal"
|
994 | 994 | * is toggled.
|
995 | 995 | */
|
996 |
| - if (bnum == INVALID_BLOCK_ID) continue; |
997 |
| - //Determine the block color |
| 996 | + if (bnum == INVALID_BLOCK_ID) |
| 997 | + continue; |
| 998 | + |
| 999 | + //Determine the block color and logical type |
998 | 1000 | ezgl::color block_color;
|
999 | 1001 | t_logical_block_type_ptr logical_block_type = nullptr;
|
1000 |
| -# ifdef VTR_ENABLE_DEBUG_LOGGING |
1001 |
| - if (f_placer_debug) { |
1002 |
| - t_pl_loc curr_loc; |
1003 |
| - curr_loc.x = i; |
1004 |
| - curr_loc.y = j; |
1005 |
| - auto it = std::find_if(draw_state->colored_blocks.begin(), draw_state->colored_blocks.end(), [&curr_loc](const std::pair<t_pl_loc, ezgl::color>& a) { return (a.first.x == curr_loc.x && a.first.y == curr_loc.y); }); |
1006 |
| - if (it != draw_state->colored_blocks.end()) { |
1007 |
| - block_color = it->second; |
1008 |
| - auto tile_type = device_ctx.grid[i][j].type; |
1009 |
| - logical_block_type = pick_best_logical_type(tile_type); |
1010 |
| - } else { |
1011 |
| - if (bnum != EMPTY_BLOCK_ID) { |
1012 |
| - block_color = draw_state->block_color(bnum); |
1013 |
| - logical_block_type = cluster_ctx.clb_nlist.block_type(bnum); |
1014 |
| - } else { |
1015 |
| - block_color = get_block_type_color(device_ctx.grid[i][j].type); |
1016 |
| - block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR); |
1017 | 1002 |
|
1018 |
| - auto tile_type = device_ctx.grid[i][j].type; |
1019 |
| - logical_block_type = pick_best_logical_type(tile_type); |
1020 |
| - } |
1021 |
| - } |
1022 |
| - } else { |
| 1003 | + //flag whether the current location is highlighted with a special color or not |
| 1004 | + bool current_loc_is_highlighted = false; |
| 1005 | + |
| 1006 | + if (placer_breakpoint_reached()) |
| 1007 | + current_loc_is_highlighted = highlight_loc_with_specific_color(int(i), int(j), block_color); |
| 1008 | + |
| 1009 | + // No color specified at this location; use the block color. |
| 1010 | + if (current_loc_is_highlighted == false) { |
1023 | 1011 | if (bnum != EMPTY_BLOCK_ID) {
|
1024 | 1012 | block_color = draw_state->block_color(bnum);
|
1025 | 1013 | logical_block_type = cluster_ctx.clb_nlist.block_type(bnum);
|
1026 | 1014 | } else {
|
1027 | 1015 | block_color = get_block_type_color(device_ctx.grid[i][j].type);
|
1028 | 1016 | block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR);
|
1029 |
| - |
1030 |
| - auto tile_type = device_ctx.grid[i][j].type; |
1031 |
| - logical_block_type = pick_best_logical_type(tile_type); |
1032 | 1017 | }
|
1033 | 1018 | }
|
1034 |
| -# else |
1035 |
| - if (bnum != EMPTY_BLOCK_ID) { |
1036 |
| - block_color = draw_state->block_color(bnum); |
1037 |
| - logical_block_type = cluster_ctx.clb_nlist.block_type(bnum); |
1038 |
| - } else { |
1039 |
| - block_color = get_block_type_color(device_ctx.grid[i][j].type); |
1040 |
| - block_color = lighten_color(block_color, EMPTY_BLOCK_LIGHTEN_FACTOR); |
1041 | 1019 |
|
1042 |
| - auto tile_type = device_ctx.grid[i][j].type; |
1043 |
| - logical_block_type = pick_best_logical_type(tile_type); |
1044 |
| - } |
1045 |
| -# endif |
| 1020 | + auto tile_type = device_ctx.grid[i][j].type; |
| 1021 | + logical_block_type = pick_best_logical_type(tile_type); |
| 1022 | + |
1046 | 1023 | g->set_color(block_color);
|
1047 | 1024 | /* Get coords of current sub_tile */
|
1048 | 1025 | ezgl::rectangle abs_clb_bbox = draw_coords->get_absolute_clb_bbox(i, j, k, logical_block_type);
|
@@ -4157,4 +4134,61 @@ static void run_graphics_commands(std::string commands) {
|
4157 | 4134 | ++draw_state->sequence_number;
|
4158 | 4135 | }
|
4159 | 4136 |
|
| 4137 | +/* This routine highlights the blocks affected in the latest move * |
| 4138 | + * It highlights the old and new locations of the moved blocks * |
| 4139 | + * It also highlights the moved block input and output terminals * |
| 4140 | + * Currently, it is used in placer debugger when breakpoint is reached */ |
| 4141 | +void highlight_moved_block_and_its_terminals(const t_pl_blocks_to_be_moved& blocks_affected) { |
| 4142 | + auto& cluster_ctx = g_vpr_ctx.clustering(); |
| 4143 | + |
| 4144 | + //clear all selected blocks |
| 4145 | + deselect_all(); |
| 4146 | + |
| 4147 | + //highlight the input/output terminals of the moved block |
| 4148 | + draw_highlight_blocks_color(cluster_ctx.clb_nlist.block_type(blocks_affected.moved_blocks[0].block_num), blocks_affected.moved_blocks[0].block_num); |
| 4149 | + |
| 4150 | + //highlight the old and new locations of the moved block |
| 4151 | + clear_colored_locations(); |
| 4152 | + set_draw_loc_color(blocks_affected.moved_blocks[0].old_loc, OLD_BLK_LOC_COLOR); |
| 4153 | + set_draw_loc_color(blocks_affected.moved_blocks[0].old_loc, NEW_BLK_LOC_COLOR); |
| 4154 | +} |
| 4155 | + |
| 4156 | +// pass in an (x,y,subtile) location and the color in which it should be drawn. |
| 4157 | +// This overrides the color of any block placed in that location, and also applies if the location is empty. |
| 4158 | +void set_draw_loc_color(t_pl_loc loc, ezgl::color clr) { |
| 4159 | + t_draw_state* draw_state = get_draw_state_vars(); |
| 4160 | + draw_state->colored_locations.push_back(std::make_pair(loc, clr)); |
| 4161 | +} |
| 4162 | + |
| 4163 | +// clear the colored_locations vector |
| 4164 | +void clear_colored_locations() { |
| 4165 | + t_draw_state* draw_state = get_draw_state_vars(); |
| 4166 | + draw_state->colored_locations.clear(); |
| 4167 | +} |
| 4168 | + |
| 4169 | +// This routine takes in a (x,y) location. |
| 4170 | +// If the input loc is marked in colored_locations vector, the function will return true and the correspnding color is sent back in loc_color |
| 4171 | +// otherwise, the function returns false (the location isn't among the highlighted locations) |
| 4172 | +bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color) { |
| 4173 | + t_draw_state* draw_state = get_draw_state_vars(); |
| 4174 | + |
| 4175 | + //define a (x,y) location variable |
| 4176 | + t_pl_loc curr_loc; |
| 4177 | + curr_loc.x = x; |
| 4178 | + curr_loc.y = y; |
| 4179 | + |
| 4180 | + //search for the current location in the vector of colored locations |
| 4181 | + auto it = std::find_if(draw_state->colored_locations.begin(), draw_state->colored_locations.end(), [&curr_loc](const std::pair<t_pl_loc, ezgl::color>& vec_element) { return (vec_element.first.x == curr_loc.x && vec_element.first.y == curr_loc.y); }); |
| 4182 | + |
| 4183 | + if (it != draw_state->colored_locations.end()) { |
| 4184 | + /* found a colored location at the spot I am drawing * |
| 4185 | + * (currently used for drawing the current move). * |
| 4186 | + * This overrides any block color. */ |
| 4187 | + loc_color = it->second; |
| 4188 | + return true; |
| 4189 | + } |
| 4190 | + |
| 4191 | + return false; |
| 4192 | +} |
| 4193 | + |
4160 | 4194 | #endif /* NO_GRAPHICS */
|
0 commit comments