From c7c13cd95f7a25b2c8932ca00ad667ffca381c70 Mon Sep 17 00:00:00 2001 From: gatecat Date: Tue, 16 Feb 2021 11:52:16 +0000 Subject: Remove isValidBelForCell This Arch API dates from when we were first working out how to implement placement validity checking, and in practice is little used by the core parts of placer1/HeAP and the Arch implementation involves a lot of duplication with isBelLocationValid. In the short term; placement validity checking is better served by the combination of checkBelAvail and isValidBelForCellType before placement; followed by isBelLocationValid after placement (potentially after moving/swapping multiple cells). Longer term, removing this API makes things a bit cleaner for a new validity checking API. Signed-off-by: gatecat --- common/place_common.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'common/place_common.cc') diff --git a/common/place_common.cc b/common/place_common.cc index 6526c38e..e5b48ffb 100644 --- a/common/place_common.cc +++ b/common/place_common.cc @@ -118,8 +118,7 @@ bool place_single_cell(Context *ctx, CellInfo *cell, bool require_legality) } IdString targetType = cell->type; for (auto bel : ctx->getBels()) { - if (ctx->isValidBelForCellType(targetType, bel) && - (!require_legality || ctx->isValidBelForCell(cell, bel))) { + if (ctx->isValidBelForCellType(targetType, bel)) { if (ctx->checkBelAvail(bel)) { wirelen_t wirelen = get_cell_metric_at_bel(ctx, cell, bel, MetricType::COST); if (iters >= 4) @@ -155,12 +154,20 @@ bool place_single_cell(Context *ctx, CellInfo *cell, bool require_legality) ctx->unbindBel(ripup_target->bel); best_bel = ripup_bel; } else { + ripup_target = nullptr; all_placed = true; } + ctx->bindBel(best_bel, cell, STRENGTH_WEAK); + if (require_legality && !ctx->isBelLocationValid(best_bel)) { + ctx->unbindBel(best_bel); + if (ripup_target != nullptr) { + ctx->bindBel(best_bel, ripup_target, STRENGTH_WEAK); + } + all_placed = false; + continue; + } if (ctx->verbose) log_info(" placed single cell '%s' at '%s'\n", cell->name.c_str(ctx), ctx->nameOfBel(best_bel)); - ctx->bindBel(best_bel, cell, STRENGTH_WEAK); - cell = ripup_target; } return true; @@ -387,7 +394,7 @@ class ConstraintLegaliseWorker for (auto bel : ctx->getBelsByTile(cp.second.x, cp.second.y)) { CellInfo *belCell = ctx->getBoundBelCell(bel); if (belCell != nullptr && !solution.count(belCell->name)) { - if (!ctx->isValidBelForCell(belCell, bel)) { + if (!ctx->isBelLocationValid(bel)) { NPNR_ASSERT(belCell->belStrength < STRENGTH_STRONG); ctx->unbindBel(bel); rippedCells.insert(belCell->name); -- cgit v1.2.3