Adding constraint satisfaction checks for debugging

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-08-03 16:59:45 +02:00
parent fd2174149c
commit dc4ab55b27
3 changed files with 18 additions and 9 deletions

View File

@ -281,7 +281,7 @@ struct CellInfo : ArchCellInfo
std::unordered_map<IdString, IdString> pins; std::unordered_map<IdString, IdString> pins;
// placement constraints // placement constraints
CellInfo *constr_parent; CellInfo *constr_parent = nullptr;
std::vector<CellInfo *> constr_children; std::vector<CellInfo *> constr_children;
const int UNCONSTR = INT_MIN; const int UNCONSTR = INT_MIN;
int constr_x = UNCONSTR; // this.x - parent.x int constr_x = UNCONSTR; // this.x - parent.x

View File

@ -438,13 +438,17 @@ class ConstraintLegaliseWorker
} }
} }
for (auto rippedCell : rippedCells) { for (auto rippedCell : rippedCells) {
bool res = place_single_cell(ctx, rippedCell, STRENGTH_WEAK); bool res = place_single_cell(ctx, rippedCell, true);
if (!res) { if (!res) {
log_error("failed to place cell '%s' after relative constraint legalisation\n", log_error("failed to place cell '%s' after relative constraint legalisation\n",
rippedCell->name.c_str(ctx)); rippedCell->name.c_str(ctx));
return false; return false;
} }
} }
for (auto cell : sorted(ctx->cells))
if (get_constraints_distance(ctx, cell.second) != 0)
log_error("constraint satisfaction check failed for cell '%s' at Bel '%s'\n", cell.first.c_str(ctx),
ctx->getBelName(cell.second->bel).c_str(ctx));
return true; return true;
} }
}; };

View File

@ -40,11 +40,12 @@
#include "place_common.h" #include "place_common.h"
#include "timing.h" #include "timing.h"
#include "util.h" #include "util.h"
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
class SAPlacer class SAPlacer
{ {
public: public:
SAPlacer(Context *ctx) : ctx(ctx) SAPlacer(Context *ctx) : ctx(ctx)
{ {
int num_bel_types = 0; int num_bel_types = 0;
@ -272,12 +273,16 @@ class SAPlacer
} }
} }
} }
for (auto cell : sorted(ctx->cells))
if (get_constraints_distance(ctx, cell.second) != 0)
log_error("constraint satisfaction check failed for cell '%s' at Bel '%s'\n", cell.first.c_str(ctx),
ctx->getBelName(cell.second->bel).c_str(ctx));
timing_analysis(ctx, true /* print_fmax */); timing_analysis(ctx, true /* print_fmax */);
ctx->unlock(); ctx->unlock();
return true; return true;
} }
private: private:
// Initial random placement // Initial random placement
void place_initial(CellInfo *cell) void place_initial(CellInfo *cell)
{ {