aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-30 16:13:02 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-30 16:13:02 +0200
commitedc6cf8b23d973aa45a8c22516e7222eb6001391 (patch)
tree15cab3bbb012a996c64853549c2abf8d103cda53 /ice40
parent1cde20273a48b0716cf1b3206edaff716fc78097 (diff)
downloadnextpnr-edc6cf8b23d973aa45a8c22516e7222eb6001391.tar.gz
nextpnr-edc6cf8b23d973aa45a8c22516e7222eb6001391.tar.bz2
nextpnr-edc6cf8b23d973aa45a8c22516e7222eb6001391.zip
ice40: Print legalisation statistics
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/place_legaliser.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/ice40/place_legaliser.cc b/ice40/place_legaliser.cc
index 9fde179d..ba09e250 100644
--- a/ice40/place_legaliser.cc
+++ b/ice40/place_legaliser.cc
@@ -114,17 +114,55 @@ class PlacementLegaliser
public:
PlacementLegaliser(Context *ctx) : ctx(ctx){};
+ void print_stats(const char *point)
+ {
+ float distance_sum = 0;
+ float max_distance = 0;
+ int moved_cells = 0;
+ for (auto orig : originalPositions) {
+ if (ctx->cells.at(orig.first)->bel == BelId())
+ continue;
+ Loc newLoc = ctx->getBelLocation(ctx->cells.at(orig.first)->bel);
+ if (newLoc != orig.second) {
+ float distance = std::sqrt(std::pow(newLoc.x - orig.second.x, 2) + pow(newLoc.y - orig.second.y, 2));
+ moved_cells++;
+ distance_sum += distance;
+ if (distance > max_distance)
+ max_distance = distance;
+ }
+ }
+ log_info(" moved %d cells (after %s)\n", moved_cells, point);
+ if (moved_cells > 0) {
+ log_info(" average distance %f\n", (distance_sum / moved_cells));
+ log_info(" maximum distance %f\n", max_distance);
+ }
+ }
+
bool legalise()
{
log_info("Legalising design..\n");
+ for (auto &cell : ctx->cells) {
+ CellInfo *ci = cell.second.get();
+ if (!ctx->getBelGlobalBuf(ci->bel) && cell.second->type == ctx->id("ICESTORM_LC")) {
+ originalPositions[cell.first] = ctx->getBelLocation(ci->bel);
+ }
+ }
init_logic_cells();
bool legalised_carries = legalise_carries();
if (!legalised_carries && !ctx->force)
return false;
+ print_stats("carry legalisation");
legalise_others();
+ print_stats("misc. cell legalisation");
legalise_logic_tiles();
+ print_stats("logic cell legalisation");
bool replaced_cells = replace_cells();
+ print_stats("cell replacement");
+
ctx->assignArchInfo();
+
+
+
return legalised_carries && replaced_cells;
}
@@ -501,6 +539,7 @@ class PlacementLegaliser
Context *ctx;
std::unordered_set<IdString> rippedCells;
std::unordered_set<IdString> createdCells;
+ std::unordered_map<IdString, Loc> originalPositions;
// Go from X and Y position to logic cells, setting occupied to true if a Bel is unavailable
std::vector<std::vector<std::vector<std::pair<BelId, bool>>>> logic_bels;
};