Skip to content

Commit baaac60

Browse files
authored
Merge pull request #3236 from verilog-to-routing/gui_update
Updated Route and Net UI Elements
2 parents 8c48d50 + 7c635ba commit baaac60

31 files changed

+1095
-886
lines changed

vpr/main.ui

Lines changed: 401 additions & 251 deletions
Large diffs are not rendered by default.

vpr/src/draw/b.png

-1.12 KB
Binary file not shown.

vpr/src/draw/draw.cpp

Lines changed: 79 additions & 201 deletions
Large diffs are not rendered by default.

vpr/src/draw/draw_basic.cpp

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const std::vector<ezgl::color> kelly_max_contrast_colors = {
7676
void drawplace(ezgl::renderer* g) {
7777
t_draw_state* draw_state = get_draw_state_vars();
7878
t_draw_coords* draw_coords = get_draw_coords_vars();
79-
const auto& device_ctx = g_vpr_ctx.device();
80-
const auto& cluster_ctx = g_vpr_ctx.clustering();
79+
const DeviceContext& device_ctx = g_vpr_ctx.device();
80+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
8181
const auto& grid_blocks = draw_state->get_graphics_blk_loc_registry_ref().grid_blocks();
8282

8383
ClusterBlockId bnum;
@@ -196,14 +196,12 @@ void drawplace(ezgl::renderer* g) {
196196
/* This routine draws the nets on the placement. The nets have not *
197197
* yet been routed, so we just draw a chain showing a possible path *
198198
* for each net. This gives some idea of future congestion. */
199-
void drawnets(ezgl::renderer* g) {
199+
void draw_flylines_placement(ezgl::renderer* g) {
200200
t_draw_state* draw_state = get_draw_state_vars();
201201
t_draw_coords* draw_coords = get_draw_coords_vars();
202-
const auto& cluster_ctx = g_vpr_ctx.clustering();
202+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
203203
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
204204

205-
float NET_ALPHA = draw_state->net_alpha;
206-
207205
g->set_line_dash(ezgl::line_dash::none);
208206
g->set_line_width(0);
209207

@@ -244,11 +242,12 @@ void drawnets(ezgl::renderer* g) {
244242
if (!element_visibility.visible) {
245243
continue; /* Don't Draw */
246244
}
247-
float transparency_factor = element_visibility.alpha;
248245

249-
//Take the highest of the 2 transparency values that the user can select from the UI
246+
// Take the highest of the 2 transparency values that the user can select from the UI
250247
// Compare the current cross layer transparency to the overall Net transparency set by the user.
251-
g->set_color(draw_state->net_color[net_id], fmin(transparency_factor, draw_state->net_color[net_id].alpha * NET_ALPHA));
248+
int transparency = std::min(element_visibility.alpha, draw_state->net_color[net_id].alpha * draw_state->net_alpha / 255);
249+
250+
g->set_color(draw_state->net_color[net_id], transparency);
252251

253252
ezgl::point2d sink_center = draw_coords->get_absolute_clb_bbox(b2, cluster_ctx.clb_nlist.block_type(b2)).center();
254253
g->draw_line(driver_center, sink_center);
@@ -266,9 +265,9 @@ void draw_congestion(ezgl::renderer* g) {
266265
return;
267266
}
268267

269-
auto& device_ctx = g_vpr_ctx.device();
270-
const auto& rr_graph = device_ctx.rr_graph;
271-
auto& route_ctx = g_vpr_ctx.routing();
268+
const DeviceContext& device_ctx = g_vpr_ctx.device();
269+
const RRGraphView& rr_graph = device_ctx.rr_graph;
270+
const RoutingContext& route_ctx = g_vpr_ctx.routing();
272271

273272
//Record min/max congestion
274273
float min_congestion_ratio = 1.;
@@ -320,7 +319,7 @@ void draw_congestion(ezgl::renderer* g) {
320319
}
321320
}
322321
g->set_line_width(0);
323-
drawroute(HIGHLIGHTED, g);
322+
draw_route(HIGHLIGHTED, g);
324323

325324
//Reset colors
326325
for (RRNodeId inode : congested_rr_nodes) {
@@ -379,8 +378,8 @@ void draw_routing_costs(ezgl::renderer* g) {
379378
return;
380379
}
381380

382-
auto& device_ctx = g_vpr_ctx.device();
383-
auto& route_ctx = g_vpr_ctx.routing();
381+
const DeviceContext& device_ctx = g_vpr_ctx.device();
382+
const RoutingContext& route_ctx = g_vpr_ctx.routing();
384383
g->set_line_width(0);
385384

386385
VTR_ASSERT(!route_ctx.rr_node_route_inf.empty());
@@ -472,8 +471,8 @@ void draw_routing_bb(ezgl::renderer* g) {
472471
return;
473472
}
474473

475-
auto& route_ctx = g_vpr_ctx.routing();
476-
auto& cluster_ctx = g_vpr_ctx.clustering();
474+
const RoutingContext& route_ctx = g_vpr_ctx.routing();
475+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
477476

478477
VTR_ASSERT(draw_state->show_routing_bb != OPEN);
479478
VTR_ASSERT(draw_state->show_routing_bb < (int)route_ctx.route_bb.size());
@@ -534,18 +533,16 @@ void draw_x(float x, float y, float size, ezgl::renderer* g) {
534533
/* Draws the nets in the positions fixed by the router. If draw_net_type is *
535534
* ALL_NETS, draw all the nets. If it is HIGHLIGHTED, draw only the nets *
536535
* that are not coloured black (useful for drawing over the rr_graph). */
537-
void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
536+
void draw_route(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
538537
/* Next free track in each channel segment if routing is GLOBAL */
539538

540-
auto& cluster_ctx = g_vpr_ctx.clustering();
539+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
541540
const AtomContext& atom_ctx = g_vpr_ctx.atom();
542541

543542
t_draw_state* draw_state = get_draw_state_vars();
544543

545-
float NET_ALPHA = draw_state->net_alpha;
546-
547544
g->set_line_dash(ezgl::line_dash::none);
548-
g->set_color(ezgl::BLACK, ezgl::BLACK.alpha * NET_ALPHA);
545+
g->set_color(ezgl::BLACK, draw_state->net_alpha);
549546

550547
/* Now draw each net, one by one. */
551548
if (draw_state->is_flat) {
@@ -568,7 +565,7 @@ void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
568565
}
569566

570567
void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
571-
auto& route_ctx = g_vpr_ctx.routing();
568+
const RoutingContext& route_ctx = g_vpr_ctx.routing();
572569

573570
t_draw_state* draw_state = get_draw_state_vars();
574571

@@ -579,13 +576,12 @@ void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
579576
for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
580577
RRNodeId inode = rt_node.inode;
581578

579+
// If a net has been highlighted, highlight all the nodes in the net the same color.
582580
if (draw_if_net_highlighted(net_id)) {
583-
/* If a net has been highlighted, highlight the whole net in *
584-
* the same color. */
585581
draw_state->draw_rr_node[inode].color = draw_state->net_color[net_id];
586582
draw_state->draw_rr_node[inode].node_highlighted = true;
587583
} else {
588-
/* If not highlighted, draw the node in default color. */
584+
// If not highlighted, draw the node in default color.
589585
draw_state->draw_rr_node[inode].color = DEFAULT_RR_NODE_COLOR;
590586
}
591587

@@ -609,21 +605,53 @@ void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
609605
//Draws the set of rr_nodes specified, using the colors set in draw_state
610606
void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::renderer* g) {
611607
t_draw_state* draw_state = get_draw_state_vars();
608+
const RRGraphView& rr_graph = g_vpr_ctx.device().rr_graph;
612609

613610
// Draw RR Nodes
614611
for (size_t i = 1; i < rr_nodes_to_draw.size(); ++i) {
615612
RRNodeId inode = rr_nodes_to_draw[i];
616613
ezgl::color color = draw_state->draw_rr_node[inode].color;
617614

615+
bool inter_cluster_node = is_inter_cluster_node(rr_graph, inode);
616+
617+
if (!(draw_state->draw_rr_node[inode].node_highlighted && draw_state->highlight_fan_in_fan_out)) {
618+
// skip drawing INTER-cluster nets if the user has disabled them
619+
if (inter_cluster_node && !draw_state->draw_inter_cluster_nets) {
620+
continue;
621+
}
622+
623+
// skip drawing INTRA-cluster nets if the user has disabled them
624+
if (!inter_cluster_node && !draw_state->draw_intra_cluster_nets) {
625+
continue;
626+
}
627+
}
628+
618629
draw_rr_node(inode, color, g);
619630
}
620631

621632
// Draw Edges
622633
for (size_t i = 1; i < rr_nodes_to_draw.size(); ++i) {
623634
RRNodeId inode = rr_nodes_to_draw[i];
624635
RRNodeId prev_node = rr_nodes_to_draw[i - 1];
636+
bool inter_cluster_node = is_inter_cluster_node(rr_graph, inode);
637+
bool prev_inter_cluster_node = is_inter_cluster_node(rr_graph, prev_node);
625638

626-
draw_rr_edge(inode, prev_node, draw_state->draw_rr_node[inode].color, g);
639+
if (!(draw_state->draw_rr_node[inode].node_highlighted && draw_state->highlight_fan_in_fan_out)) {
640+
// If this is an edge between two inter-cluster nodes, draw only if the user has enabled inter-cluster nets
641+
if ((inter_cluster_node && prev_inter_cluster_node) && !draw_state->draw_inter_cluster_nets) {
642+
continue;
643+
}
644+
645+
// If this is an edge containing an intra-cluster node, draw only if the user has enabled intra-cluster nets
646+
if ((!inter_cluster_node || !prev_inter_cluster_node) && !draw_state->draw_intra_cluster_nets) {
647+
continue;
648+
}
649+
}
650+
651+
// avoid highlighting edge unless both nodes are highlighted
652+
ezgl::color color = draw_state->draw_rr_node[prev_node].node_highlighted ? draw_state->draw_rr_node[inode].color : DEFAULT_RR_NODE_COLOR;
653+
654+
draw_rr_edge(inode, prev_node, color, g);
627655
}
628656
}
629657

@@ -633,7 +661,7 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
633661
*/
634662
bool is_edge_valid_to_draw(RRNodeId current_node, RRNodeId prev_node) {
635663
t_draw_state* draw_state = get_draw_state_vars();
636-
auto& rr_graph = g_vpr_ctx.device().rr_graph;
664+
const RRGraphView& rr_graph = g_vpr_ctx.device().rr_graph;
637665

638666
int current_node_layer = rr_graph.node_layer(current_node);
639667
int prev_node_layer = rr_graph.node_layer(prev_node);
@@ -726,7 +754,7 @@ void draw_routing_util(ezgl::renderer* g) {
726754
}
727755

728756
t_draw_coords* draw_coords = get_draw_coords_vars();
729-
auto& device_ctx = g_vpr_ctx.device();
757+
const DeviceContext& device_ctx = g_vpr_ctx.device();
730758

731759
auto chanx_usage = calculate_routing_usage(e_rr_type::CHANX, draw_state->is_flat, false);
732760
auto chany_usage = calculate_routing_usage(e_rr_type::CHANY, draw_state->is_flat, false);
@@ -896,7 +924,7 @@ void draw_crit_path(ezgl::renderer* g) {
896924
tatum::TimingPathCollector path_collector;
897925

898926
t_draw_state* draw_state = get_draw_state_vars();
899-
auto& timing_ctx = g_vpr_ctx.timing();
927+
const TimingContext& timing_ctx = g_vpr_ctx.timing();
900928

901929
if (draw_state->show_crit_path == DRAW_NO_CRIT_PATH) {
902930
return;
@@ -1054,7 +1082,7 @@ void draw_crit_path_elements(const std::vector<tatum::TimingPath>& paths, const
10541082
int get_timing_path_node_layer_num(tatum::NodeId node) {
10551083
t_draw_state* draw_state = get_draw_state_vars();
10561084
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
1057-
const auto& atom_ctx = g_vpr_ctx.atom();
1085+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
10581086

10591087
AtomPinId atom_pin = atom_ctx.lookup().tnode_atom_pin(node);
10601088
AtomBlockId atom_block = atom_ctx.netlist().pin_block(atom_pin);
@@ -1152,9 +1180,9 @@ void draw_routed_timing_edge_connection(tatum::NodeId src_tnode,
11521180
tatum::NodeId sink_tnode,
11531181
ezgl::color color,
11541182
ezgl::renderer* g) {
1155-
auto& atom_ctx = g_vpr_ctx.atom();
1156-
auto& cluster_ctx = g_vpr_ctx.clustering();
1157-
auto& timing_ctx = g_vpr_ctx.timing();
1183+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
1184+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
1185+
const TimingContext& timing_ctx = g_vpr_ctx.timing();
11581186

11591187
AtomPinId atom_src_pin = atom_ctx.lookup().tnode_atom_pin(src_tnode);
11601188
AtomPinId atom_sink_pin = atom_ctx.lookup().tnode_atom_pin(sink_tnode);
@@ -1211,6 +1239,7 @@ void draw_routed_timing_edge_connection(tatum::NodeId src_tnode,
12111239

12121240
for (RRNodeId inode : routed_rr_nodes) {
12131241
draw_state->draw_rr_node[inode].color = color;
1242+
draw_state->draw_rr_node[inode].node_highlighted = true;
12141243
}
12151244

12161245
//draw_partial_route() takes care of layer visibility and cross-layer settings
@@ -1284,8 +1313,8 @@ void draw_block_pin_util() {
12841313
if (draw_state->show_blk_pin_util == DRAW_NO_BLOCK_PIN_UTIL)
12851314
return;
12861315

1287-
const auto& device_ctx = g_vpr_ctx.device();
1288-
const auto& cluster_ctx = g_vpr_ctx.clustering();
1316+
const DeviceContext& device_ctx = g_vpr_ctx.device();
1317+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
12891318
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();
12901319

12911320
std::map<t_physical_tile_type_ptr, size_t> total_input_pins;
@@ -1344,7 +1373,7 @@ void draw_block_pin_util() {
13441373
}
13451374

13461375
void draw_reset_blk_colors() {
1347-
const auto& cluster_ctx = g_vpr_ctx.clustering();
1376+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
13481377
for (auto blk : cluster_ctx.clb_nlist.blocks()) {
13491378
draw_reset_blk_color(blk);
13501379
}

vpr/src/draw/draw_basic.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
* Blocks are drawn in layer order (so that semi-transparent blocks/grids render well)*/
3030
void drawplace(ezgl::renderer* g);
3131

32-
/* This routine draws the nets on the placement. The nets have not *
33-
* yet been routed, so we just draw a chain showing a possible path *
34-
* for each net. This gives some idea of future congestion. */
35-
void drawnets(ezgl::renderer* g);
32+
/** This routine draws the nets on the placement. The nets have not
33+
* yet been routed, so we just draw a chain showing a possible path
34+
* for each net. This gives some idea of future congestion.
35+
* This function may be deprecated. draw_logical_connections() is preferred. */
36+
void draw_flylines_placement(ezgl::renderer* g);
3637

3738
/* Draws all the overused routing resources (i.e. congestion) in various contrasting colors showing congestion ratio. */
3839
void draw_congestion(ezgl::renderer* g);
@@ -49,7 +50,7 @@ void draw_x(float x, float y, float size, ezgl::renderer* g);
4950
/* Draws the nets in the positions fixed by the router. If draw_net_type is *
5051
* ALL_NETS, draw all the nets. If it is HIGHLIGHTED, draw only the nets *
5152
* that are not coloured black (useful for drawing over the rr_graph). */
52-
void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g);
53+
void draw_route(enum e_draw_net_type draw_net_type, ezgl::renderer* g);
5354

5455
void draw_routed_net(ParentNetId net, ezgl::renderer* g);
5556

vpr/src/draw/draw_floorplanning.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static std::vector<int> highlight_alpha;
5656

5757
//Helper function to highlight a partition
5858
static void highlight_partition(ezgl::renderer* g, int partitionID, int alpha) {
59-
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
59+
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
6060
auto constraints = floorplanning_ctx.constraints;
6161
t_draw_coords* draw_coords = get_draw_coords_vars();
6262
t_draw_state* draw_state = get_draw_state_vars();
@@ -116,7 +116,7 @@ static void highlight_partition(ezgl::renderer* g, int partitionID, int alpha) {
116116

117117
//Iterates through all partitions and draws each region of each partition
118118
void highlight_all_regions(ezgl::renderer* g) {
119-
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
119+
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
120120
const auto& constraints = floorplanning_ctx.constraints;
121121
auto num_partitions = constraints.get_num_partitions();
122122

@@ -135,11 +135,11 @@ void highlight_all_regions(ezgl::renderer* g) {
135135

136136
// Draws atoms that are constrained to a partition in the colour of their respective partition.
137137
void draw_constrained_atoms(ezgl::renderer* g) {
138-
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
138+
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
139139
const auto& constraints = floorplanning_ctx.constraints;
140140
int num_partitions = constraints.get_num_partitions();
141-
auto& atom_ctx = g_vpr_ctx.atom();
142-
auto& cluster_ctx = g_vpr_ctx.clustering();
141+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
142+
const ClusteringContext& cluster_ctx = g_vpr_ctx.clustering();
143143

144144
for (int partitionID = 0; partitionID < num_partitions; partitionID++) {
145145
auto atoms = constraints.get_part_atoms((PartitionId)partitionID);
@@ -237,7 +237,7 @@ enum {
237237

238238
//Highlights partition clicked on in the legend.
239239
void highlight_selected_partition(GtkWidget* widget) {
240-
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
240+
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
241241
auto constraints = floorplanning_ctx.constraints;
242242
auto num_partitions = constraints.get_num_partitions();
243243

@@ -282,8 +282,8 @@ void highlight_selected_partition(GtkWidget* widget) {
282282

283283
//Fills in the legend
284284
static GtkTreeModel* create_and_fill_model() {
285-
auto& atom_ctx = g_vpr_ctx.atom();
286-
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
285+
const AtomContext& atom_ctx = g_vpr_ctx.atom();
286+
const FloorplanningContext& floorplanning_ctx = g_vpr_ctx.floorplanning();
287287
const auto& constraints = floorplanning_ctx.constraints;
288288
int num_partitions = constraints.get_num_partitions();
289289

vpr/src/draw/draw_noc.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
void draw_noc(ezgl::renderer* g) {
1414
t_draw_state* draw_state = get_draw_state_vars();
15-
auto& noc_ctx = g_vpr_ctx.noc();
16-
auto& device_ctx = g_vpr_ctx.device();
15+
const NocContext& noc_ctx = g_vpr_ctx.noc();
16+
const DeviceContext& device_ctx = g_vpr_ctx.device();
1717

1818
// vector of routers in the NoC
1919
const vtr::vector<NocRouterId, NocRouter>& router_list = noc_ctx.noc_model.get_noc_routers();
@@ -76,7 +76,7 @@ void draw_noc(ezgl::renderer* g) {
7676
*/
7777
void draw_noc_usage(vtr::vector<NocLinkId, ezgl::color>& noc_link_colors) {
7878
t_draw_state* draw_state = get_draw_state_vars();
79-
const auto& noc_ctx = g_vpr_ctx.noc();
79+
const NocContext& noc_ctx = g_vpr_ctx.noc();
8080
const auto& noc_link_bandwidth_usages = draw_state->get_noc_link_bandwidth_usages_ref();
8181

8282
// check to see if a color map was already created previously
@@ -210,7 +210,7 @@ void draw_noc_links(ezgl::renderer* g,
210210
ezgl::rectangle noc_connection_marker_bbox,
211211
const vtr::vector<NocLinkId, NocLinkShift>& list_of_noc_link_shift_directions) {
212212
t_draw_coords* draw_coords = get_draw_coords_vars();
213-
auto& noc_ctx = g_vpr_ctx.noc();
213+
const NocContext& noc_ctx = g_vpr_ctx.noc();
214214

215215
// vector of routers in the NoC
216216
const vtr::vector<NocRouterId, NocRouter>& router_list = noc_ctx.noc_model.get_noc_routers();
@@ -296,7 +296,7 @@ void draw_noc_links(ezgl::renderer* g,
296296
}
297297

298298
void determine_direction_to_shift_noc_links(vtr::vector<NocLinkId, NocLinkShift>& list_of_noc_link_shift_directions) {
299-
auto& noc_ctx = g_vpr_ctx.noc();
299+
const NocContext& noc_ctx = g_vpr_ctx.noc();
300300

301301
int number_of_links = list_of_noc_link_shift_directions.size();
302302

0 commit comments

Comments
 (0)