Skip to content

Commit af5659d

Browse files
committed
[vpr][place][net_cost] fix num_inter_dir_conn corner cases
1 parent 01b9cd6 commit af5659d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,16 +1604,29 @@ double NetCostHandler::get_net_wirelength_from_layer_bb_(ClusterNetId net_id) {
16041604
return ncost;
16051605
}
16061606

1607-
float NetCostHandler::get_chanz_cost_factor(const t_bb& bounding_box, float place_cost_exp) {
1607+
float NetCostHandler::get_chanz_cost_factor(const t_bb& bounding_box) {
1608+
float place_cost_exp = placer_opts_.place_cost_exp;
16081609
int x_high = bounding_box.xmax;
16091610
int x_low = bounding_box.xmin;
16101611
int y_high = bounding_box.ymax;
16111612
int y_low = bounding_box.ymin;
16121613

1613-
int num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \
1614-
acc_tile_num_inter_die_conn_[x_low-1][y_high] - \
1615-
acc_tile_num_inter_die_conn_[x_high][y_low-1] + \
1616-
acc_tile_num_inter_die_conn_[x_low-1][y_low-1];
1614+
int num_inter_dir_conn;
1615+
1616+
if (x_low == 0 && y_low == 0) {
1617+
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high];
1618+
} else if (x_low == 0) {
1619+
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \
1620+
acc_tile_num_inter_die_conn_[x_high][y_low-1];
1621+
} else if (y_low == 0) {
1622+
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \
1623+
acc_tile_num_inter_die_conn_[x_low-1][y_high];
1624+
} else {
1625+
num_inter_dir_conn = acc_tile_num_inter_die_conn_[x_high][y_high] - \
1626+
acc_tile_num_inter_die_conn_[x_low-1][y_high] - \
1627+
acc_tile_num_inter_die_conn_[x_high][y_low-1] + \
1628+
acc_tile_num_inter_die_conn_[x_low-1][y_low-1];
1629+
}
16171630

16181631
int bb_num_tiles = (x_high - x_low + 1) * (y_high - y_low + 1);
16191632

@@ -1623,7 +1636,6 @@ float NetCostHandler::get_chanz_cost_factor(const t_bb& bounding_box, float plac
16231636
} else {
16241637
z_cost_factor = bb_num_tiles / static_cast<float>(num_inter_dir_conn);
16251638
z_cost_factor = pow((double)z_cost_factor, (double)place_cost_exp);
1626-
16271639
}
16281640

16291641
return z_cost_factor;

0 commit comments

Comments
 (0)