Skip to content

Commit 5f163bd

Browse files
committed
[vpr][place] make get_net_wirelength_from_layer_bb_ static function and update its parameters
1 parent 7ade605 commit 5f163bd

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ static void add_block_to_bb(const t_physical_tile_loc& new_pin_loc,
9292
*/
9393
static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb);
9494

95+
/**
96+
* @brief Given the per-layer BB, calculate the wire-length estimate of the net on each layer
97+
* and return the sum of the lengths
98+
* @param bb Per-layer BB of the net
99+
* @param net_layer_pin_sink_count Number of sink pins on each layer for the net
100+
* @return Wirelength estimate of the net
101+
*/
102+
static double get_net_wirelength_from_layer_bb_(const std::vector<t_2D_bb>& bb, const vtr::NdMatrixProxy<int, 1>& net_layer_pin_sink_count);
103+
95104
/**
96105
* @brief To get the wirelength cost/est, BB perimeter is multiplied by a factor to approximately correct for the half-perimeter
97106
* bounding box wirelength's underestimate of wiring for nets with fanout greater than 2.
@@ -1438,23 +1447,23 @@ static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb) {
14381447
return ncost;
14391448
}
14401449

1441-
double NetCostHandler::get_net_wirelength_from_layer_bb_(ClusterNetId net_id) {
1450+
static double get_net_wirelength_from_layer_bb_(const std::vector<t_2D_bb>& bb, const vtr::NdMatrixProxy<int, 1>& net_layer_pin_sink_count) {
14421451
/* WMF: Finds the estimate of wirelength due to one net by looking at *
14431452
* its coordinate bounding box. */
14441453

1445-
const auto& move_ctx = placer_state_.move();
1446-
const std::vector<t_2D_bb>& bb = move_ctx.layer_bb_coords[net_id];
1447-
const auto& layer_pin_sink_count = move_ctx.num_sink_pin_layer[size_t(net_id)];
1448-
14491454
double ncost = 0.;
1450-
const int num_layers = g_vpr_ctx.device().grid.get_num_layers();
1455+
VTR_ASSERT_SAFE(static_cast<int>(bb.size()) == g_vpr_ctx.device().grid.get_num_layers());
14511456

1452-
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
1453-
VTR_ASSERT_SAFE(layer_pin_sink_count[layer_num] != OPEN);
1454-
if (layer_pin_sink_count[layer_num] == 0) {
1457+
for (size_t layer_num = 0; layer_num < bb.size(); layer_num++) {
1458+
VTR_ASSERT_SAFE(net_layer_pin_sink_count[layer_num] != OPEN);
1459+
if (net_layer_pin_sink_count[layer_num] == 0) {
14551460
continue;
14561461
}
1457-
double crossing = wirelength_crossing_count(layer_pin_sink_count[layer_num] + 1);
1462+
1463+
// The reason we add 1 to the number of sink pins is because when per-layer bounding box is used,
1464+
// we want to get the estimated wirelength of the given layer assuming that the source pin is
1465+
// also on that layer
1466+
double crossing = wirelength_crossing_count(net_layer_pin_sink_count[layer_num] + 1);
14581467

14591468
/* Could insert a check for xmin == xmax. In that case, assume *
14601469
* connection will be made with no bends and hence no x-cost. *

0 commit comments

Comments
 (0)