Skip to content

Commit 97f1203

Browse files
committed
added basic intra cluster routing visualization
1 parent 6c43c20 commit 97f1203

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

vpr/src/draw/draw_basic.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ void draw_routed_net(ParentNetId net_id, ezgl::renderer* g) {
607607
//Draws the set of rr_nodes specified, using the colors set in draw_state
608608
void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::renderer* g) {
609609
t_draw_state* draw_state = get_draw_state_vars();
610+
t_draw_coords* draw_coords = get_draw_coords_vars();
610611
auto& device_ctx = g_vpr_ctx.device();
611612
const auto& rr_graph = device_ctx.rr_graph;
612613

@@ -632,11 +633,6 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
632633
for (int j = 1; j < height - 1; j++)
633634
chany_track[i][j] = (-1);
634635
}
635-
// VTR_LOG("Start");
636-
// for (RRNodeId inode : rr_nodes_to_draw) {
637-
// VTR_LOG( "%d\n", rr_graph.node_type(inode));
638-
// }
639-
// VTR_LOG("End");
640636

641637
for (size_t i = 1; i < rr_nodes_to_draw.size(); ++i) {
642638
RRNodeId inode = rr_nodes_to_draw[i];
@@ -659,27 +655,21 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
659655

660656
ezgl::color color = draw_state->draw_rr_node[inode].color;
661657

662-
663-
664-
658+
// Skip drawing sources and sinks
665659
if (rr_graph.node_type(inode) == e_rr_type::SINK || rr_graph.node_type(inode) == e_rr_type::SOURCE || rr_graph.node_type(prev_node) == e_rr_type::SINK || rr_graph.node_type(prev_node) == e_rr_type::SOURCE) {
666660
continue;
667661
}
668662

669663
if (!is_inode_inter_cluster && !is_prev_node_inter_cluster) {
670664

665+
auto blk_id_pin_id1 = get_rr_node_cluster_blk_id_pb_graph_pin(inode);
666+
auto blk_id_pin_id2 = get_rr_node_cluster_blk_id_pb_graph_pin(prev_node);
671667

668+
ezgl::point2d p1 = draw_coords->get_absolute_pin_location(blk_id_pin_id1.first, blk_id_pin_id1.second);
669+
ezgl::point2d p2 = draw_coords->get_absolute_pin_location(blk_id_pin_id2.first, blk_id_pin_id2.second);
672670

673-
// AtomPinId pin_id1 = get_rr_node_atom_pin_id(inode);
674-
// AtomPinId pin_id2 = get_rr_node_atom_pin_id(prev_node);
675-
676-
// VTR_ASSERT(pin_id1 != AtomPinId::INVALID() && pin_id2 != AtomPinId::INVALID());
677-
678-
// ezgl::point2d p1 = atom_pin_draw_coord(pin_id1);
679-
// ezgl::point2d p2 = atom_pin_draw_coord(pin_id2);
680-
681-
// g->set_color(color, edge_visibility.alpha);
682-
// g->draw_line(p1, p2);
671+
g->set_color(color, edge_visibility.alpha);
672+
g->draw_line(p1, p2);
683673

684674
continue;
685675
}

vpr/src/draw/draw_types.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ ezgl::point2d t_draw_coords::get_absolute_pin_location( const ClusterBlockId clb
156156
t_pb_graph_node* pb_gnode = pb_graph_pin->parent_node;
157157
ezgl::rectangle pb_bbox = this->get_absolute_pb_bbox(clb_index, pb_gnode);
158158
int num_pins = pb_gnode->num_pins();
159-
// int pin_index =
159+
int num_pin_in_port = pb_graph_pin->pin_number;
160+
int num_pins_in_port = pb_graph_pin->port->num_pins;
161+
int num_port = pb_graph_pin->port->index;
162+
int num_pin = num_pins_in_port * num_port + num_pin_in_port;
160163

161-
164+
165+
float interval = pb_bbox.width() / (num_pins + 1);
166+
167+
return ezgl::point2d(interval * (num_pin + 1), 0.01 *this->tile_width) + pb_bbox.top_left();
162168
}
163169

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

vpr/src/util/vpr_utils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ RRNodeId get_atom_pin_rr_node_id(AtomPinId atom_pin_id) {
17551755
return rr_node_id;
17561756
}
17571757

1758-
AtomPinId get_rr_node_atom_pin_id(RRNodeId rr_node_id) {
1758+
std::pair<ClusterBlockId, t_pb_graph_pin*> get_rr_node_cluster_blk_id_pb_graph_pin(RRNodeId rr_node_id) {
17591759
auto& device_ctx = g_vpr_ctx.device();
17601760
auto& place_ctx = g_vpr_ctx.placement();
17611761

@@ -1778,6 +1778,14 @@ AtomPinId get_rr_node_atom_pin_id(RRNodeId rr_node_id) {
17781778

17791779
VTR_ASSERT(pb_graph_pin);
17801780

1781+
return {blk_id, pb_graph_pin};
1782+
}
1783+
1784+
AtomPinId get_rr_node_atom_pin_id(RRNodeId rr_node_id) {
1785+
ClusterBlockId blk_id;
1786+
t_pb_graph_pin* pb_graph_pin;
1787+
std::tie(blk_id, pb_graph_pin) = get_rr_node_cluster_blk_id_pb_graph_pin(rr_node_id);
1788+
17811789
AtomPinId atom_pin_id = find_atom_pin(blk_id, pb_graph_pin);
17821790

17831791
return atom_pin_id;

vpr/src/util/vpr_utils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,19 @@ RRNodeId get_pin_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,
257257
RRNodeId get_atom_pin_rr_node_id(AtomPinId atom_pin_id);
258258

259259
/**
260-
* @brief Returns the atom pin ID for the given RR node ID.
260+
* @brief Returns the cluster block ID and pb_graph_pin for the given RR node ID.
261261
* **Warning**: This function should be called only if flat-router is enabled,
262262
* since, otherwise, the routing resources inside clusters are not added to the RR graph.
263263
* @param rr_node_id The RR node ID.
264264
*/
265+
std::pair<ClusterBlockId, t_pb_graph_pin*> get_rr_node_cluster_blk_id_pb_graph_pin(RRNodeId rr_node_id);
266+
267+
/**
268+
* @brief Returns the atom pin ID for the given RR node ID.
269+
* **Warning**: This function should be called only if flat-router is enabled,
270+
* since, otherwise, the routing resources inside clusters are not added to the RR graph. Also, not all RRNodes have an AtomPinId associated with them.
271+
* @param rr_node_id The RR node ID.
272+
*/
265273
AtomPinId get_rr_node_atom_pin_id(RRNodeId rr_node_id);
266274

267275
RRNodeId get_class_rr_node_id(const RRSpatialLookup& rr_spatial_lookup,

0 commit comments

Comments
 (0)