diff options
author | David Shah <dave@ds0.me> | 2019-11-19 10:42:43 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2020-02-03 11:38:31 +0000 |
commit | 72f4721167c14024dc00a83f2d3c13380a34b6fe (patch) | |
tree | c2fe621718984ce3e00c540f123f836ee1ad83bf /common | |
parent | c21db8a0c1ea94fc042e77311840c15bb5703023 (diff) | |
download | nextpnr-72f4721167c14024dc00a83f2d3c13380a34b6fe.tar.gz nextpnr-72f4721167c14024dc00a83f2d3c13380a34b6fe.tar.bz2 nextpnr-72f4721167c14024dc00a83f2d3c13380a34b6fe.zip |
router2: Some simple partitioning
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r-- | common/router2.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/common/router2.cc b/common/router2.cc index 67c6dae2..d513a08c 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -710,10 +710,54 @@ struct Router2 } } + void partition_nets() + { + // Create a histogram of positions in X and Y positions + std::map<int, int> cxs, cys; + for (auto &n : nets) { + if (n.cx != -1) + ++cxs[n.cx]; + if (n.cy != -1) + ++cys[n.cy]; + } + // 4-way split for now + int accum_x = 0, accum_y = 0; + int mid_x = 0, mid_y = 0; + int halfway = int(nets.size()) / 2; + for (auto &p : cxs) { + if (accum_x < halfway && (accum_x + p.second) >= halfway) + mid_x = p.first; + accum_x += p.second; + } + for (auto &p : cys) { + if (accum_y < halfway && (accum_y + p.second) >= halfway) + mid_y = p.first; + accum_y += p.second; + } + log_info("x splitpoint: %d\n", mid_x); + log_info("y splitpoint: %d\n", mid_y); + std::vector<int> bins(5, 0); + for (auto &n : nets) { + if (n.bb.x0 < mid_x && n.bb.x1 < mid_x && n.bb.y0 < mid_y && n.bb.y1 < mid_y) + ++bins[0]; // TL + else if (n.bb.x0 >= mid_x && n.bb.x1 >= mid_x && n.bb.y0 < mid_y && n.bb.y1 < mid_y) + ++bins[1]; // TR + else if (n.bb.x0 < mid_x && n.bb.x1 < mid_x && n.bb.y0 >= mid_y && n.bb.y1 >= mid_y) + ++bins[2]; // BL + else if (n.bb.x0 >= mid_x && n.bb.x1 >= mid_x && n.bb.y0 >= mid_y && n.bb.y1 >= mid_y) + ++bins[3]; // BR + else + ++bins[4]; // cross-boundary + } + for (int i = 0; i < 5; i++) + log_info("bin %d N=%d\n", i, bins[i]); + } + void router_test() { setup_nets(); setup_wires(); + partition_nets(); curr_cong_weight = 0.5; hist_cong_weight = 1.0; ThreadContext st; |