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::max(); timing_driven = ctx->setting("timing_driven"); slack_redist_iter = ctx->setting("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);