Skip to content

Commit de56731

Browse files
committed
clip HF BB by original BB
1 parent dabeec3 commit de56731

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

vpr/src/route/connection_router.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -964,16 +964,21 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
964964
}
965965
}
966966

967-
static t_bb adjust_highfanout_bounding_box(t_bb highfanout_bb) {
968-
t_bb bb = highfanout_bb;
967+
/* Expand bb by inode's extents and clip against net_bb */
968+
inline void expand_highfanout_bounding_box(t_bb& bb, const t_bb& net_bb, RRNodeId inode, const RRGraphView* rr_graph) {
969+
bb.xmin = std::max<int>(net_bb.xmin, std::min<int>(bb.xmin, rr_graph->node_xlow(inode)));
970+
bb.ymin = std::max<int>(net_bb.ymin, std::min<int>(bb.ymin, rr_graph->node_ylow(inode)));
971+
bb.xmax = std::min<int>(net_bb.xmax, std::max<int>(bb.xmax, rr_graph->node_xhigh(inode)));
972+
bb.ymax = std::min<int>(net_bb.ymax, std::max<int>(bb.ymax, rr_graph->node_yhigh(inode)));
973+
}
969974

975+
/* Expand bb by HIGH_FANOUT_BB_FAC and clip against net_bb */
976+
inline void adjust_highfanout_bounding_box(t_bb& bb, const t_bb& net_bb) {
970977
constexpr int HIGH_FANOUT_BB_FAC = 3;
971-
bb.xmin -= HIGH_FANOUT_BB_FAC;
972-
bb.ymin -= HIGH_FANOUT_BB_FAC;
973-
bb.xmax += HIGH_FANOUT_BB_FAC;
974-
bb.ymax += HIGH_FANOUT_BB_FAC;
975-
976-
return bb;
978+
bb.xmin = std::max<int>(net_bb.xmin, bb.xmin - HIGH_FANOUT_BB_FAC);
979+
bb.ymin = std::max<int>(net_bb.ymin, bb.ymin - HIGH_FANOUT_BB_FAC);
980+
bb.xmax = std::min<int>(net_bb.xmax, bb.xmax + HIGH_FANOUT_BB_FAC);
981+
bb.ymax = std::min<int>(net_bb.ymax, bb.ymax + HIGH_FANOUT_BB_FAC);
977982
}
978983

979984
template<typename Heap>
@@ -1032,11 +1037,8 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10321037
// Put the node onto the heap
10331038
add_route_tree_node_to_heap(rt_node, target_node, cost_params, true);
10341039

1035-
// Update Bounding Box
1036-
highfanout_bb.xmin = std::min<int>(highfanout_bb.xmin, rr_graph_->node_xlow(rr_node_to_add));
1037-
highfanout_bb.ymin = std::min<int>(highfanout_bb.ymin, rr_graph_->node_ylow(rr_node_to_add));
1038-
highfanout_bb.xmax = std::max<int>(highfanout_bb.xmax, rr_graph_->node_xhigh(rr_node_to_add));
1039-
highfanout_bb.ymax = std::max<int>(highfanout_bb.ymax, rr_graph_->node_yhigh(rr_node_to_add));
1040+
// Expand HF BB to include the node (clip by original BB)
1041+
expand_highfanout_bounding_box(highfanout_bb, net_bounding_box, rr_node_to_add, rr_graph_);
10401042
if (is_flat_) {
10411043
if (rr_graph_->node_type(rr_node_to_add) == CHANY || rr_graph_->node_type(rr_node_to_add) == CHANX) {
10421044
chan_nodes_added++;
@@ -1062,15 +1064,14 @@ t_bb ConnectionRouter<Heap>::add_high_fanout_route_tree_to_heap(
10621064
if (done) break;
10631065
}
10641066

1065-
t_bb bounding_box = net_bounding_box;
10661067
if (nodes_added == 0) { //If the target bin, and it's surrounding bins were empty, just add the full route tree
10671068
add_route_tree_to_heap(rt_root, target_node, cost_params, true);
1069+
return net_bounding_box;
10681070
} else {
10691071
//We found nearby routing, replace original bounding box to be localized around that routing
1070-
bounding_box = adjust_highfanout_bounding_box(highfanout_bb);
1072+
adjust_highfanout_bounding_box(highfanout_bb, net_bounding_box);
1073+
return highfanout_bb;
10711074
}
1072-
1073-
return bounding_box;
10741075
}
10751076

10761077
std::unique_ptr<ConnectionRouterInterface> make_connection_router(e_heap_type heap_type,

vpr/test/test_connection_router.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <tuple>
22
#include "catch2/catch_test_macros.hpp"
33

4+
#include "route_net.h"
45
#include "rr_graph_fwd.h"
56
#include "vpr_api.h"
67
#include "vpr_signal_handler.h"
@@ -73,8 +74,7 @@ static float do_one_route(RRNodeId source_node,
7374
cost_params,
7475
bounding_box,
7576
router_stats,
76-
conn_params,
77-
true);
77+
conn_params);
7878

7979
// Default delay is infinity, which indicates that a route was not found.
8080
float delay = std::numeric_limits<float>::infinity();

0 commit comments

Comments
 (0)