mirror of https://github.com/YosysHQ/nextpnr.git
placer_heap: fix clamping to region (#1569)
This commit is contained in:
parent
e9bac6961a
commit
e7f9060efb
|
|
@ -909,22 +909,25 @@ class HeAPPlacer
|
||||||
|
|
||||||
// Determine a search radius around the solver location (which increases over time) that is clamped to
|
// Determine a search radius around the solver location (which increases over time) that is clamped to
|
||||||
// the region constraint for the cell (if applicable)
|
// the region constraint for the cell (if applicable)
|
||||||
int rx = radius, ry = radius;
|
int x0 = std::max(cell_locs.at(ci->name).x - radius, 0);
|
||||||
|
int y0 = std::max(cell_locs.at(ci->name).y - radius, 0);
|
||||||
|
int x1 = cell_locs.at(ci->name).x + radius;
|
||||||
|
int y1 = cell_locs.at(ci->name).y + radius;
|
||||||
|
|
||||||
if (ci->region != nullptr) {
|
if (ci->region != nullptr) {
|
||||||
rx = std::min(radius, (constraint_region_bounds[ci->region->name].x1 -
|
auto &r = constraint_region_bounds[ci->region->name];
|
||||||
constraint_region_bounds[ci->region->name].x0) /
|
// Clamp search box to a region
|
||||||
2 +
|
x0 = std::max(x0, r.x0);
|
||||||
1);
|
y0 = std::max(y0, r.y0);
|
||||||
ry = std::min(radius, (constraint_region_bounds[ci->region->name].y1 -
|
x1 = std::min(x1, r.x1);
|
||||||
constraint_region_bounds[ci->region->name].y0) /
|
y1 = std::min(y1, r.y1);
|
||||||
2 +
|
if (x0 > x1) std::swap(x0, x1);
|
||||||
1);
|
if (y0 > y1) std::swap(y0, y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick a random X and Y location within our search radius
|
// Pick a random X and Y location within our search radius / search box
|
||||||
int nx = ctx->rng(2 * rx + 1) + std::max(cell_locs.at(ci->name).x - rx, 0);
|
int nx = ctx->rng(x1 - x0 + 1) + x0;
|
||||||
int ny = ctx->rng(2 * ry + 1) + std::max(cell_locs.at(ci->name).y - ry, 0);
|
int ny = ctx->rng(y1 - y0 + 1) + y0;
|
||||||
|
|
||||||
iter++;
|
iter++;
|
||||||
iter_at_radius++;
|
iter_at_radius++;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue