Skip to content

Commit ea61183

Browse files
committed
updated comments and fixed block drawing issue
1 parent 4d5a522 commit ea61183

File tree

4 files changed

+44
-31
lines changed

4 files changed

+44
-31
lines changed

vpr/src/draw/draw_rr_edges.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
3838
void draw_chanx_to_chany_edge(RRNodeId chanx_node, RRNodeId chany_node, enum e_edge_dir edge_dir, short switch_type, ezgl::renderer* g);
3939

4040
/**
41-
* @brief Draws the edge between an intra-cluster pin and a 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.
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.
4242
* @param inode The current node to draw to
4343
* @param prev_node The previous node to draw from
4444
* @param g The ezgl renderer

vpr/src/draw/intra_logic_block.cpp

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "draw.h"
3535
#include "draw_triangle.h"
3636

37+
// Vertical padding (as a fraction of tile height) added to leave space for text inside internal logic blocks
3738
constexpr float FRACTION_TEXT_PADDING = 0.01;
3839

3940
/************************* Subroutines local to this file. *******************************/
@@ -54,7 +55,15 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
5455
*/
5556
static int draw_internal_find_max_lvl(const t_pb_type& pb_type);
5657
/**
57-
* @brief A helper function for draw_internal_load_coords. Calculates the coordinates of a internal block and stores its bounding box inside global variables. The calculated width and height of the block are also assigned to the pointers blk_width and blk_height.
58+
* @brief A helper function to calculate the number of child blocks for a given t_mode.
59+
* @param mode The mode of the parent pb_type.
60+
* @return The number of child blocks for the given t_mode.
61+
*/
62+
static int get_num_child_blocks(const t_mode& mode);
63+
/**
64+
* @brief A helper function for draw_internal_load_coords.
65+
* Calculates the coordinates of a internal block and stores its bounding box inside global variables.
66+
* The calculated width and height of the block are also assigned to the pointers blk_width and blk_height.
5867
* @param type_descrip_index The index of the logical block type.
5968
* @param pb_graph_node The pb_graph_node of the logical block type.
6069
* @param blk_num Each logical block type has num_modes * num_pb_type_children sub-blocks. blk_num is the index of the sub-block within the logical block type.
@@ -241,6 +250,15 @@ static int draw_internal_find_max_lvl(const t_pb_type& pb_type) {
241250
return max_levels;
242251
}
243252

253+
static int get_num_child_blocks(const t_mode& mode) {
254+
// not all child_pb_types have the same number of physical blocks, so we have to manually loop through and count the physical blocks
255+
int num_blocks = 0;
256+
for (int j=0;j<mode.num_pb_type_children;++j) {
257+
num_blocks += mode.pb_type_children[j].num_pb;
258+
}
259+
return num_blocks;
260+
}
261+
244262
/* Helper function for initializing bounding box values for each sub-block. This function
245263
* traverses through the pb_graph for a descriptor_type (given by type_descrip_index), and
246264
* calls helper function to compute bounding box values.
@@ -259,16 +277,18 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
259277
for (int i = 0; i < num_modes; ++i) {
260278
t_mode mode = pb_type->modes[i];
261279
int num_children = mode.num_pb_type_children;
280+
int num_blocks = get_num_child_blocks(mode);
281+
int blk_num = 0;
262282

263283
for (int j = 0; j < num_children; ++j) {
264-
/* Find the number of instances for each child pb_type. */
284+
// Find the number of instances for each child pb_type.
265285
int num_pb = mode.pb_type_children[j].num_pb;
266286

267-
// Determine how we want to arrange the sub-blocks in the parent block. We want the blocks to be squarish, and not too wide or too tall. In other words, we want the number of rows to be as close to the number of columns as possible such that num_rows * num_columns = num_blocks.
268-
269-
int num_blocks = num_pb * num_children;
270-
271-
// determine central factor for the number of columns
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
290+
// num_rows * num_columns = num_blocks.
291+
// first, determine the "middle" factor for the number of columns
272292
int num_columns = 1;
273293
for (int k = 1; k * k <= num_blocks; ++k) {
274294
if (num_blocks % k == 0) {
@@ -286,19 +306,19 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
286306

287307
for (int k = 0; k < num_pb; ++k) {
288308

289-
int blk_num = j * num_pb + k;
290-
291-
/* Compute bound box for block. Don't call if pb_type is root-level pb. */
309+
// Compute bound box for block. Don't call if pb_type is root-level pb.
292310
draw_internal_calc_coords(type_descrip_index,
293311
&pb_graph_node->child_pb_graph_nodes[i][j][k],
294312
blk_num, num_columns, num_rows,
295313
parent_width, parent_height,
296314
&blk_width, &blk_height);
297315

298-
/* Traverse to next level in the pb_graph */
316+
// Traverse to next level in the pb_graph
299317
draw_internal_load_coords(type_descrip_index,
300318
&pb_graph_node->child_pb_graph_nodes[i][j][k],
301319
blk_width, blk_height);
320+
321+
blk_num++;
302322
}
303323
}
304324
}
@@ -317,7 +337,6 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
317337

318338
constexpr float FRACTION_PARENT_PADDING = 0.005;
319339
constexpr float FRACTION_CHILD_MARGIN = 0.003;
320-
constexpr int MIN_WIDTH_HEIGHT_RATIO = 2;
321340

322341
float abs_parent_padding = tile_width * FRACTION_PARENT_PADDING;
323342
float abs_text_padding = tile_width * FRACTION_TEXT_PADDING;
@@ -333,10 +352,6 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
333352
float parent_drawing_width = parent_width - 2 * abs_parent_padding;
334353
float parent_drawing_height = parent_height - 2 * abs_parent_padding - abs_text_padding;
335354

336-
if (parent_drawing_height > MIN_WIDTH_HEIGHT_RATIO * parent_drawing_width) {
337-
parent_drawing_height /= 2;
338-
}
339-
340355
int x_index = blk_num % num_columns;
341356
int y_index = blk_num / num_columns;
342357

@@ -348,7 +363,7 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
348363
abs_child_margin = 0;
349364
}
350365

351-
/* The starting point to draw the physical block. */
366+
// The starting point to draw the physical block.
352367
double left = child_width * x_index + abs_parent_padding + abs_child_margin;
353368
double bot = child_height * y_index + abs_parent_padding + abs_child_margin;
354369

@@ -389,7 +404,7 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
389404
return;
390405
}
391406

392-
/// first draw box ///
407+
// first draw box
393408

394409
if (pb->name != nullptr) {
395410
// If block is used, draw it in colour with solid border.
@@ -419,20 +434,20 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
419434
g->draw_rectangle(abs_bbox);
420435
}
421436

422-
/// then draw text ///
423-
437+
// draw text for each physical block.
438+
// format: <block_type_name>:<mode_name>[<placement_index>]
424439
std::string pb_type_name(pb_type->name);
425440

426-
pb_type_name += "[" + std::to_string(pb->pb_graph_node->placement_index) + "]";
427-
428-
//get the mode of the physical block
441+
// get the mode of the physical block
429442
if (!pb->is_primitive()) {
430443
// primitives have no modes
431444
std::string mode_name = pb->pb_graph_node->pb_type->modes[pb->mode].name;
432-
pb_type_name += "[" + mode_name + "]";
445+
pb_type_name += ":" + mode_name;
433446
}
434447

435-
g->set_font_size(16); // note: calc_text_xbound(...) assumes this is 16
448+
pb_type_name += "[" + std::to_string(pb->pb_graph_node->placement_index) + "]";
449+
450+
g->set_font_size(16);
436451
if (pb_type->depth == draw_state->show_blk_internal || pb->child_pbs == nullptr) {
437452
// If this pb is at the lowest displayed level, or has no more children, then
438453
// label it in the center with its type and name
@@ -458,7 +473,7 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
458473
}
459474
}
460475

461-
/// now recurse on the child pbs. ///
476+
// now recurse on the child pbs.
462477

463478
// return if no children, or this is an unusused pb,
464479
// or if going down will be too far down (this one is redundant, but for optimazition)

vpr/src/util/vpr_utils.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ AtomPinId find_atom_pin(ClusterBlockId blk_id, const t_pb_graph_pin* pb_gpin) {
865865
AtomNetId atom_net = cluster_ctx.clb_nlist.block_pb(blk_id)->pb_route[pb_route_id].atom_net_id;
866866
VTR_ASSERT(atom_net);
867867

868-
AtomPinId atom_pin;
868+
AtomPinId atom_pin = AtomPinId::INVALID();
869869

870870
//Look through all the pins on this net, looking for the matching pin
871871
for (AtomPinId pin : atom_ctx.netlist().net_pins(atom_net)) {
@@ -878,8 +878,6 @@ AtomPinId find_atom_pin(ClusterBlockId blk_id, const t_pb_graph_pin* pb_gpin) {
878878
}
879879
}
880880

881-
VTR_ASSERT(atom_pin);
882-
883881
return atom_pin;
884882
}
885883

vpr/src/util/vpr_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const t_pb_graph_pin* find_pb_graph_pin(const t_pb_graph_node* pb_gnode, const s
167167
const t_pb_graph_pin* find_pb_graph_pin(const AtomNetlist& netlist, const AtomPBBimap& atom_pb_lookup, const AtomPinId pin_id);
168168

169169
/**
170-
* @brief Retrieves the atom pin associated with a specific CLB and pb_graph_pin. Warning: Not all pb_graph_pins are associated with an atom pin! Only pb_graph_pins on primatives are associated with an AtomPinId.
170+
* @brief Retrieves the atom pin associated with a specific CLB and pb_graph_pin. Warning: Not all pb_graph_pins are associated with an atom pin! Only pb_graph_pins on primatives are associated with an AtomPinId. Returns AtomPinId::INVALID() if no atom pin is found.
171171
*/
172172
AtomPinId find_atom_pin(ClusterBlockId blk_id, const t_pb_graph_pin* pb_gpin);
173173

0 commit comments

Comments
 (0)