Skip to content

Commit 057982c

Browse files
committed
changed ipin color from blk_skyblue to purple and and used std::map for colors
1 parent d887452 commit 057982c

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

vpr/src/draw/draw_rr.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void draw_rr(ezgl::renderer* g) {
6666
draw_state->draw_rr_node[inode].color = ezgl::PINK;
6767
break;
6868
case e_rr_type::IPIN:
69-
draw_state->draw_rr_node[inode].color = blk_LIGHTSKYBLUE;
69+
draw_state->draw_rr_node[inode].color = ezgl::PURPLE;
7070
break;
7171
case e_rr_type::SOURCE:
7272
draw_state->draw_rr_node[inode].color = ezgl::PLUM;
@@ -240,7 +240,7 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
240240
e_rr_type from_type, to_type;
241241

242242
from_type = rr_graph.node_type(inode);
243-
if (from_type == e_rr_type::SOURCE || from_type == e_rr_type::SINK || !is_inter_cluster_node(rr_graph, inode)) {
243+
if (from_type == e_rr_type::SOURCE || from_type == e_rr_type::SINK) {
244244
return;
245245
}
246246

@@ -255,51 +255,51 @@ void draw_rr_edges(RRNodeId inode, ezgl::renderer* g) {
255255
to_type = rr_graph.node_type(to_node);
256256
bool edge_configurable = rr_graph.edge_is_configurable(inode, iedge);
257257

258-
if (to_type == e_rr_type::SOURCE || to_type == e_rr_type::SINK || !is_inter_cluster_node(rr_graph, to_node)) {
258+
if (to_type == e_rr_type::SOURCE || to_type == e_rr_type::SINK) {
259259
continue;
260260
}
261261

262262
ezgl::color color = DEFAULT_RR_NODE_COLOR;
263-
// Determine the color based on the type of the edge
264-
switch (from_type) {
265-
case e_rr_type::OPIN:
266-
if (to_type == e_rr_type::CHANX || to_type == e_rr_type::CHANY) {
267-
color = ezgl::PINK;
268-
} else if (to_type == e_rr_type::IPIN) {
269-
color = ezgl::MEDIUM_PURPLE;
270-
} else {
271-
vpr_throw(VPR_ERROR_OTHER, __FILE__, __LINE__,
272-
"in draw_rr_edges: node %d (type: %d) connects to node %d (type: %d).\n",
273-
inode, from_type, to_node, to_type);
274-
}
275-
break;
276-
case e_rr_type::CHANX:
277-
case e_rr_type::CHANY:
278-
if (to_type == e_rr_type::IPIN) {
279-
color = blk_LIGHTSKYBLUE;
280-
if (draw_state->draw_rr_node[to_node].node_highlighted && draw_state->draw_rr_node[inode].color == DEFAULT_RR_NODE_COLOR) {
281-
// If the IPIN is clicked on, draw connection to all the CHANX
282-
// wire segments fanning into the pin. If a CHANX wire is clicked
283-
// on, draw only the connection between that wire and the IPIN, with
284-
// the pin fanning out from the wire.
285-
color = ezgl::MAGENTA;
286-
}
287-
} else if (to_type == e_rr_type::CHANX || to_type == e_rr_type::CHANY) {
288-
if (edge_configurable) {
289-
color = blk_DARKGREEN;
290-
} else {
291-
color = blk_DARKGREY;
292-
}
293-
} else {
294-
vpr_throw(VPR_ERROR_OTHER, __FILE__, __LINE__,
295-
"in draw_rr_edges: node %d (type: %d) connects to node %d (type: %d).\n",
296-
inode, from_type, to_node, to_type);
297-
}
298-
break;
299-
default:
300-
break;
263+
264+
// Color map for edges based on {from_type, to_type}
265+
static const std::map<std::pair<e_rr_type, e_rr_type>, ezgl::color> edge_color_map = {
266+
// Pin to pin connections
267+
{{e_rr_type::IPIN, e_rr_type::IPIN}, ezgl::MEDIUM_PURPLE},
268+
{{e_rr_type::OPIN, e_rr_type::IPIN}, ezgl::MEDIUM_PURPLE},
269+
{{e_rr_type::OPIN, e_rr_type::OPIN}, ezgl::LIGHT_PINK},
270+
{{e_rr_type::IPIN, e_rr_type::OPIN}, ezgl::LIGHT_PINK},
271+
272+
// Channel to pin connections
273+
{{e_rr_type::OPIN, e_rr_type::CHANX}, ezgl::PINK},
274+
{{e_rr_type::OPIN, e_rr_type::CHANY}, ezgl::PINK},
275+
{{e_rr_type::CHANX, e_rr_type::IPIN}, ezgl::PURPLE},
276+
{{e_rr_type::CHANY, e_rr_type::IPIN}, ezgl::PURPLE},
277+
278+
// Channel to channel connections
279+
{{e_rr_type::CHANX, e_rr_type::CHANX}, blk_DARKGREEN},
280+
{{e_rr_type::CHANX, e_rr_type::CHANY}, blk_DARKGREEN},
281+
{{e_rr_type::CHANY, e_rr_type::CHANY}, blk_DARKGREEN},
282+
{{e_rr_type::CHANY, e_rr_type::CHANX}, blk_DARKGREEN},
283+
};
284+
285+
if (edge_color_map.find({from_type, to_type}) != edge_color_map.end()) {
286+
color = edge_color_map.at({from_type, to_type});
287+
}
288+
289+
if (!edge_configurable) color = blk_DARKGREY;
290+
291+
if((from_type == e_rr_type::CHANX || from_type == e_rr_type::CHANY)
292+
&& (to_type == e_rr_type::IPIN)
293+
&& draw_state->draw_rr_node[to_node].node_highlighted
294+
&& draw_state->draw_rr_node[inode].color == DEFAULT_RR_NODE_COLOR){
295+
// If the IPIN is clicked on, draw connection to all the CHANX
296+
// wire segments fanning into the pin. If a CHANX wire is clicked
297+
// on, draw only the connection between that wire and the IPIN, with
298+
// the pin fanning out from the wire.
299+
color = ezgl::MAGENTA;
301300
}
302301

302+
// If the node is highlighted, use its color
303303
if (rgb_is_same(draw_state->draw_rr_node[inode].color, ezgl::MAGENTA) || rgb_is_same(draw_state->draw_rr_node[to_node].color, ezgl::MAGENTA)) {
304304
color = draw_state->draw_rr_node[to_node].color;
305305
}

0 commit comments

Comments
 (0)