aboutsummaryrefslogtreecommitdiffstats
path: root/common/design_utils.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-06-17 14:31:43 +0200
committerClifford Wolf <clifford@clifford.at>2018-06-17 14:31:43 +0200
commitc0a2f0b89fa1505c728d57a4529a62aa78013da4 (patch)
treef74bbf4e63857251a65e3ca50b1da62da7934d5a /common/design_utils.cc
parent3b5c33d685b1330747612e4cebb422b09b2bd8de (diff)
parent153b800f6a5da9af277e64b4cd4aee1c10ca0a01 (diff)
downloadnextpnr-c0a2f0b89fa1505c728d57a4529a62aa78013da4.tar.gz
nextpnr-c0a2f0b89fa1505c728d57a4529a62aa78013da4.tar.bz2
nextpnr-c0a2f0b89fa1505c728d57a4529a62aa78013da4.zip
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into chipdbng
Diffstat (limited to 'common/design_utils.cc')
-rw-r--r--common/design_utils.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 85895a75..ae6e21ed 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -2,6 +2,7 @@
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Clifford Wolf <clifford@clifford.at>
+ * Copyright (C) 2018 David Shah <david@symbioticeda.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,7 +19,9 @@
*/
#include "design_utils.h"
-
+#include <map>
+#include "log.h"
+#include "util.h"
NEXTPNR_NAMESPACE_BEGIN
void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
@@ -49,4 +52,23 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
}
}
+// Print utilisation of a design
+void print_utilisation(const Design *design)
+{
+ // Sort by Bel type
+ std::map<BelType, int> used_types;
+ for (auto cell : design->cells) {
+ used_types[belTypeFromId(cell.second->type)]++;
+ }
+ std::map<BelType, int> available_types;
+ for (auto bel : design->chip.getBels()) {
+ available_types[design->chip.getBelType(bel)]++;
+ }
+ log("\nDesign utilisation:\n");
+ for (auto type : available_types) {
+ log("\t%20s: %5d/%5d\n", belTypeToId(type.first).c_str(),
+ get_or_default(used_types, type.first, 0), type.second);
+ }
+}
+
NEXTPNR_NAMESPACE_END