diff options
author | gatecat <gatecat@ds0.me> | 2021-03-02 08:27:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 08:27:12 +0000 |
commit | 27fbee523301be074abd06a3568dc9591d98e0fa (patch) | |
tree | 3ec0f59c35cb1107adc3a2f5043e19e4ffde3adc /common/placer_heap.cc | |
parent | 6ff02248a3f625829c9bd041c369247ee926d8d0 (diff) | |
parent | 392156c25095aa93fdf847ef51dfa571b5d2ce88 (diff) | |
download | nextpnr-27fbee523301be074abd06a3568dc9591d98e0fa.tar.gz nextpnr-27fbee523301be074abd06a3568dc9591d98e0fa.tar.bz2 nextpnr-27fbee523301be074abd06a3568dc9591d98e0fa.zip |
Merge pull request #605 from litghost/add_placement_sanity_check
Add placement sanity check in placer_heap.
Diffstat (limited to 'common/placer_heap.cc')
-rw-r--r-- | common/placer_heap.cc | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/common/placer_heap.cc b/common/placer_heap.cc index 8a3b427f..eb931a37 100644 --- a/common/placer_heap.cc +++ b/common/placer_heap.cc @@ -49,6 +49,7 @@ #include "nextpnr.h" #include "place_common.h" #include "placer1.h" +#include "scope_lock.h" #include "timing.h" #include "util.h" @@ -147,7 +148,7 @@ class HeAPPlacer { auto startt = std::chrono::high_resolution_clock::now(); - ctx->lock(); + nextpnr::ScopeLock<Context> lock(ctx); place_constraints(); build_fast_bels(); seed_placement(); @@ -312,7 +313,24 @@ class HeAPPlacer log_info("AP soln: %s -> %s\n", cell.first.c_str(ctx), ctx->nameOfBel(cell.second->bel)); } - ctx->unlock(); + bool any_bad_placements = false; + for (auto bel : ctx->getBels()) { + CellInfo *cell = ctx->getBoundBelCell(bel); + if (!ctx->isBelLocationValid(bel)) { + std::string cell_text = "no cell"; + if (cell != nullptr) + cell_text = std::string("cell '") + ctx->nameOf(cell) + "'"; + log_warning("post-placement validity check failed for Bel '%s' " + "(%s)\n", + ctx->nameOfBel(bel), cell_text.c_str()); + any_bad_placements = true; + } + } + + if (any_bad_placements) { + return false; + } + auto endtt = std::chrono::high_resolution_clock::now(); log_info("HeAP Placer Time: %.02fs\n", std::chrono::duration<double>(endtt - startt).count()); log_info(" of which solving equations: %.02fs\n", solve_time); @@ -320,8 +338,11 @@ class HeAPPlacer log_info(" of which strict legalisation: %.02fs\n", sl_time); ctx->check(); + lock.unlock_early(); - placer1_refine(ctx, Placer1Cfg(ctx)); + if (!placer1_refine(ctx, Placer1Cfg(ctx))) { + return false; + } return true; } |