@@ -472,6 +472,7 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
472
472
find_layer = true ;
473
473
}
474
474
std::vector<ClusterBlockId> connected_blocks_to_update;
475
+ std::unordered_set<ClusterBlockId> seen_blocks;
475
476
476
477
// iterate over the from block pins
477
478
for (ClusterPinId pin_id : cluster_ctx.clb_nlist .block_pins (head_blk)) {
@@ -510,6 +511,7 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
510
511
VTR_ASSERT (tile_loc.layer_num != OPEN);
511
512
layer_count[tile_loc.layer_num ]++;
512
513
}
514
+ seen_blocks.insert (cluster_ctx.clb_nlist .pin_block (sink_pin_id));
513
515
acc_x += tile_loc.x ;
514
516
acc_y += tile_loc.y ;
515
517
acc_weight++;
@@ -530,12 +532,31 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
530
532
VTR_ASSERT (tile_loc.layer_num != OPEN);
531
533
layer_count[tile_loc.layer_num ]++;
532
534
}
535
+ seen_blocks.insert (cluster_ctx.clb_nlist .pin_block (source_pin));
533
536
acc_x += tile_loc.x ;
534
537
acc_y += tile_loc.y ;
535
538
acc_weight++;
536
539
}
537
540
}
538
541
542
+ if (is_io_type (cluster_ctx.clb_nlist .block_type (head_blk)) && acc_weight != 0 ) {
543
+ for (const auto & block : cluster_ctx.clb_nlist .blocks ()) {
544
+ if (seen_blocks.find (block) == seen_blocks.end ()) {
545
+ continue ;
546
+ }
547
+ if (block == head_blk) {
548
+ continue ;
549
+ }
550
+ if (is_io_type (cluster_ctx.clb_nlist .block_type (block))) {
551
+ if (is_block_placed (block, block_locs)) {
552
+ acc_x += block_locs[block].loc .x ;
553
+ acc_y += block_locs[block].loc .y ;
554
+ acc_weight++;
555
+ }
556
+ }
557
+ }
558
+ }
559
+
539
560
// Calculate the centroid location
540
561
if (acc_weight > 0 ) {
541
562
centroid.x = acc_x / acc_weight;
0 commit comments