@@ -51,23 +51,32 @@ void draw_rr(ezgl::renderer* g) {
5151
5252 g->set_line_dash (ezgl::line_dash::none);
5353
54+ // Node colors by types
55+ // colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ
56+ constexpr vtr::array<e_rr_type, ezgl::color, (size_t )e_rr_type::NUM_RR_TYPES> node_colors{DEFAULT_RR_NODE_COLOR,
57+ DEFAULT_RR_NODE_COLOR,
58+ ezgl::PURPLE,
59+ ezgl::PINK,
60+ DEFAULT_RR_NODE_COLOR,
61+ DEFAULT_RR_NODE_COLOR,
62+ DEFAULT_RR_NODE_COLOR,
63+ DEFAULT_RR_NODE_COLOR};
64+
65+ // Draw edges first, then nodes, so that nodes (and their muxes) are rendered on top of edges.
5466 for (const RRNodeId inode : device_ctx.rr_graph .nodes ()) {
67+ draw_rr_edges (inode, g);
68+ }
5569
70+ for (const RRNodeId inode : device_ctx.rr_graph .nodes ()) {
5671 e_rr_type node_type = rr_graph.node_type (inode);
5772 bool inter_cluster_node = is_inter_cluster_node (rr_graph, inode);
5873 bool node_highlighted = draw_state->draw_rr_node [inode].node_highlighted ;
5974
60- // Node colors by types
61- // colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ
62- constexpr vtr::array<e_rr_type, ezgl::color, (size_t )e_rr_type::NUM_RR_TYPES> node_colors{DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, ezgl::PURPLE, ezgl::PINK, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR};
63-
6475 // Apply color to the node if it is not highlighted
6576 if (!node_highlighted) {
6677 draw_state->draw_rr_node [inode].color = node_colors.at (node_type);
6778 }
6879
69- draw_rr_edges (inode, g);
70-
7180 if (!node_highlighted) {
7281 // Draw channel nodes if enabled
7382 if ((node_type == e_rr_type::CHANX || node_type == e_rr_type::CHANY) && !draw_state->draw_channel_nodes ) {
@@ -233,14 +242,11 @@ void draw_rr_chan(RRNodeId inode, const ezgl::color color, ezgl::renderer* g) {
233242 g->set_color (color, transparency_factor); // Ensure color is still set correctly if we drew any arrows/text
234243}
235244
236- /* Draws all the edges that the user wants shown between inode and what it
237- * connects to. inode is assumed to be a CHANX, CHANY, or IPIN. */
238245void draw_rr_edges (RRNodeId inode, ezgl::renderer* g) {
239246 t_draw_state* draw_state = get_draw_state_vars ();
240247 const DeviceContext& device_ctx = g_vpr_ctx.device ();
241248 const RRGraphView& rr_graph = device_ctx.rr_graph ;
242249
243- e_rr_type to_type;
244250 e_rr_type from_type = rr_graph.node_type (inode);
245251
246252 // Currently don't visualize source or sinks.
@@ -250,45 +256,22 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
250256
251257 for (t_edge_size iedge = 0 , l = rr_graph.num_edges (inode); iedge < l; iedge++) {
252258 RRNodeId to_node = rr_graph.edge_sink_node (inode, iedge);
253- to_type = rr_graph.node_type (to_node);
259+ e_rr_type to_type = rr_graph.node_type (to_node);
254260 bool edge_configurable = rr_graph.edge_is_configurable (inode, iedge);
255261
256262 // Currently don't visualize source or sinks.
257263 if (to_type == e_rr_type::SOURCE || to_type == e_rr_type::SINK) {
258264 continue ;
259265 }
260266
261- ezgl::color color = DEFAULT_RR_NODE_COLOR;
262- e_edge_type edge_type;
263267 bool draw_edge = true ;
264268 bool inode_inter_cluster = is_inter_cluster_node (rr_graph, inode);
265269 bool to_node_inter_cluster = is_inter_cluster_node (rr_graph, to_node);
266270
267- // Color map for edges based on {from_type, to_type}
268- const std::map<std::pair<e_rr_type, e_rr_type>, e_edge_type> edge_type_map = {
269- // Pin to pin connections
270- {{e_rr_type::IPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
271- {{e_rr_type::OPIN, e_rr_type::IPIN}, e_edge_type::PIN_TO_IPIN},
272- {{e_rr_type::OPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
273- {{e_rr_type::IPIN, e_rr_type::OPIN}, e_edge_type::PIN_TO_OPIN},
274-
275- // Channel to pin connections
276- {{e_rr_type::OPIN, e_rr_type::CHANX}, e_edge_type::OPIN_TO_CHAN},
277- {{e_rr_type::OPIN, e_rr_type::CHANY}, e_edge_type::OPIN_TO_CHAN},
278- {{e_rr_type::CHANX, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
279- {{e_rr_type::CHANY, e_rr_type::IPIN}, e_edge_type::CHAN_TO_IPIN},
280-
281- // Channel to channel connections
282- {{e_rr_type::CHANX, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
283- {{e_rr_type::CHANX, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
284- {{e_rr_type::CHANY, e_rr_type::CHANY}, e_edge_type::CHAN_TO_CHAN},
285- {{e_rr_type::CHANY, e_rr_type::CHANX}, e_edge_type::CHAN_TO_CHAN},
286- };
287-
288- if (edge_type_map.find ({from_type, to_type}) == edge_type_map.end ()) {
271+ if (EDGE_TYPE_MAP.find ({from_type, to_type}) == EDGE_TYPE_MAP.end ()) {
289272 continue ; // Unsupported edge type
290273 }
291- edge_type = edge_type_map .at ({from_type, to_type});
274+ e_edge_type edge_type = EDGE_TYPE_MAP .at ({from_type, to_type});
292275
293276 // Determine whether to draw the edge based on user options
294277
@@ -309,17 +292,11 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
309292 draw_edge = draw_state->draw_connection_box_edges ;
310293 }
311294
312- // Select edge colors
313- const std::map<e_edge_type, ezgl::color> edge_color_map = {
314- {e_edge_type::PIN_TO_OPIN, ezgl::LIGHT_PINK},
315- {e_edge_type::PIN_TO_IPIN, ezgl::MEDIUM_PURPLE},
316- {e_edge_type::OPIN_TO_CHAN, ezgl::PINK},
317- {e_edge_type::CHAN_TO_IPIN, ezgl::PURPLE},
318- {e_edge_type::CHAN_TO_CHAN, blk_DARKGREEN}};
295+ ezgl::color color = EDGE_COLOR_MAP.at (edge_type);
319296
320- color = edge_color_map. at (edge_type);
321-
322- if (!edge_configurable) color = blk_DARKGREY;
297+ if (!edge_configurable) {
298+ color = blk_DARKGREY;
299+ }
323300
324301 if ((from_type == e_rr_type::CHANX || from_type == e_rr_type::CHANY)
325302 && (to_type == e_rr_type::IPIN)
0 commit comments