Skip to content

Commit 885151a

Browse files
committed
updated intra logic block drawing
1 parent 718e85a commit 885151a

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

vpr/src/draw/draw_types.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ ezgl::rectangle t_draw_coords::get_absolute_pb_bbox(const ClusterBlockId clb_ind
151151
return result;
152152
}
153153

154+
ezgl::point2d t_draw_coords::get_absolute_pin_location( const ClusterBlockId clb_index,const t_pb_graph_pin* pb_graph_pin) {
155+
156+
t_pb_graph_node* pb_gnode = pb_graph_pin->parent_node;
157+
ezgl::rectangle pb_bbox = this->get_absolute_pb_bbox(clb_index, pb_gnode);
158+
int num_pins = pb_gnode->num_pins();
159+
// int pin_index =
160+
161+
162+
}
163+
154164
ezgl::rectangle t_draw_coords::get_absolute_clb_bbox(const ClusterBlockId clb_index, const t_logical_block_type_ptr block_type) {
155165
t_draw_state* draw_state = get_draw_state_vars();
156166
const auto& block_locs = draw_state->get_graphics_blk_loc_registry_ref().block_locs();

vpr/src/draw/intra_logic_block.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636

3737
/************************* Subroutines local to this file. *******************************/
3838

39-
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height);
39+
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height, float scale_factor);
4040
static int draw_internal_find_max_lvl(const t_pb_type& pb_type);
41-
static void draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height);
41+
static void draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height, float scale_factor);
4242
std::vector<AtomBlockId> collect_pb_atoms(const t_pb* pb);
4343
void collect_pb_atoms_recurr(const t_pb* pb, std::vector<AtomBlockId>& atoms);
4444
t_pb* highlight_sub_block_helper(const ClusterBlockId clb_index, t_pb* pb, const ezgl::point2d& local_pt, int max_depth);
@@ -130,7 +130,7 @@ void draw_internal_init_blk() {
130130

131131
clb_bbox = ezgl::rectangle(bot_left, top_right);
132132
draw_internal_load_coords(type_descriptor_index, pb_graph_head_node,
133-
clb_bbox.width(), clb_bbox.height());
133+
clb_bbox.width(), clb_bbox.height(), std::max(clb_bbox.width(), clb_bbox.height()));
134134

135135
/* Determine the max number of sub_block levels in the FPGA */
136136
draw_state->max_sub_blk_lvl = std::max(draw_internal_find_max_lvl(*type.pb_type),
@@ -218,7 +218,7 @@ static int draw_internal_find_max_lvl(const t_pb_type& pb_type) {
218218
* traverses through the pb_graph for a descriptor_type (given by type_descrip_index), and
219219
* calls helper function to compute bounding box values.
220220
*/
221-
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height) {
221+
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height, float scale_factor) {
222222
float blk_width = 0.;
223223
float blk_height = 0.;
224224

@@ -239,7 +239,7 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
239239

240240
int num_blocks = num_pb * num_children;
241241

242-
// determine an optimal number of columns (calculates central factor)
242+
// determine an optimal number of columns
243243
int num_columns = 1;
244244
for(int k = 1; k * k <= num_blocks; ++k) {
245245
if(num_blocks % k == 0) {
@@ -248,6 +248,11 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
248248
}
249249
int num_rows = num_blocks / num_columns;
250250

251+
const int MAX_WIDTH_HEIGHT_RATIO = 2;
252+
if(parent_width > parent_height * MAX_WIDTH_HEIGHT_RATIO){
253+
std::swap(num_columns, num_rows);
254+
}
255+
251256
for (int k = 0; k < num_pb; ++k) {
252257

253258
int num_block = j * num_pb + k;
@@ -257,12 +262,12 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
257262
&pb_graph_node->child_pb_graph_nodes[i][j][k],
258263
num_block, num_columns, num_rows,
259264
parent_width, parent_height,
260-
&blk_width, &blk_height);
265+
&blk_width, &blk_height, scale_factor);
261266

262267
/* Traverse to next level in the pb_graph */
263268
draw_internal_load_coords(type_descrip_index,
264269
&pb_graph_node->child_pb_graph_nodes[i][j][k],
265-
blk_width, blk_height);
270+
blk_width, blk_height, scale_factor);
266271
}
267272
}
268273
}
@@ -272,41 +277,41 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
272277
* are relative to the left and bottom corner of the parent block.
273278
*/
274279
static void
275-
draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height) {
280+
draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height, float scale_factor) {
276281

277282
// get the bbox for this pb type
278283
ezgl::rectangle& pb_bbox = get_draw_coords_vars()->blk_info.at(type_descrip_index).get_pb_bbox_ref(*pb_graph_node);
284+
279285

280-
const float FRACTION_PARENT_PADDING_X = 0.01;
281-
const float FRACTION_PARENT_PADDING_Y = 0.01;
286+
const float FRACTION_PARENT_PADDING = 0.005;
287+
const float FRACTION_CHILD_MARGIN = 0.003;
288+
const float FRACTION_TEXT_PADDING = 0.01;
289+
const int MIN_WIDTH_HEIGHT_RATIO = 2;
282290

283-
const float FRACTION_CHILD_MARGIN_X = 0.01;
284-
const float FRACTION_CHILD_MARGIN_Y = 0.01;
291+
float abs_parent_padding = scale_factor * FRACTION_PARENT_PADDING;
292+
float abs_text_padding = scale_factor * FRACTION_TEXT_PADDING;
285293

286294
/* Draw all child-level blocks in just most of the space inside their parent block. */
287-
float parent_drawing_width = parent_width * (1 - FRACTION_PARENT_PADDING_X * 2);
288-
float parent_drawing_height = parent_height * (1 - FRACTION_PARENT_PADDING_Y * 2);
295+
float parent_drawing_width = parent_width - 2* abs_parent_padding;
296+
float parent_drawing_height = parent_height - 2 * abs_parent_padding - abs_text_padding;
289297

290-
/* The left and bottom corner (inside the parent block) of the space to draw
291-
* child blocks.
292-
*/
293-
float sub_tile_x = parent_width * FRACTION_PARENT_PADDING_X;
294-
float sub_tile_y = parent_height * FRACTION_PARENT_PADDING_Y;
298+
if(parent_drawing_height > MIN_WIDTH_HEIGHT_RATIO * parent_drawing_width) {
299+
parent_drawing_height /= 2;
300+
}
295301

296302
int x_index = num_block % num_columns;
297303
int y_index = num_block / num_columns;
298304

299305
float child_width = parent_drawing_width / num_columns;
300306
float child_height = parent_drawing_height / num_rows;
301307

308+
float abs_child_margin = scale_factor * FRACTION_CHILD_MARGIN;
302309
/* The starting point to draw the physical block. */
303-
double left = child_width * x_index + sub_tile_x + FRACTION_CHILD_MARGIN_X * child_width;
304-
double bot = child_height * y_index + sub_tile_y + FRACTION_CHILD_MARGIN_Y * child_height;
310+
double left = child_width * x_index + abs_parent_padding + abs_child_margin;
311+
double bot = child_height * y_index + abs_parent_padding + abs_child_margin;
305312

306-
/* Leave some space between different pb_types. */
307-
child_width *= 1 - FRACTION_CHILD_MARGIN_X * 2;
308-
/* Leave some space between different instances of the same type. */
309-
child_height *= 1 - FRACTION_CHILD_MARGIN_Y * 2;
313+
child_width -= abs_child_margin * 2;
314+
child_height -= abs_child_margin * 2;
310315

311316
/* Endpoint for drawing the pb_type */
312317
double right = left + child_width;

0 commit comments

Comments
 (0)