diff options
author | David Shah <dave@ds0.me> | 2020-02-02 15:25:20 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2020-02-12 10:41:27 +0000 |
commit | 7bda6f15a9c906f54408b8b35915113e711c887c (patch) | |
tree | 1386e11519938af8d8eb760055b92e310879c802 | |
parent | ca733561873cd54be047ae30a94efcd71b3f8be5 (diff) | |
download | nextpnr-7bda6f15a9c906f54408b8b35915113e711c887c.tar.gz nextpnr-7bda6f15a9c906f54408b8b35915113e711c887c.tar.bz2 nextpnr-7bda6f15a9c906f54408b8b35915113e711c887c.zip |
placer1: Allow scaling HPWL differently in each direction
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r-- | common/placer1.cc | 19 | ||||
-rw-r--r-- | common/placer1.h | 1 |
2 files changed, 14 insertions, 6 deletions
diff --git a/common/placer1.cc b/common/placer1.cc index 96424957..9c1eaba4 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -68,7 +68,10 @@ class SAPlacer int x0 = 0, x1 = 0, y0 = 0, y1 = 0; // Number of cells at each extremity int nx0 = 0, nx1 = 0, ny0 = 0, ny1 = 0; - wirelen_t hpwl() const { return wirelen_t((x1 - x0) + (y1 - y0)); } + wirelen_t hpwl(const Placer1Cfg &cfg) const + { + return wirelen_t(cfg.hpwl_scale_x * (x1 - x0) + cfg.hpwl_scale_y * (y1 - y0)); + } }; public: @@ -689,8 +692,10 @@ class SAPlacer int dx = diameter, dy = diameter; if (cell->region != nullptr && cell->region->constr_bels) { - dx = std::min(diameter, (region_bounds[cell->region->name].x1 - region_bounds[cell->region->name].x0) + 1); - dy = std::min(diameter, (region_bounds[cell->region->name].y1 - region_bounds[cell->region->name].y0) + 1); + dx = std::min(cfg.hpwl_scale_x * diameter, + (region_bounds[cell->region->name].x1 - region_bounds[cell->region->name].x0) + 1); + dy = std::min(cfg.hpwl_scale_y * diameter, + (region_bounds[cell->region->name].y1 - region_bounds[cell->region->name].y0) + 1); // Clamp location to within bounds curr_loc.x = std::max(region_bounds[cell->region->name].x0, curr_loc.x); curr_loc.x = std::min(region_bounds[cell->region->name].x1, curr_loc.x); @@ -820,7 +825,7 @@ class SAPlacer { wirelen_t cost = 0; for (const auto &net : net_bounds) - cost += net.hpwl(); + cost += net.hpwl(cfg); return cost; } @@ -1061,10 +1066,10 @@ class SAPlacer } for (const auto &bc : md.bounds_changed_nets_x) - md.wirelen_delta += md.new_net_bounds[bc].hpwl() - net_bounds[bc].hpwl(); + md.wirelen_delta += md.new_net_bounds[bc].hpwl(cfg) - net_bounds[bc].hpwl(cfg); for (const auto &bc : md.bounds_changed_nets_y) if (md.already_bounds_changed_x[bc] == MoveChangeData::NO_CHANGE) - md.wirelen_delta += md.new_net_bounds[bc].hpwl() - net_bounds[bc].hpwl(); + md.wirelen_delta += md.new_net_bounds[bc].hpwl(cfg) - net_bounds[bc].hpwl(cfg); if (cfg.timing_driven) { for (const auto &tc : md.changed_arcs) { @@ -1145,6 +1150,8 @@ Placer1Cfg::Placer1Cfg(Context *ctx) timingFanoutThresh = std::numeric_limits<int>::max(); timing_driven = ctx->setting<bool>("timing_driven"); slack_redist_iter = ctx->setting<int>("slack_redist_iter"); + hpwl_scale_x = 1; + hpwl_scale_y = 1; } bool placer1(Context *ctx, Placer1Cfg cfg) diff --git a/common/placer1.h b/common/placer1.h index 1356db3e..e803d592 100644 --- a/common/placer1.h +++ b/common/placer1.h @@ -34,6 +34,7 @@ struct Placer1Cfg int timingFanoutThresh; bool timing_driven; int slack_redist_iter; + int hpwl_scale_x, hpwl_scale_y; }; extern bool placer1(Context *ctx, Placer1Cfg cfg); |