diff options
author | David Shah <dave@ds0.me> | 2019-11-18 16:06:47 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2020-02-03 11:38:30 +0000 |
commit | c21db8a0c1ea94fc042e77311840c15bb5703023 (patch) | |
tree | d6c80cc7afb187def7d69ef5f8e720412aee0208 | |
parent | 010e7ba8cbff440c10b4482da4e0f9bf4a9210fa (diff) | |
download | nextpnr-c21db8a0c1ea94fc042e77311840c15bb5703023.tar.gz nextpnr-c21db8a0c1ea94fc042e77311840c15bb5703023.tar.bz2 nextpnr-c21db8a0c1ea94fc042e77311840c15bb5703023.zip |
router2: Congestion map generation
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r-- | common/router2.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/common/router2.cc b/common/router2.cc index ee298ae4..67c6dae2 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -29,6 +29,7 @@ #include <algorithm> #include <boost/container/flat_map.hpp> #include <deque> +#include <fstream> #include <queue> #include "log.h" #include "nextpnr.h" @@ -670,6 +671,45 @@ struct Router2 return success; } + void write_heatmap(std::ostream &out, bool congestion = false) + { + std::vector<std::vector<int>> hm_xy; + int max_x = 0, max_y = 0; + for (auto &w : wires) { + auto &wd = w.second; + int val = int(wd.bound_nets.size()) - (congestion ? 1 : 0); + if (wd.bound_nets.empty()) + continue; + // Estimate wire location by driving pip location + PipId drv; + for (auto &bn : wd.bound_nets) + if (bn.second.second != PipId()) { + drv = bn.second.second; + break; + } + if (drv == PipId()) + continue; + Loc l = ctx->getPipLocation(drv); + max_x = std::max(max_x, l.x); + max_y = std::max(max_y, l.y); + if (l.y >= int(hm_xy.size())) + hm_xy.resize(l.y + 1); + if (l.x >= int(hm_xy.at(l.y).size())) + hm_xy.at(l.y).resize(l.x + 1); + if (val > 0) + hm_xy.at(l.y).at(l.x) += val; + } + for (int y = 0; y <= max_y; y++) { + for (int x = 0; x <= max_x; x++) { + if (y >= int(hm_xy.size()) || x >= int(hm_xy.at(y).size())) + out << "0,"; + else + out << hm_xy.at(y).at(x) << ","; + } + out << std::endl; + } + } + void router_test() { setup_nets(); @@ -691,6 +731,12 @@ struct Router2 } route_queue.clear(); update_congestion(); +#if 1 + if (iter == 1 && ctx->debug) { + std::ofstream cong_map("cong_map_0.csv"); + write_heatmap(cong_map, true); + } +#endif if (overused_wires == 0) { // Try and actually bind nextpnr Arch API wires bind_and_check_all(); |