Skip to content

Commit 1478410

Browse files
authored
Merge pull request #1522 from verilog-to-routing/place_debug_refactor
Refactor the placer debug code
2 parents 7b87c11 + fb6cda3 commit 1478410

File tree

13 files changed

+416
-132
lines changed

13 files changed

+416
-132
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ jobs:
113113
script:
114114
- ./.github/travis/build.sh
115115
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
116+
- stage: Test
117+
name: "Basic Regression Tests with NO_GRAPHICS"
118+
env:
119+
- CMAKE_PARAMS="-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVPR_USE_EZGL=off"
120+
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
121+
script:
122+
- ./.github/travis/build.sh
123+
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
124+
- stage: Test
125+
name: "Basic Regression Tests with VTR_ENABLE_DEBUG_LOGGING"
126+
env:
127+
- CMAKE_PARAMS="-DVTR_ASSERT_LEVEL=3 -DWITH_BLIFEXPLORER=on -DVTR_ENABLE_DEBUG_LOGGING=on"
128+
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
129+
script:
130+
- ./.github/travis/build.sh
131+
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -j2
116132
- stage: Test
117133
name: "Strong Regression Tests"
118134
env:

vpr/src/draw/breakpoint.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <iostream>
55

6+
#ifndef NO_GRAPHICS
67
//if the user adds a "proceed move" breakpoint using the entry field in the UI, this function converts it to the equivalent expression and calls the expression evaluator. Returns true if a breakpoint is encountered
78
//the way the proceed moves breakpoint works is that it proceeds the indicated number of moves from where the placer currently is i.e if at move 3 and proceed 4 ends up at move 7
89
bool check_for_moves_breakpoints(int moves_to_proceed) {
@@ -92,3 +93,4 @@ void print_current_info(bool in_placer) {
9293
else
9394
std::cout << "\nrouter_iter: " << get_bp_state_globals()->get_glob_breakpoint_state()->router_iter << "\nnet_id: " << get_bp_state_globals()->get_glob_breakpoint_state()->route_net_id << "\n----------------------------\n";
9495
}
96+
#endif

vpr/src/draw/draw.cpp

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
#include "route_common.h"
4949
#include "breakpoint.h"
5050

51-
#ifdef VTR_ENABLE_DEBUG_LOGGING
52-
# include "move_utils.h"
53-
#endif
51+
#include "move_utils.h"
5452

5553
#ifdef WIN32 /* For runtime tracking in WIN32. The clock() function defined in time.h will *
5654
* track CPU runtime. */
@@ -78,6 +76,8 @@
7876
/****************************** Define Macros *******************************/
7977

8078
# define DEFAULT_RR_NODE_COLOR ezgl::BLACK
79+
# define OLD_BLK_LOC_COLOR blk_GOLD
80+
# define NEW_BLK_LOC_COLOR blk_GREEN
8181
//#define TIME_DRAWSCREEN /* Enable if want to track runtime for drawscreen() */
8282

8383
/********************** Subroutines local to this module ********************/
@@ -993,56 +993,33 @@ static void drawplace(ezgl::renderer* g) {
993993
/* Fill background for the clb. Do not fill if "show_blk_internal"
994994
* is toggled.
995995
*/
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
9981000
ezgl::color block_color;
9991001
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);
10171002

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) {
10231011
if (bnum != EMPTY_BLOCK_ID) {
10241012
block_color = draw_state->block_color(bnum);
10251013
logical_block_type = cluster_ctx.clb_nlist.block_type(bnum);
10261014
} else {
10271015
block_color = get_block_type_color(device_ctx.grid[i][j].type);
10281016
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);
10321017
}
10331018
}
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);
10411019

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+
10461023
g->set_color(block_color);
10471024
/* Get coords of current sub_tile */
10481025
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) {
41574134
++draw_state->sequence_number;
41584135
}
41594136

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+
41604194
#endif /* NO_GRAPHICS */

vpr/src/draw/draw.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ float get_net_alpha();
8484

8585
ezgl::color get_block_type_color(t_physical_tile_type_ptr type);
8686

87+
/* This routine highlights the blocks affected in the latest move *
88+
* It highlights the old and new locations of the moved blocks *
89+
* It also highlights the moved block input and output terminals *
90+
* Currently, it is used in placer debugger when breakpoint is reached */
91+
void highlight_moved_block_and_its_terminals(const t_pl_blocks_to_be_moved&);
92+
93+
// pass in an (x,y,subtile) location and the color in which it should be drawn.
94+
// This overrides the color of any block placed in that location, and also applies if the location is empty.
95+
void set_draw_loc_color(t_pl_loc, ezgl::color);
96+
97+
// clear the colored_locations vector
98+
void clear_colored_locations();
99+
100+
// This routine takes in a (x,y) location.
101+
// 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
102+
// otherwise, the function returns false (the location isn't among the highlighted locations)
103+
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color);
104+
87105
#endif /* NO_GRAPHICS */
88106

89107
#endif /* DRAW_H */

0 commit comments

Comments
 (0)