place_common: Relative constraints working for basic example
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
48e06896a2
commit
60757a2dd7
@ -251,6 +251,7 @@ class ConstraintLegaliseWorker
|
|||||||
zSearch = IncreasingDiameterSearch(loc.z + child->constr_z);
|
zSearch = IncreasingDiameterSearch(loc.z + child->constr_z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool success = false;
|
||||||
while (!xSearch.done()) {
|
while (!xSearch.done()) {
|
||||||
Loc cloc;
|
Loc cloc;
|
||||||
cloc.x = xSearch.get();
|
cloc.x = xSearch.get();
|
||||||
@ -269,13 +270,16 @@ class ConstraintLegaliseWorker
|
|||||||
|
|
||||||
if (usedLocations.count(cloc))
|
if (usedLocations.count(cloc))
|
||||||
continue;
|
continue;
|
||||||
if (valid_loc_for(child, cloc, solution, usedLocations))
|
if (valid_loc_for(child, cloc, solution, usedLocations)) {
|
||||||
return true;
|
success = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
usedLocations.erase(loc);
|
usedLocations.erase(loc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (solution.count(cell->name))
|
if (solution.count(cell->name))
|
||||||
usedLocations.erase(solution.at(cell->name));
|
usedLocations.erase(solution.at(cell->name));
|
||||||
solution[cell->name] = loc;
|
solution[cell->name] = loc;
|
||||||
@ -325,14 +329,27 @@ class ConstraintLegaliseWorker
|
|||||||
std::unordered_set<Loc> used;
|
std::unordered_set<Loc> used;
|
||||||
if (valid_loc_for(cell, rootLoc, solution, used)) {
|
if (valid_loc_for(cell, rootLoc, solution, used)) {
|
||||||
for (auto cp : solution) {
|
for (auto cp : solution) {
|
||||||
|
// First unbind all cells
|
||||||
|
if (ctx->cells.at(cp.first)->bel != BelId())
|
||||||
|
ctx->unbindBel(ctx->cells.at(cp.first)->bel);
|
||||||
|
}
|
||||||
|
for (auto cp : solution) {
|
||||||
|
if (ctx->verbose)
|
||||||
|
log_info(" placing '%s' at (%d, %d, %d)\n", cp.first.c_str(ctx), cp.second.x, cp.second.y, cp.second.z);
|
||||||
BelId target = ctx->getBelByLocation(cp.second);
|
BelId target = ctx->getBelByLocation(cp.second);
|
||||||
|
if(ctx->verbose)
|
||||||
|
log_info(" resolved to bel: '%s'\n", ctx->getBelName(target).c_str(ctx));
|
||||||
|
if (!ctx->checkBelAvail(target)) {
|
||||||
IdString conflicting = ctx->getConflictingBelCell(target);
|
IdString conflicting = ctx->getConflictingBelCell(target);
|
||||||
if (conflicting != IdString()) {
|
if (conflicting != IdString()) {
|
||||||
CellInfo *confl_cell = ctx->cells.at(conflicting).get();
|
CellInfo *confl_cell = ctx->cells.at(conflicting).get();
|
||||||
|
if (ctx->verbose)
|
||||||
|
log_info(" '%s' already placed at '%s'\n", conflicting.c_str(ctx), ctx->getBelName(confl_cell->bel).c_str(ctx));
|
||||||
NPNR_ASSERT(confl_cell->belStrength < STRENGTH_STRONG);
|
NPNR_ASSERT(confl_cell->belStrength < STRENGTH_STRONG);
|
||||||
ctx->unbindBel(target);
|
ctx->unbindBel(target);
|
||||||
rippedCells.push_back(confl_cell);
|
rippedCells.push_back(confl_cell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ctx->bindBel(target, cp.first, STRENGTH_LOCKED);
|
ctx->bindBel(target, cp.first, STRENGTH_LOCKED);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user