Skip to content

Commit aebcaad

Browse files
committed
Merge branch 'noc_mvm_designs' of https://github.com/verilog-to-routing/vtr-verilog-to-routing into noc_mvm_designs
2 parents 87fd634 + 99f0564 commit aebcaad

16 files changed

+1268
-541
lines changed

vpr/main.ui

Lines changed: 424 additions & 158 deletions
Large diffs are not rendered by default.

vpr/src/draw/draw.cpp

Lines changed: 96 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static void default_setup(ezgl::application* app) {
292292
net_button_setup(app);
293293
block_button_setup(app);
294294
search_setup(app);
295+
view_button_setup(app);
295296
}
296297

297298
// Initial Setup functions run default setup if they are a new window. Then, they will run
@@ -526,6 +527,10 @@ void alloc_draw_structs(const t_arch* arch) {
526527
* not yet know information about the routing resources. */
527528
draw_state->draw_rr_node.resize(device_ctx.rr_graph.num_nodes());
528529

530+
draw_state->draw_layer_display.resize(device_ctx.grid.get_num_layers());
531+
//By default show the lowest layer only. This is the only die layer for 2D FPGAs
532+
draw_state->draw_layer_display[0].visible = true;
533+
529534
draw_state->arch_info = arch;
530535

531536
deselect_all(); /* Set initial colors */
@@ -990,83 +995,83 @@ static void highlight_blocks(double x, double y) {
990995
/// determine block ///
991996
ezgl::rectangle clb_bbox;
992997

993-
//TODO: Change when graphics supports 3D FPGAs
994-
VTR_ASSERT(device_ctx.grid.get_num_layers() == 1);
995-
int layer_num = 0;
996-
// iterate over grid x
997-
for (int i = 0; i < (int)device_ctx.grid.width(); ++i) {
998-
if (draw_coords->tile_x[i] > x) {
999-
break; // we've gone to far in the x direction
1000-
}
1001-
// iterate over grid y
1002-
for (int j = 0; j < (int)device_ctx.grid.height(); ++j) {
1003-
if (draw_coords->tile_y[j] > y) {
1004-
break; // we've gone to far in the y direction
998+
//iterate over grid z (layers) first, so we draw from bottom to top die. This makes partial transparency of layers draw properly.
999+
for (int layer_num = 0; layer_num < device_ctx.grid.get_num_layers(); layer_num++) {
1000+
// iterate over grid x
1001+
for (int i = 0; i < (int)device_ctx.grid.width(); ++i) {
1002+
if (draw_coords->tile_x[i] > x) {
1003+
break; // we've gone too far in the x direction
10051004
}
1006-
// iterate over sub_blocks
1007-
const auto& type = device_ctx.grid.get_physical_type({i, j, layer_num});
1008-
for (int k = 0; k < type->capacity; ++k) {
1009-
// TODO: Change when graphics supports 3D
1010-
clb_index = place_ctx.grid_blocks.block_at_location({i, j, k, layer_num});
1011-
if (clb_index != EMPTY_BLOCK_ID) {
1012-
clb_bbox = draw_coords->get_absolute_clb_bbox(clb_index,
1013-
cluster_ctx.clb_nlist.block_type(clb_index));
1014-
if (clb_bbox.contains({x, y})) {
1015-
break;
1016-
} else {
1017-
clb_index = EMPTY_BLOCK_ID;
1005+
// iterate over grid y
1006+
for (int j = 0; j < (int)device_ctx.grid.height(); ++j) {
1007+
if (draw_coords->tile_y[j] > y) {
1008+
break; // we've gone too far in the y direction
1009+
}
1010+
// iterate over sub_blocks
1011+
const auto& type = device_ctx.grid.get_physical_type({i, j, layer_num});
1012+
for (int k = 0; k < type->capacity; ++k) {
1013+
clb_index = place_ctx.grid_blocks.block_at_location({i, j, k, layer_num});
1014+
if (clb_index != EMPTY_BLOCK_ID) {
1015+
clb_bbox = draw_coords->get_absolute_clb_bbox(clb_index,
1016+
cluster_ctx.clb_nlist.block_type(clb_index));
1017+
if (clb_bbox.contains({x, y})) {
1018+
break;
1019+
} else {
1020+
clb_index = EMPTY_BLOCK_ID;
1021+
}
10181022
}
10191023
}
1024+
if (clb_index != EMPTY_BLOCK_ID) {
1025+
break; // we've found something
1026+
}
10201027
}
10211028
if (clb_index != EMPTY_BLOCK_ID) {
10221029
break; // we've found something
10231030
}
10241031
}
1025-
if (clb_index != EMPTY_BLOCK_ID) {
1026-
break; // we've found something
1027-
}
1028-
}
10291032

1030-
if (clb_index == EMPTY_BLOCK_ID || clb_index == ClusterBlockId::INVALID()) {
1031-
//Nothing found
1032-
return;
1033-
}
1033+
if (clb_index == EMPTY_BLOCK_ID || clb_index == ClusterBlockId::INVALID()) {
1034+
//Nothing found
1035+
return;
1036+
}
10341037

1035-
VTR_ASSERT(clb_index != EMPTY_BLOCK_ID);
1038+
VTR_ASSERT(clb_index != EMPTY_BLOCK_ID);
10361039

1037-
// note: this will clear the selected sub-block if show_blk_internal is 0,
1038-
// or if it doesn't find anything
1039-
ezgl::point2d point_in_clb = ezgl::point2d(x, y) - clb_bbox.bottom_left();
1040-
highlight_sub_block(point_in_clb, clb_index,
1041-
cluster_ctx.clb_nlist.block_pb(clb_index));
1040+
// note: this will clear the selected sub-block if show_blk_internal is 0,
1041+
// or if it doesn't find anything
1042+
ezgl::point2d point_in_clb = ezgl::point2d(x, y) - clb_bbox.bottom_left();
1043+
highlight_sub_block(point_in_clb, clb_index,
1044+
cluster_ctx.clb_nlist.block_pb(clb_index));
10421045

1043-
if (get_selected_sub_block_info().has_selection()) {
1044-
t_pb* selected_subblock = get_selected_sub_block_info().get_selected_pb();
1045-
sprintf(msg, "sub-block %s (a \"%s\") selected",
1046-
selected_subblock->name,
1047-
selected_subblock->pb_graph_node->pb_type->name);
1048-
} else {
1049-
/* Highlight block and fan-in/fan-outs. */
1050-
draw_highlight_blocks_color(cluster_ctx.clb_nlist.block_type(clb_index),
1051-
clb_index);
1052-
sprintf(msg, "Block #%zu (%s) at (%d, %d) selected.", size_t(clb_index),
1053-
cluster_ctx.clb_nlist.block_name(clb_index).c_str(),
1054-
place_ctx.block_locs[clb_index].loc.x,
1055-
place_ctx.block_locs[clb_index].loc.y);
1056-
}
1046+
if (get_selected_sub_block_info().has_selection()) {
1047+
t_pb* selected_subblock = get_selected_sub_block_info().get_selected_pb();
1048+
sprintf(msg, "sub-block %s (a \"%s\") selected",
1049+
selected_subblock->name,
1050+
selected_subblock->pb_graph_node->pb_type->name);
1051+
} else {
1052+
/* Highlight block and fan-in/fan-outs. */
1053+
draw_highlight_blocks_color(cluster_ctx.clb_nlist.block_type(clb_index),
1054+
clb_index);
1055+
sprintf(msg, "Block #%zu (%s) at (%d, %d) selected.", size_t(clb_index),
1056+
cluster_ctx.clb_nlist.block_name(clb_index).c_str(),
1057+
place_ctx.block_locs[clb_index].loc.x,
1058+
place_ctx.block_locs[clb_index].loc.y);
1059+
}
10571060

1058-
//If manual moves is activated, then user can select block from the grid.
1059-
t_draw_state* draw_state = get_draw_state_vars();
1060-
if (draw_state->manual_moves_state.manual_move_enabled) {
1061-
draw_state->manual_moves_state.user_highlighted_block = true;
1062-
if (!draw_state->manual_moves_state.manual_move_window_is_open) {
1063-
draw_manual_moves_window(std::to_string(size_t(clb_index)));
1061+
//If manual moves is activated, then user can select block from the grid.
1062+
t_draw_state* draw_state = get_draw_state_vars();
1063+
if (draw_state->manual_moves_state.manual_move_enabled) {
1064+
draw_state->manual_moves_state.user_highlighted_block = true;
1065+
if (!draw_state->manual_moves_state.manual_move_window_is_open) {
1066+
draw_manual_moves_window(std::to_string(size_t(clb_index)));
1067+
}
10641068
}
1065-
}
10661069

1067-
application.update_message(msg);
1068-
application.refresh_drawing();
1070+
application.update_message(msg);
1071+
application.refresh_drawing();
1072+
}
10691073
}
1074+
10701075
static void setup_default_ezgl_callbacks(ezgl::application* app) {
10711076
// Connect press_proceed function to the Proceed button
10721077
GObject* proceed_button = app->get_object("ProceedButton");
@@ -1370,25 +1375,15 @@ void clear_colored_locations() {
13701375
draw_state->colored_locations.clear();
13711376
}
13721377

1373-
// This routine takes in a (x,y) location.
1374-
// 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
1375-
// otherwise, the function returns false (the location isn't among the highlighted locations)
1376-
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color) {
1378+
bool highlight_loc_with_specific_color(t_pl_loc curr_loc, ezgl::color& loc_color) {
13771379
t_draw_state* draw_state = get_draw_state_vars();
13781380

1379-
//define a (x,y) location variable
1380-
t_pl_loc curr_loc;
1381-
curr_loc.x = x;
1382-
curr_loc.y = y;
1383-
//TODO: Graphic currently doesn't support 3D FPGAs
1384-
curr_loc.layer = 0;
1385-
13861381
//search for the current location in the vector of colored locations
13871382
auto it = std::find_if(draw_state->colored_locations.begin(),
13881383
draw_state->colored_locations.end(),
13891384
[&curr_loc](const std::pair<t_pl_loc, ezgl::color>& vec_element) {
13901385
return (vec_element.first.x == curr_loc.x
1391-
&& vec_element.first.y == curr_loc.y);
1386+
&& vec_element.first.y == curr_loc.y && vec_element.first.layer == curr_loc.layer);
13921387
});
13931388

13941389
if (it != draw_state->colored_locations.end()) {
@@ -1443,4 +1438,32 @@ size_t get_max_fanout() {
14431438
return max;
14441439
}
14451440

1441+
bool rgb_is_same(ezgl::color color1, ezgl::color color2) {
1442+
color1.alpha = 255;
1443+
color2.alpha = 255;
1444+
return (color1 == color2);
1445+
}
1446+
t_draw_layer_display get_element_visibility_and_transparency(int src_layer, int sink_layer) {
1447+
t_draw_layer_display element_visibility;
1448+
t_draw_state* draw_state = get_draw_state_vars();
1449+
1450+
element_visibility.visible = true;
1451+
bool cross_layer_enabled = draw_state->cross_layer_display.visible;
1452+
1453+
//To only show primitive nets that are connected to currently active layers on the screen
1454+
if (!draw_state->draw_layer_display[sink_layer].visible || (!cross_layer_enabled && src_layer != sink_layer)) {
1455+
element_visibility.visible = false; /* Don't Draw */
1456+
}
1457+
1458+
if (src_layer != sink_layer) {
1459+
//assign transparency from cross layer option if connection is between different layers
1460+
element_visibility.alpha = draw_state->cross_layer_display.alpha;
1461+
} else {
1462+
//otherwise assign transparency of current layer
1463+
element_visibility.alpha = draw_state->draw_layer_display[src_layer].alpha;
1464+
}
1465+
1466+
return element_visibility;
1467+
}
1468+
14461469
#endif /* NO_GRAPHICS */

vpr/src/draw/draw.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,17 @@ void set_draw_loc_color(t_pl_loc, ezgl::color);
116116
// clear the colored_locations vector
117117
void clear_colored_locations();
118118

119-
// This routine takes in a (x,y) location.
120-
// 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
121-
// otherwise, the function returns false (the location isn't among the highlighted locations)
122-
bool highlight_loc_with_specific_color(int x, int y, ezgl::color& loc_color);
119+
/**
120+
* @brief If the input loc is marked in colored_locations vector, the function will return true and the corresponding color is sent back in loc_color
121+
* otherwise, the function returns false (the location isn't among the highlighted locations)
122+
*
123+
* @param curr_loc The current location that is being checked for whether it must be highlighted or not
124+
* @param loc_color The corresponding color that is to be used to highlight the block
125+
*
126+
* @return Returns true or false depending on whether the block at the specified (x,y,layer) location needs to be highlighted by a specific color.
127+
* The corresponding color is returned by reference.
128+
*/
129+
bool highlight_loc_with_specific_color(t_pl_loc curr_loc, ezgl::color& loc_color);
123130

124131
/* Because the list of possible block type colours is finite, we wrap around possible colours if there are more
125132
* block types than colour choices. This ensures we support any number of types, although the colours may repeat.*/
@@ -132,6 +139,22 @@ void toggle_window_mode(GtkWidget* /*widget*/, ezgl::application* /*app*/);
132139

133140
size_t get_max_fanout();
134141

142+
/**
143+
* @brief Takes in two colors and compares rgb values, ignoring transparency/alpha
144+
* Sets both transparencies to opaque and then compares the colors.
145+
*/
146+
bool rgb_is_same(ezgl::color color1, ezgl::color color2);
147+
148+
/**
149+
* @brief Takes in the layer number of the src and sink of an element(flyline, rr_node connections, etc...) and returns a t_draw_layer_display object holding the
150+
* information of the visibility of the element as well as the transparency based on the setting set by the user from the view menu in the UI.
151+
*
152+
* @param src_layer
153+
* @param sink_layer
154+
* @return Returns whether the element should be drawn (true or false) and the transparency factor (0 - transparent ,255 - opaque) as a t_draw_layer_display object
155+
*/
156+
t_draw_layer_display get_element_visibility_and_transparency(int src_layer, int sink_layer);
157+
135158
#endif /* NO_GRAPHICS */
136159

137160
#endif /* DRAW_H */

0 commit comments

Comments
 (0)