@@ -92,6 +92,15 @@ static void add_block_to_bb(const t_physical_tile_loc& new_pin_loc,
92
92
*/
93
93
static double get_net_wirelength_estimate (ClusterNetId net_id, const t_bb& bb);
94
94
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
+
95
104
/* *
96
105
* @brief To get the wirelength cost/est, BB perimeter is multiplied by a factor to approximately correct for the half-perimeter
97
106
* 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) {
1438
1447
return ncost;
1439
1448
}
1440
1449
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 ) {
1442
1451
/* WMF: Finds the estimate of wirelength due to one net by looking at *
1443
1452
* its coordinate bounding box. */
1444
1453
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
-
1449
1454
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 () );
1451
1456
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 ) {
1455
1460
continue ;
1456
1461
}
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 );
1458
1467
1459
1468
/* Could insert a check for xmin == xmax. In that case, assume *
1460
1469
* connection will be made with no bends and hence no x-cost. *
0 commit comments