Skip to content

Commit c6f7d0d

Browse files
committed
implemented intra-cluster routing
1 parent b49ac73 commit c6f7d0d

File tree

8 files changed

+75
-32
lines changed

8 files changed

+75
-32
lines changed

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int get_track_num(int inode, const vtr::OffsetMatrix<int>& chanx_track, const vt
658658
* could be caused by the user clicking on a routing resource, toggled, or
659659
* fan-in/fan-out of a highlighted node.
660660
*/
661-
bool draw_if_net_highlighted(ClusterNetId inet) {
661+
bool draw_if_net_highlighted(ParentNetId inet) {
662662
t_draw_state* draw_state = get_draw_state_vars();
663663

664664
if (draw_state->net_color[inet] != DEFAULT_RR_NODE_COLOR) {

vpr/src/draw/draw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ezgl::color to_ezgl_color(vtr::Color<float> color);
9494
/* This helper function determines whether a net has been highlighted. The highlighting
9595
* could be caused by the user clicking on a routing resource, toggled, or
9696
* fan-in/fan-out of a highlighted node. */
97-
bool draw_if_net_highlighted(ClusterNetId inet);
97+
bool draw_if_net_highlighted(ParentNetId inet);
9898
std::vector<RRNodeId> trace_routed_connection_rr_nodes(
9999
ClusterNetId net_id,
100100
int driver_pin,

vpr/src/draw/draw_basic.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,24 +569,20 @@ void drawroute(enum e_draw_net_type draw_net_type, ezgl::renderer* g) {
569569

570570
void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
571571
auto& route_ctx = g_vpr_ctx.routing();
572-
auto& cluster_ctx = g_vpr_ctx.clustering();
573572

574573
t_draw_state* draw_state = get_draw_state_vars();
575574

576-
if (cluster_ctx.clb_nlist.net_is_ignored(convert_to_cluster_net_id(net_id))) /* Don't draw. */
577-
return;
578-
579575
if (!route_ctx.route_trees[net_id]) // No routing -> Skip. (Allows me to draw partially complete routes)
580576
return;
581577

582578
std::vector<RRNodeId> rr_nodes_to_draw;
583579
for (auto& rt_node : route_ctx.route_trees[net_id].value().all_nodes()) {
584580
RRNodeId inode = rt_node.inode;
585581

586-
if (draw_if_net_highlighted(convert_to_cluster_net_id(net_id))) {
582+
if (draw_if_net_highlighted(net_id)) {
587583
/* If a net has been highlighted, highlight the whole net in *
588584
* the same color. */
589-
draw_state->draw_rr_node[inode].color = draw_state->net_color[convert_to_cluster_net_id(net_id)];
585+
draw_state->draw_rr_node[inode].color = draw_state->net_color[net_id];
590586
draw_state->draw_rr_node[inode].node_highlighted = true;
591587
} else {
592588
/* If not highlighted, draw the node in default color. */
@@ -676,12 +672,35 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
676672

677673
g->set_color(color, edge_visibility.alpha);
678674
g->draw_line(p1, p2);
675+
g->draw_text(p1, blk_id_pin_id1.second->parent_node->pb_type->name, 50, 0.5 * 20);
679676

680677
continue;
681678
}
682679

683680
if (!is_inode_inter_cluster || !is_prev_node_inter_cluster) {
681+
bool swap = false;
682+
if (!is_inode_inter_cluster && is_prev_node_inter_cluster) {
683+
//Swap the nodes so that the inter-cluster node is always the current node
684+
std::swap(inode, prev_node);
685+
swap = true;
686+
}
687+
688+
auto blk_id_pin_id = get_rr_node_cluster_blk_id_pb_graph_pin(prev_node);
689+
float x1, y1;
690+
ezgl::point2d p2 = draw_coords->get_absolute_pin_location(blk_id_pin_id.first, blk_id_pin_id.second);
691+
692+
693+
for (const e_side& pin_side : TOTAL_2D_SIDES) {
694+
if (!rr_graph.is_node_on_specific_side(RRNodeId(inode), pin_side)) {
695+
continue;
696+
}
697+
draw_get_rr_pin_coords(inode, &x1, &y1, pin_side);
698+
g->set_color(color, edge_visibility.alpha);
699+
g->draw_line({x1, y1}, p2);
700+
}
701+
684702
continue;
703+
685704
}
686705

687706
auto iedge = find_edge(prev_node, inode);

vpr/src/draw/draw_searchbar.cpp

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,40 +131,60 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type,
131131
/* If an rr_node has been clicked on, it will be highlighted in MAGENTA.
132132
* If so, and toggle nets is selected, highlight the whole net in that colour.
133133
*/
134-
void highlight_nets(char* message, RRNodeId hit_node, bool is_flat) {
134+
void highlight_net(char* message, RRNodeId hit_node) {
135135
auto& cluster_ctx = g_vpr_ctx.clustering();
136+
auto& atom_ctx = g_vpr_ctx.atom();
136137
auto& route_ctx = g_vpr_ctx.routing();
137138

138139
/* Don't crash if there's no routing */
139140
if (route_ctx.route_trees.empty())
140141
return;
141142

143+
if (route_ctx.is_flat){
144+
for (auto net_id : atom_ctx.netlist().nets()){
145+
check_node_highlight_net(message, net_id, hit_node);
146+
}
147+
148+
} else{
149+
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
150+
check_node_highlight_net(message, net_id, hit_node);
151+
}
152+
}
153+
154+
application.update_message(message);
155+
}
156+
157+
void check_node_highlight_net(char* message, ParentNetId parent_id,
158+
RRNodeId hit_node) {
159+
auto& route_ctx = g_vpr_ctx.routing();
142160
t_draw_state* draw_state = get_draw_state_vars();
143161

144-
for (auto net_id : cluster_ctx.clb_nlist.nets()) {
145-
ParentNetId parent_id = get_cluster_net_parent_id(g_vpr_ctx.atom().lookup(), net_id, is_flat);
146-
if (!route_ctx.route_trees[parent_id])
147-
continue;
162+
if (!route_ctx.route_trees[parent_id])
163+
return;
148164

149-
for (auto& rt_node : route_ctx.route_trees[parent_id].value().all_nodes()) {
150-
RRNodeId inode = rt_node.inode;
151-
if (draw_state->draw_rr_node[inode].color == ezgl::MAGENTA) {
152-
draw_state->net_color[net_id] = draw_state->draw_rr_node[inode].color;
153-
if (inode == hit_node) {
154-
std::string orig_msg(message);
155-
sprintf(message, "%s || Net: %zu (%s)", orig_msg.c_str(),
156-
size_t(net_id),
157-
cluster_ctx.clb_nlist.net_name(net_id).c_str());
165+
for (auto& rt_node : route_ctx.route_trees[parent_id].value().all_nodes()) {
166+
RRNodeId inode = rt_node.inode;
167+
if (draw_state->draw_rr_node[inode].color == ezgl::MAGENTA) {
168+
draw_state->net_color[parent_id] = draw_state->draw_rr_node[inode].color;
169+
if (inode == hit_node) {
170+
std::string orig_msg(message);
171+
std::string net_name;
172+
if(!route_ctx.is_flat){
173+
net_name = g_vpr_ctx.clustering().clb_nlist.net_name(convert_to_cluster_net_id(parent_id));
174+
} else {
175+
net_name = g_vpr_ctx.atom().netlist().net_name(convert_to_atom_net_id(parent_id));
158176
}
159-
} else if (draw_state->draw_rr_node[inode].color
160-
== ezgl::WHITE) {
161-
// If node is de-selected.
162-
draw_state->net_color[net_id] = ezgl::BLACK;
163-
break;
177+
sprintf(message, "%s || Net: %zu (%s)", orig_msg.c_str(),
178+
size_t(parent_id),
179+
net_name.c_str());
164180
}
181+
} else if (draw_state->draw_rr_node[inode].color
182+
== ezgl::WHITE) {
183+
// If node is de-selected.
184+
draw_state->net_color[parent_id] = ezgl::BLACK;
185+
break;
165186
}
166187
}
167-
application.update_message(message);
168188
}
169189

170190
/* If an rr_node has been clicked on, it will be either highlighted in MAGENTA,

vpr/src/draw/draw_searchbar.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ void draw_highlight_blocks_color(t_logical_block_type_ptr type, ClusterBlockId b
2828

2929
/* If an rr_node has been clicked on, it will be highlighted in MAGENTA.
3030
* If so, and toggle nets is selected, highlight the whole net in that colour.*/
31-
void highlight_nets(char* message, RRNodeId hit_node, bool is_flat);
31+
void highlight_net(char* message, RRNodeId hit_node);
32+
33+
/* Checks if a node is part of a net, and highlights the net if it is. */
34+
void check_node_highlight_net(char* message, ParentNetId parent_id,
35+
RRNodeId hit_node);
3236

3337
/* If an rr_node has been clicked on, it will be either highlighted in MAGENTA,
3438
* or de-highlighted in WHITE. If highlighted, and toggle_rr is selected, highlight

vpr/src/draw/draw_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ezgl::point2d t_draw_coords::get_absolute_pin_location( const ClusterBlockId clb
164164

165165
float interval = pb_bbox.width() / (num_pins + 1);
166166

167-
return ezgl::point2d(interval * (num_pin + 1), 0.01 *this->tile_width) + pb_bbox.top_left();
167+
return ezgl::point2d(interval * (num_pin + 1), -0.01 *this->tile_width) + pb_bbox.top_left();
168168
}
169169

170170
ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(const ClusterBlockId clb_index, const t_logical_block_type_ptr block_type) {

vpr/src/draw/intra_logic_block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void draw_internal_draw_subblk(ezgl::renderer* g) {
198198
static int draw_internal_find_max_lvl(const t_pb_type& pb_type) {
199199
int i, j;
200200
t_mode mode;
201-
int max_levels = 0;
201+
int max_levels = 1;
202202

203203
/* If pb_type is a primitive, we have reached the end of pb_graph */
204204
if (pb_type.is_primitive())

vpr/src/draw/search_bar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ bool highlight_rr_nodes(RRNodeId hit_node) {
247247
}
248248

249249
if (draw_state->show_nets)
250-
highlight_nets(message, hit_node, draw_state->is_flat);
250+
highlight_net(message, hit_node);
251251
else
252252
application.update_message(message);
253253

0 commit comments

Comments
 (0)