@@ -84,14 +84,6 @@ static void add_block_to_bb(const t_physical_tile_loc& new_pin_loc,
84
84
t_2D_bb& bb_edge_new,
85
85
t_2D_bb& bb_coord_new);
86
86
87
- /* *
88
- * @brief Given the 3D BB, calculate the wire-length estimate of the net
89
- * @param net_id ID of the net which wirelength estimate is requested
90
- * @param bb Bounding box of the net
91
- * @return Wirelength estimate of the net
92
- */
93
- static double get_net_wirelength_estimate (ClusterNetId net_id, const t_bb& bb);
94
-
95
87
/* *
96
88
* @brief To get the wirelength cost/est, BB perimeter is multiplied by a factor to approximately correct for the half-perimeter
97
89
* bounding box wirelength's underestimate of wiring for nets with fanout greater than 2.
@@ -275,7 +267,7 @@ std::pair<double, double> NetCostHandler::comp_cube_bb_cost_(e_cost_methods meth
275
267
net_cost_[net_id] = get_net_cube_bb_cost_ (net_id, /* use_ts=*/ false );
276
268
cost += net_cost_[net_id];
277
269
if (method == e_cost_methods::CHECK) {
278
- expected_wirelength += get_net_wirelength_estimate (net_id, place_move_ctx. bb_coords [net_id] );
270
+ expected_wirelength += get_net_wirelength_estimate_ (net_id);
279
271
}
280
272
}
281
273
}
@@ -1419,7 +1411,9 @@ double NetCostHandler::get_net_per_layer_bb_cost_(ClusterNetId net_id, bool use_
1419
1411
return ncost;
1420
1412
}
1421
1413
1422
- static double get_net_wirelength_estimate (ClusterNetId net_id, const t_bb& bb) {
1414
+ double NetCostHandler::get_net_wirelength_estimate_ (ClusterNetId net_id) const {
1415
+ const auto & move_ctx = placer_state_.move ();
1416
+ const t_bb& bb = move_ctx.bb_coords [net_id];
1423
1417
auto & cluster_ctx = g_vpr_ctx.clustering ();
1424
1418
1425
1419
double crossing = wirelength_crossing_count (cluster_ctx.clb_nlist .net_pins (net_id).size ());
@@ -1438,23 +1432,27 @@ static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb) {
1438
1432
return ncost;
1439
1433
}
1440
1434
1441
- double NetCostHandler::get_net_wirelength_from_layer_bb_ (ClusterNetId net_id) {
1435
+ double NetCostHandler::get_net_wirelength_from_layer_bb_ (ClusterNetId net_id) const {
1442
1436
/* WMF: Finds the estimate of wirelength due to one net by looking at *
1443
1437
* its coordinate bounding box. */
1444
1438
1445
1439
const auto & move_ctx = placer_state_.move ();
1446
1440
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)];
1441
+ const vtr::NdMatrixProxy< int , 1 > net_layer_pin_sink_count = move_ctx.num_sink_pin_layer [size_t (net_id)];
1448
1442
1449
1443
double ncost = 0 .;
1450
- const int num_layers = g_vpr_ctx.device ().grid .get_num_layers ();
1444
+ VTR_ASSERT_SAFE ( static_cast < int >(bb. size ()) == g_vpr_ctx.device ().grid .get_num_layers () );
1451
1445
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 ) {
1446
+ for (size_t layer_num = 0 ; layer_num < bb. size () ; layer_num++) {
1447
+ VTR_ASSERT_SAFE (net_layer_pin_sink_count [layer_num] != OPEN);
1448
+ if (net_layer_pin_sink_count [layer_num] == 0 ) {
1455
1449
continue ;
1456
1450
}
1457
- double crossing = wirelength_crossing_count (layer_pin_sink_count[layer_num] + 1 );
1451
+
1452
+ // The reason we add 1 to the number of sink pins is because when per-layer bounding box is used,
1453
+ // we want to get the estimated wirelength of the given layer assuming that the source pin is
1454
+ // also on that layer
1455
+ double crossing = wirelength_crossing_count (net_layer_pin_sink_count[layer_num] + 1 );
1458
1456
1459
1457
/* Could insert a check for xmin == xmax. In that case, assume *
1460
1458
* connection will be made with no bends and hence no x-cost. *
@@ -1627,12 +1625,15 @@ void NetCostHandler::recompute_costs_from_scratch(const PlaceDelayModel* delay_m
1627
1625
1628
1626
double NetCostHandler::get_total_wirelength_estimate () const {
1629
1627
const auto & clb_nlist = g_vpr_ctx.clustering ().clb_nlist ;
1630
- const auto & bb_coords = placer_state_.move ().bb_coords ;
1631
1628
1632
1629
double estimated_wirelength = 0.0 ;
1633
1630
for (ClusterNetId net_id : clb_nlist.nets ()) { /* for each net ... */
1634
1631
if (!clb_nlist.net_is_ignored (net_id)) { /* Do only if not ignored. */
1635
- estimated_wirelength += get_net_wirelength_estimate (net_id, bb_coords[net_id]);
1632
+ if (cube_bb_) {
1633
+ estimated_wirelength += get_net_wirelength_estimate_ (net_id);
1634
+ } else {
1635
+ estimated_wirelength += get_net_wirelength_from_layer_bb_ (net_id);
1636
+ }
1636
1637
}
1637
1638
}
1638
1639
0 commit comments