From 42d1990784b95710e16d3892399262877ab18502 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 16:32:06 -0800 Subject: [timing] Path report to include pips when --verbose set --- common/timing.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/timing.cc b/common/timing.cc index 2769cd65..c5a99f54 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -407,7 +407,24 @@ void timing_analysis(Context *ctx, bool print_histogram, bool print_path) log_info("%4.1f %4.1f Net %s budget %f ns (%d,%d) -> (%d,%d)\n", ctx->getDelayNS(net_delay), ctx->getDelayNS(total), net->name.c_str(ctx), ctx->getDelayNS(sink->budget), driver_loc.x, driver_loc.y, sink_loc.x, sink_loc.y); - log_info(" Sink %s.%s\n", sink_cell->name.c_str(ctx), sink->port.c_str(ctx)); + log_info(" Sink %s.%s\n", sink_cell->name.c_str(ctx), sink->port.c_str(ctx)); + if (ctx->verbose) { + auto driver_wire = ctx->getNetinfoSourceWire(net); + auto sink_wire = ctx->getNetinfoSinkWire(net, *sink); + log_info(" prediction: %f ns estimate: %f ns\n", + ctx->getDelayNS(ctx->predictDelay(net, *sink)), ctx->getDelayNS(ctx->estimateDelay(driver_wire, sink_wire))); + auto cursor = sink_wire; + delay_t delay; + while (driver_wire != cursor) { + auto it = net->wires.find(cursor); + assert(it != net->wires.end()); + auto pip = it->second.pip; + NPNR_ASSERT(pip != PipId()); + delay = ctx->getPipDelay(pip).maxDelay(); + log_info(" %1.3f %s\n", ctx->getDelayNS(delay), ctx->getPipName(pip).c_str(ctx)); + cursor = ctx->getPipSrcWire(pip); + } + } last_port = sink->port; } log_break(); -- cgit v1.2.3 From 519bcd31bfe076ff0d89ed1d2ec832ec140f58a2 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 15:52:06 -0800 Subject: [placer1] Fix require_legal polarity --- common/placer1.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/placer1.cc b/common/placer1.cc index 0d7c0701..8c467162 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -244,9 +244,9 @@ class SAPlacer } // Once cooled below legalise threshold, run legalisation and start requiring // legal moves only - if (temp < legalise_temp && !require_legal) { + if (temp < legalise_temp && require_legal) { legalise_relative_constraints(ctx); - require_legal = true; + require_legal = false; autoplaced.clear(); for (auto cell : sorted(ctx->cells)) { if (cell.second->belStrength < STRENGTH_STRONG) @@ -486,7 +486,7 @@ class SAPlacer std::unordered_map bel_types; std::vector>>> fast_bels; std::unordered_set locked_bels; - bool require_legal = false; + bool require_legal = true; const float legalise_temp = 1; const float post_legalise_temp = 10; const float post_legalise_dia_scale = 1.5; -- cgit v1.2.3 From 6527e3b6aedf399f2eff5244bff78da0c08f82a6 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 16:01:30 -0800 Subject: [common] Fix typo in Loc::operator!=() --- common/nextpnr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index 86e781ae..4434c438 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -191,7 +191,7 @@ struct Loc Loc(int x, int y, int z) : x(x), y(y), z(z) {} bool operator==(const Loc &other) const { return (x == other.x) && (y == other.y) && (z == other.z); } - bool operator!=(const Loc &other) const { return (x != other.x) || (y != other.y) || (z == other.z); } + bool operator!=(const Loc &other) const { return (x != other.x) || (y != other.y) || (z != other.z); } }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From cab91b035b591f331e6ca19f3593fa030087a7e0 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 16:04:59 -0800 Subject: [common] Fix 'after after' --- common/place_common.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/place_common.cc b/common/place_common.cc index 1c262c6f..3def2b25 100644 --- a/common/place_common.cc +++ b/common/place_common.cc @@ -473,7 +473,7 @@ class ConstraintLegaliseWorker return false; } } - print_stats("after legalising chains"); + print_stats("legalising chains"); for (auto rippedCell : rippedCells) { bool res = place_single_cell(ctx, ctx->cells.at(rippedCell).get(), true); if (!res) { @@ -481,7 +481,7 @@ class ConstraintLegaliseWorker return false; } } - print_stats("after replacing ripped up cells"); + print_stats("replacing ripped up cells"); 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), -- cgit v1.2.3 From 1b931078437370de28f5f0bee185e70b6bea8ed6 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 16:17:39 -0800 Subject: [placer1] Only increase temperature if legaliser moved something --- common/place_common.cc | 22 ++++++++++++---------- common/placer1.cc | 20 +++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) (limited to 'common') diff --git a/common/place_common.cc b/common/place_common.cc index 3def2b25..4cb5ae11 100644 --- a/common/place_common.cc +++ b/common/place_common.cc @@ -431,12 +431,12 @@ class ConstraintLegaliseWorker print_chain(child, depth + 1); } - void print_stats(const char *point) + unsigned print_stats(const char *point) { float distance_sum = 0; float max_distance = 0; - int moved_cells = 0; - int unplaced_cells = 0; + unsigned moved_cells = 0; + unsigned unplaced_cells = 0; for (auto orig : oldLocations) { if (ctx->cells.at(orig.first)->bel == BelId()) { unplaced_cells++; @@ -456,9 +456,10 @@ class ConstraintLegaliseWorker log_info(" average distance %f\n", (distance_sum / moved_cells)); log_info(" maximum distance %f\n", max_distance); } + return moved_cells + unplaced_cells; } - bool legalise_constraints() + int legalise_constraints() { log_info("Legalising relative constraints...\n"); for (auto cell : sorted(ctx->cells)) { @@ -470,27 +471,28 @@ class ConstraintLegaliseWorker if (ctx->verbose) print_chain(cell.second); log_error("failed to place chain starting at cell '%s'\n", cell.first.c_str(ctx)); - return false; + return -1; } } - print_stats("legalising chains"); + if (print_stats("legalising chains") == 0) + return 0; for (auto rippedCell : rippedCells) { bool res = place_single_cell(ctx, ctx->cells.at(rippedCell).get(), true); if (!res) { log_error("failed to place cell '%s' after relative constraint legalisation\n", rippedCell.c_str(ctx)); - return false; + return -1; } } - print_stats("replacing ripped up cells"); + auto score = print_stats("replacing ripped up cells"); 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 score; } }; -bool legalise_relative_constraints(Context *ctx) { return ConstraintLegaliseWorker(ctx).legalise_constraints(); } +bool legalise_relative_constraints(Context *ctx) { return ConstraintLegaliseWorker(ctx).legalise_constraints() > 0; } // Get the total distance from satisfied constraints for a cell int get_constraints_distance(const Context *ctx, const CellInfo *cell) diff --git a/common/placer1.cc b/common/placer1.cc index 8c467162..b22a66cb 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -245,16 +245,18 @@ class SAPlacer // Once cooled below legalise threshold, run legalisation and start requiring // legal moves only if (temp < legalise_temp && require_legal) { - legalise_relative_constraints(ctx); - require_legal = false; - autoplaced.clear(); - for (auto cell : sorted(ctx->cells)) { - if (cell.second->belStrength < STRENGTH_STRONG) - autoplaced.push_back(cell.second); + if (legalise_relative_constraints(ctx)) { + // Only increase temperature if something was moved + autoplaced.clear(); + for (auto cell : sorted(ctx->cells)) { + if (cell.second->belStrength < STRENGTH_STRONG) + autoplaced.push_back(cell.second); + } + temp = post_legalise_temp; + diameter *= post_legalise_dia_scale; + ctx->shuffle(autoplaced); } - temp = post_legalise_temp; - diameter *= post_legalise_dia_scale; - ctx->shuffle(autoplaced); + require_legal = false; // Legalisation is a big change so force a slack redistribution here if (ctx->slack_redist_iter > 0) -- cgit v1.2.3 From df2622d30014d6c7fc0dfc3b440688ab22331ba2 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Tue, 13 Nov 2018 16:21:22 -0800 Subject: [placer1] Only perform slack redist if legalised --- common/placer1.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/placer1.cc b/common/placer1.cc index b22a66cb..0fd9a227 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -255,12 +255,12 @@ class SAPlacer temp = post_legalise_temp; diameter *= post_legalise_dia_scale; ctx->shuffle(autoplaced); + + // Legalisation is a big change so force a slack redistribution here + if (ctx->slack_redist_iter > 0) + assign_budget(ctx, true /* quiet */); } require_legal = false; - - // Legalisation is a big change so force a slack redistribution here - if (ctx->slack_redist_iter > 0) - assign_budget(ctx, true /* quiet */); } else if (ctx->slack_redist_iter > 0 && iter % ctx->slack_redist_iter == 0) { assign_budget(ctx, true /* quiet */); } -- cgit v1.2.3