Skip to content

Commit 850a0e6

Browse files
committed
fixed incorrect pin side issue
1 parent ea61183 commit 850a0e6

File tree

5 files changed

+90
-51
lines changed

5 files changed

+90
-51
lines changed

vpr/src/draw/draw_basic.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,27 @@ void draw_partial_route(const std::vector<RRNodeId>& rr_nodes_to_draw, ezgl::ren
683683
continue;
684684
}
685685

686-
if (!inode_inter_cluster || !prev_node_inter_cluster) {
687-
draw_intra_cluster_pin_to_pin(inode, prev_node, g);
686+
// Default side for pin in case none can be found
687+
e_side pin_side = e_side::TOP;
688+
if (!prev_node_inter_cluster && inode_inter_cluster) {
689+
// draw intra-cluster pin to inter-cluster pin
690+
// node i + 1 is the channel node
691+
if (i + 1 < rr_nodes_to_draw.size()) {
692+
pin_side = get_pin_side(inode, rr_nodes_to_draw[i + 1]);
693+
}
694+
695+
draw_intra_cluster_pin_to_pin(prev_node, inode, FROM_INTRA_CLUSTER_TO_INTER_CLUSTER, pin_side, g);
696+
continue;
697+
}
698+
699+
if (prev_node_inter_cluster && !inode_inter_cluster) {
700+
// draw inter-cluster pin to intra-cluster pin
701+
// node i - 2 is the channel node
702+
if (i >= 2) {
703+
pin_side = get_pin_side(prev_node, rr_nodes_to_draw[i - 2]);
704+
}
705+
706+
draw_intra_cluster_pin_to_pin(inode, prev_node, FROM_INTER_CLUSTER_TO_INTRA_CLUSTER, pin_side, g);
688707
continue;
689708
}
690709

vpr/src/draw/draw_rr_edges.cpp

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
205205
}
206206
}
207207

208-
void draw_chanx_to_chany_edge(RRNodeId chanx_node, RRNodeId chany_node, enum e_edge_dir edge_dir, short switch_type, ezgl::renderer* g) {
208+
void draw_chanx_to_chany_edge(RRNodeId chanx_node, RRNodeId chany_node, enum e_chan_edge_dir edge_dir, short switch_type, ezgl::renderer* g) {
209209
t_draw_state* draw_state = get_draw_state_vars();
210210
t_draw_coords* draw_coords = get_draw_coords_vars();
211211
auto& device_ctx = g_vpr_ctx.device();
@@ -300,44 +300,33 @@ void draw_intra_cluster_edge(RRNodeId inode, RRNodeId prev_node, ezgl::renderer*
300300
draw_triangle_along_line(g, triangle_coord_x, triangle_coord_y, prev_coord.x, icoord.x, prev_coord.y, icoord.y);
301301
}
302302

303-
void draw_intra_cluster_pin_to_pin(RRNodeId inode, RRNodeId prev_node, ezgl::renderer* g) {
303+
void draw_intra_cluster_pin_to_pin(RRNodeId intra_cluster_node, RRNodeId inter_cluster_node, e_pin_edge_dir pin_edge_dir, e_side pin_side, ezgl::renderer* g) {
304304
t_draw_state* draw_state = get_draw_state_vars();
305305
t_draw_coords* draw_coords = get_draw_coords_vars();
306306

307307
if (!draw_state->is_flat) {
308308
return;
309309
}
310310

311-
const auto& rr_graph = g_vpr_ctx.device().rr_graph;
311+
// determine the location of the pins
312+
float inter_cluster_x, inter_cluster_y;
313+
ezgl::point2d intra_cluster_coord;
312314

313-
ezgl::point2d prev_coord, icoord;
314-
float temp_x, temp_y; // temporary variables to hold coordinates to cast into ezgl::point2d
315-
316-
// get the location of the nodes based on whether inode is an inter-cluster or intra-cluster pin.
317-
if (!is_inter_cluster_node(rr_graph, inode)) {
315+
draw_get_rr_pin_coords(inter_cluster_node, &inter_cluster_x, &inter_cluster_y, pin_side);
318316

319-
auto [blk_id, pin_id] = get_rr_node_cluster_blk_id_pb_graph_pin(inode);
320-
icoord = draw_coords->get_absolute_pin_location(blk_id, pin_id);
317+
auto [blk_id, pin_id] = get_rr_node_cluster_blk_id_pb_graph_pin(intra_cluster_node);
318+
intra_cluster_coord = draw_coords->get_absolute_pin_location(blk_id, pin_id);
321319

322-
for (const e_side& pin_side : TOTAL_2D_SIDES) {
323-
if (!rr_graph.is_node_on_specific_side(RRNodeId(prev_node), pin_side)) {
324-
continue;
325-
}
326-
draw_get_rr_pin_coords(prev_node, &temp_x, &temp_y, pin_side);
327-
prev_coord = {temp_x, temp_y};
328-
}
320+
// determine which coord is first based on the pin edge direction
321+
ezgl::point2d prev_coord, icoord;
322+
if (pin_edge_dir == FROM_INTRA_CLUSTER_TO_INTER_CLUSTER) {
323+
prev_coord = intra_cluster_coord;
324+
icoord = {inter_cluster_x, inter_cluster_y};
325+
} else if (pin_edge_dir == FROM_INTER_CLUSTER_TO_INTRA_CLUSTER) {
326+
prev_coord = {inter_cluster_x, inter_cluster_y};
327+
icoord = intra_cluster_coord;
329328
} else {
330-
331-
auto [prev_blk_id, prev_pin_id] = get_rr_node_cluster_blk_id_pb_graph_pin(prev_node);
332-
prev_coord = draw_coords->get_absolute_pin_location(prev_blk_id, prev_pin_id);
333-
334-
for (const e_side& pin_side : TOTAL_2D_SIDES) {
335-
if (!rr_graph.is_node_on_specific_side(RRNodeId(inode), pin_side)) {
336-
continue;
337-
}
338-
draw_get_rr_pin_coords(inode, &temp_x, &temp_y, pin_side);
339-
icoord = {temp_x, temp_y};
340-
}
329+
VPR_ERROR(VPR_ERROR_DRAW, "Invalid pin edge direction: %d", pin_edge_dir);
341330
}
342331

343332
g->draw_line(prev_coord, icoord);
@@ -433,14 +422,8 @@ void draw_source_to_pin(RRNodeId source_node, RRNodeId opin_node, ezgl::renderer
433422
}
434423
}
435424

436-
void draw_pin_to_chan_edge(RRNodeId pin_node, RRNodeId chan_node, ezgl::renderer* g) {
437-
/* This routine draws an edge from the pin_node to the chan_node (CHANX or *
438-
* CHANY). The connection is made to the nearest end of the track instead *
439-
* of perpendicular to the track to symbolize a single-drive connection. */
440-
441-
/* TODO: Fix this for global routing, currently for detailed only */
425+
e_side get_pin_side(RRNodeId pin_node, RRNodeId chan_node) {
442426

443-
t_draw_coords* draw_coords = get_draw_coords_vars();
444427
auto& device_ctx = g_vpr_ctx.device();
445428
const auto& rr_graph = device_ctx.rr_graph;
446429

@@ -453,7 +436,6 @@ void draw_pin_to_chan_edge(RRNodeId pin_node, RRNodeId chan_node, ezgl::renderer
453436
int width_offset = device_ctx.grid.get_width_offset(tile_loc);
454437
int height_offset = device_ctx.grid.get_height_offset(tile_loc);
455438

456-
float x1 = 0, y1 = 0;
457439
/* If there is only one side, no need for the following inference!!!
458440
* When a node may have multiple sides,
459441
* we lack direct information about which side of the node drives the channel node
@@ -521,6 +503,30 @@ void draw_pin_to_chan_edge(RRNodeId pin_node, RRNodeId chan_node, ezgl::renderer
521503
/* Sanity check */
522504
VTR_ASSERT(NUM_2D_SIDES != pin_side);
523505

506+
return pin_side;
507+
}
508+
509+
void draw_pin_to_chan_edge(RRNodeId pin_node, RRNodeId chan_node, ezgl::renderer* g) {
510+
/* This routine draws an edge from the pin_node to the chan_node (CHANX or *
511+
* CHANY). The connection is made to the nearest end of the track instead *
512+
* of perpendicular to the track to symbolize a single-drive connection. */
513+
514+
/* TODO: Fix this for global routing, currently for detailed only */
515+
516+
t_draw_coords* draw_coords = get_draw_coords_vars();
517+
auto& device_ctx = g_vpr_ctx.device();
518+
const auto& rr_graph = device_ctx.rr_graph;
519+
520+
t_physical_tile_loc tile_loc = {
521+
rr_graph.node_xlow(pin_node),
522+
rr_graph.node_ylow(pin_node),
523+
rr_graph.node_layer(pin_node)};
524+
525+
const auto& grid_type = device_ctx.grid.get_physical_type(tile_loc);
526+
const e_rr_type channel_type = rr_graph.node_type(chan_node);
527+
e_side pin_side = get_pin_side(pin_node, chan_node);
528+
529+
float x1 = 0, y1 = 0;
524530
/* Now we determine which side to be used, calculate the offset for the pin to be drawn
525531
* - For the pin locates above/right to the grid (at the top/right side),
526532
* a positive offset (+ve) is required

vpr/src/draw/draw_rr_edges.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
3535
* @param switch_type The type of switch used for the connection
3636
* @param g The ezgl renderer
3737
*/
38-
void draw_chanx_to_chany_edge(RRNodeId chanx_node, RRNodeId chany_node, enum e_edge_dir edge_dir, short switch_type, ezgl::renderer* g);
38+
void draw_chanx_to_chany_edge(RRNodeId chanx_node, RRNodeId chany_node, enum e_chan_edge_dir edge_dir, short switch_type, ezgl::renderer* g);
3939

4040
/**
41-
* @brief Draws the edge between an intra-cluster pin and an inter-cluster pin when flat routing is enabled. It does not matter whether prev_node is the intra-cluster pin or whether inode is the intra-cluster pin.
42-
* @param inode The current node to draw to
43-
* @param prev_node The previous node to draw from
41+
* @brief Draws the edge between an intra-cluster pin and an inter-cluster pin when flat routing is enabled.
42+
* @param intra_cluster_node The intra-cluster pin node
43+
* @param inter_cluster_node The inter-cluster pin node
44+
* @param pin_edge_dir The direction of the edge, FROM_INTER_CLUSTER_TO_INTRA_CLUSTER or FROM_INTRA_CLUSTER_TO_INTER_CLUSTER
45+
* @param pin_side The side of the inter-cluster pin (e.g. TOP, RIGHT, BOTTOM, LEFT)
4446
* @param g The ezgl renderer
4547
*/
46-
void draw_intra_cluster_pin_to_pin(RRNodeId inode, RRNodeId prev_node, ezgl::renderer* g);
48+
void draw_intra_cluster_pin_to_pin(RRNodeId intra_cluster_node, RRNodeId inter_cluster_node, e_pin_edge_dir pin_edge_dir, e_side pin_side, ezgl::renderer* g);
4749
/**
4850
* @brief Draws the edge between two intra-cluster pins when flat routing is enabled.
4951
* @param inode The current node to draw to
@@ -61,6 +63,13 @@ void draw_pin_to_pin(RRNodeId opin, RRNodeId ipin, ezgl::renderer* g);
6163
void draw_pin_to_sink(RRNodeId ipin_node, RRNodeId sink_node, ezgl::renderer* g);
6264
void draw_source_to_pin(RRNodeId source_node, RRNodeId opin_node, ezgl::renderer* g);
6365

66+
/**
67+
* @brief Determines the side of clb, the inter-cluster pin is located on based on the channel node.
68+
* @param pin_node The inter-cluster pin node
69+
* @param chan_node The channel node (CHANX or CHANY) that the pin is connected to
70+
* @return The side of the clb that the pin is located on (e.g. TOP, RIGHT, BOTTOM, LEFT)
71+
*/
72+
e_side get_pin_side(RRNodeId pin_node, RRNodeId chan_node);
6473
/**
6574
* @brief Draws an edge from a inter-cluster pin node to a channel node (CHANX or CHANY).
6675
*/

vpr/src/draw/draw_types.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,18 @@ enum e_draw_net_type {
109109
ALL_NETS,
110110
HIGHLIGHTED
111111
};
112-
113-
/* Chanx to chany or vice versa? */
114-
enum e_edge_dir {
112+
/// Chanx to chany or vice versa?
113+
enum e_chan_edge_dir {
115114
FROM_X_TO_Y,
116115
FROM_Y_TO_X
117116
};
118117

118+
/// From inter-cluster pin to intra-cluster pin or vice versa?
119+
enum e_pin_edge_dir {
120+
FROM_INTER_CLUSTER_TO_INTRA_CLUSTER,
121+
FROM_INTRA_CLUSTER_TO_INTER_CLUSTER
122+
};
123+
119124
/*
120125
* Defines the type of drawings that can be generated for the NoC.
121126
* DRAW_NO_NOC -> user did not select the option to draw the NoC

vpr/src/draw/intra_logic_block.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int draw_internal_find_max_lvl(const t_pb_type& pb_type) {
253253
static int get_num_child_blocks(const t_mode& mode) {
254254
// not all child_pb_types have the same number of physical blocks, so we have to manually loop through and count the physical blocks
255255
int num_blocks = 0;
256-
for (int j=0;j<mode.num_pb_type_children;++j) {
256+
for (int j = 0; j < mode.num_pb_type_children; ++j) {
257257
num_blocks += mode.pb_type_children[j].num_pb;
258258
}
259259
return num_blocks;
@@ -284,9 +284,9 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
284284
// Find the number of instances for each child pb_type.
285285
int num_pb = mode.pb_type_children[j].num_pb;
286286

287-
// Determine how we want to arrange the sub-blocks in the parent block.
288-
// We want the blocks to be squarish, and not too wide or too tall.
289-
// In other words, we want the number of rows to be as close to the number of columns as possible such that
287+
// Determine how we want to arrange the sub-blocks in the parent block.
288+
// We want the blocks to be squarish, and not too wide or too tall.
289+
// In other words, we want the number of rows to be as close to the number of columns as possible such that
290290
// num_rows * num_columns = num_blocks.
291291
// first, determine the "middle" factor for the number of columns
292292
int num_columns = 1;
@@ -317,7 +317,7 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
317317
draw_internal_load_coords(type_descrip_index,
318318
&pb_graph_node->child_pb_graph_nodes[i][j][k],
319319
blk_width, blk_height);
320-
320+
321321
blk_num++;
322322
}
323323
}

0 commit comments

Comments
 (0)