@@ -292,6 +292,7 @@ static void default_setup(ezgl::application* app) {
292
292
net_button_setup (app);
293
293
block_button_setup (app);
294
294
search_setup (app);
295
+ view_button_setup (app);
295
296
}
296
297
297
298
// 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) {
526
527
* not yet know information about the routing resources. */
527
528
draw_state->draw_rr_node .resize (device_ctx.rr_graph .num_nodes ());
528
529
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
+
529
534
draw_state->arch_info = arch;
530
535
531
536
deselect_all (); /* Set initial colors */
@@ -990,83 +995,83 @@ static void highlight_blocks(double x, double y) {
990
995
// / determine block ///
991
996
ezgl::rectangle clb_bbox;
992
997
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
1005
1004
}
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
+ }
1018
1022
}
1019
1023
}
1024
+ if (clb_index != EMPTY_BLOCK_ID) {
1025
+ break ; // we've found something
1026
+ }
1020
1027
}
1021
1028
if (clb_index != EMPTY_BLOCK_ID) {
1022
1029
break ; // we've found something
1023
1030
}
1024
1031
}
1025
- if (clb_index != EMPTY_BLOCK_ID) {
1026
- break ; // we've found something
1027
- }
1028
- }
1029
1032
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
+ }
1034
1037
1035
- VTR_ASSERT (clb_index != EMPTY_BLOCK_ID);
1038
+ VTR_ASSERT (clb_index != EMPTY_BLOCK_ID);
1036
1039
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));
1042
1045
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
+ }
1057
1060
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
+ }
1064
1068
}
1065
- }
1066
1069
1067
- application.update_message (msg);
1068
- application.refresh_drawing ();
1070
+ application.update_message (msg);
1071
+ application.refresh_drawing ();
1072
+ }
1069
1073
}
1074
+
1070
1075
static void setup_default_ezgl_callbacks (ezgl::application* app) {
1071
1076
// Connect press_proceed function to the Proceed button
1072
1077
GObject* proceed_button = app->get_object (" ProceedButton" );
@@ -1370,25 +1375,15 @@ void clear_colored_locations() {
1370
1375
draw_state->colored_locations .clear ();
1371
1376
}
1372
1377
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) {
1377
1379
t_draw_state* draw_state = get_draw_state_vars ();
1378
1380
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
-
1386
1381
// search for the current location in the vector of colored locations
1387
1382
auto it = std::find_if (draw_state->colored_locations .begin (),
1388
1383
draw_state->colored_locations .end (),
1389
1384
[&curr_loc](const std::pair<t_pl_loc, ezgl::color>& vec_element) {
1390
1385
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 );
1392
1387
});
1393
1388
1394
1389
if (it != draw_state->colored_locations .end ()) {
@@ -1443,4 +1438,32 @@ size_t get_max_fanout() {
1443
1438
return max;
1444
1439
}
1445
1440
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
+
1446
1469
#endif /* NO_GRAPHICS */
0 commit comments