From c3837027b22b67a5079d84419bae20c4d545430b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 20 Jun 2018 12:50:38 +0200 Subject: Add better iCE40 delay estimates Signed-off-by: Clifford Wolf --- common/nextpnr.h | 10 +++++----- common/route.cc | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'common') diff --git a/common/nextpnr.h b/common/nextpnr.h index c59b401e..5ccbf057 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -17,13 +17,13 @@ * */ +#include #include #include #include #include #include #include -#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -196,12 +196,12 @@ struct CellInfo; enum PlaceStrength { - STRENGTH_NONE = 0, - STRENGTH_WEAK = 1, + STRENGTH_NONE = 0, + STRENGTH_WEAK = 1, STRENGTH_STRONG = 2, - STRENGTH_FIXED = 3, + STRENGTH_FIXED = 3, STRENGTH_LOCKED = 4, - STRENGTH_USER = 5 + STRENGTH_USER = 5 }; struct PortRef diff --git a/common/route.cc b/common/route.cc index b031237c..42a705a1 100644 --- a/common/route.cc +++ b/common/route.cc @@ -206,15 +206,16 @@ struct Router assert(next_delay >= 0); if (visited.count(next_wire)) { - if (visited.at(next_wire).delay <= next_delay + 1e-3) + if (visited.at(next_wire).delay <= + next_delay + ctx->getDelayEpsilon()) continue; #if 0 // FIXME if (ctx->verbose) log("Found better route to %s. Old vs new delay " - "estimate: %.2f %.2f\n", + "estimate: %.3f %.3f\n", ctx->getWireName(next_wire).c_str(), - float(visited.at(next_wire).delay), - float(next_delay)); + ctx->getDelayNS(visited.at(next_wire).delay), + ctx->getDelayNS(next_delay)); #endif revisitCnt++; } @@ -246,8 +247,8 @@ struct Router } if (ctx->verbose) - log(" Final path delay: %.2f\n", - float(visited[dst_wire].delay)); + log(" Final path delay: %.3f\n", + ctx->getDelayNS(visited[dst_wire].delay)); maxDelay = fmaxf(maxDelay, visited[dst_wire].delay); if (ctx->verbose) @@ -257,7 +258,8 @@ struct Router while (1) { if (ctx->verbose) - log(" %8.2f %s\n", float(visited[cursor].delay), + log(" %8.3f %s\n", + ctx->getDelayNS(visited[cursor].delay), ctx->getWireName(cursor).c_str(ctx)); if (src_wires.count(cursor)) -- cgit v1.2.3 From cb9c6c6ef271a6f5297d74c81807bca01a0d8319 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 20 Jun 2018 12:57:38 +0200 Subject: Changes to estimatePosition API Signed-off-by: Clifford Wolf --- common/place_sa.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/place_sa.cc b/common/place_sa.cc index 0fead5d8..3162d88c 100644 --- a/common/place_sa.cc +++ b/common/place_sa.cc @@ -51,7 +51,8 @@ class SAPlacer int num_bel_types = 0; for (auto bel : ctx->getBels()) { int x, y; - ctx->estimatePosition(bel, x, y); + bool gb; + ctx->estimatePosition(bel, x, y, gb); BelType type = ctx->getBelType(bel); int type_idx; if (bel_types.find(type) == bel_types.end()) { @@ -288,18 +289,17 @@ class SAPlacer float get_wirelength(NetInfo *net) { float wirelength = 0; - int driver_x = 0, driver_y = 0; - bool consider_driver = false; + int driver_x, driver_y; + bool driver_gb; CellInfo *driver_cell = net->driver.cell; if (!driver_cell) return 0; if (driver_cell->bel == BelId()) return 0; - consider_driver = - ctx->estimatePosition(driver_cell->bel, driver_x, driver_y); + ctx->estimatePosition(driver_cell->bel, driver_x, driver_y, driver_gb); WireId drv_wire = ctx->getWireBelPin( driver_cell->bel, ctx->portPinFromId(net->driver.port)); - if (!consider_driver) + if (driver_gb) return 0; for (auto load : net->users) { if (load.cell == nullptr) @@ -307,7 +307,7 @@ class SAPlacer CellInfo *load_cell = load.cell; if (load_cell->bel == BelId()) continue; - // ctx->estimatePosition(load_cell->bel, load_x, load_y); + // ctx->estimatePosition(load_cell->bel, load_x, load_y, load_gb); WireId user_wire = ctx->getWireBelPin( load_cell->bel, ctx->portPinFromId(load.port)); // wirelength += std::abs(load_x - driver_x) + std::abs(load_y - @@ -405,8 +405,9 @@ class SAPlacer BelId random_bel_for_cell(CellInfo *cell) { BelType targetType = ctx->belTypeFromId(cell->type); - int x = 0, y = 0; - ctx->estimatePosition(cell->bel, x, y); + int x, y; + bool gb; + ctx->estimatePosition(cell->bel, x, y, gb); while (true) { int nx = ctx->rng(2 * diameter + 1) + std::max(x - diameter, 0); int ny = ctx->rng(2 * diameter + 1) + std::max(y - diameter, 0); -- cgit v1.2.3 From 7c3593ea5acef05546be8835e25cf5e4b18549ee Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 20 Jun 2018 12:57:59 +0200 Subject: Updates from clangformat Signed-off-by: Clifford Wolf --- common/place_sa.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/place_sa.cc b/common/place_sa.cc index 3162d88c..55ec9b9a 100644 --- a/common/place_sa.cc +++ b/common/place_sa.cc @@ -374,8 +374,9 @@ class SAPlacer delta = new_wirelength - curr_wirelength; n_move++; // SA acceptance criterea - if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <= - std::exp(-delta / temp))) { + if (delta < 0 || + (temp > 1e-6 && + (ctx->rng() / float(0x3fffffff)) <= std::exp(-delta / temp))) { n_accept++; if (delta < 0) improved = true; -- cgit v1.2.3