aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-17 11:45:41 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-17 11:45:41 +0200
commit3afce5ff5a6adfa1baccb4f4625005300b9a3862 (patch)
tree6217511802c19514a1168a4e6412d1268ac07fb3 /common
parentc604426341c75bc34b9d97ad5cd49cc28f9198fb (diff)
downloadnextpnr-3afce5ff5a6adfa1baccb4f4625005300b9a3862.tar.gz
nextpnr-3afce5ff5a6adfa1baccb4f4625005300b9a3862.tar.bz2
nextpnr-3afce5ff5a6adfa1baccb4f4625005300b9a3862.zip
Improving the placer output
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/design_utils.cc23
-rw-r--r--common/design_utils.h3
-rw-r--r--common/place_sa.cc14
-rw-r--r--common/util.h12
4 files changed, 38 insertions, 14 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 85895a75..c6504fb9 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -18,7 +18,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 +51,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
diff --git a/common/design_utils.h b/common/design_utils.h
index 8d231d4c..0a33b168 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -83,6 +83,9 @@ CellInfo *net_driven_by(const NetInfo *net, F1 cell_pred, IdString port)
}
}
+void print_utilisation(const Design *design);
+
+
NEXTPNR_NAMESPACE_END
#endif
diff --git a/common/place_sa.cc b/common/place_sa.cc
index aef759f8..7532213c 100644
--- a/common/place_sa.cc
+++ b/common/place_sa.cc
@@ -183,7 +183,8 @@ static bool try_swap_position(Design *design, CellInfo *cell, BelId newBel,
chip.bindBel(oldBel, other_cell->name);
}
- if (!isBelLocationValid(design, newBel) || ((other != IdString() && !isBelLocationValid(design, oldBel)))) {
+ if (!isBelLocationValid(design, newBel) ||
+ ((other != IdString() && !isBelLocationValid(design, oldBel)))) {
chip.unbindBel(newBel);
if (other != IdString())
chip.unbindBel(oldBel);
@@ -309,7 +310,7 @@ void place_design_sa(Design *design)
autoplaced.push_back(cell.second);
placed_cells++;
}
- log_info("placed %d/%d\n", int(placed_cells), int(total_cells));
+ // log_info("placed %d/%d\n", int(placed_cells), int(total_cells));
}
// Build up a fast position/type to Bel lookup table
int max_x = 0, max_y = 0;
@@ -345,9 +346,9 @@ void place_design_sa(Design *design)
state.n_move = state.n_accept = 0;
state.improved = false;
- // if (iter % 50 == 0)
- log(" at iteration #%d: temp = %f, wire length = %f\n", iter,
- state.temp, state.curr_wirelength);
+ if (iter % 5 == 0)
+ log(" at iteration #%d: temp = %f, wire length = %f\n", iter,
+ state.temp, state.curr_wirelength);
for (int m = 0; m < 15; ++m) {
// Loop through all automatically placed cells
@@ -403,7 +404,8 @@ void place_design_sa(Design *design)
IdString cell = design->chip.getBelCell(bel, false);
if (cell != IdString())
cell_text = std::string("cell '") + cell.str() + "'";
- log_error("post-placement validity check failed for Bel '%s' (%s)", design->chip.getBelName(bel).c_str(), cell_text.c_str());
+ log_error("post-placement validity check failed for Bel '%s' (%s)",
+ design->chip.getBelName(bel).c_str(), cell_text.c_str());
}
}
}
diff --git a/common/util.h b/common/util.h
index 2313a290..34b2ed02 100644
--- a/common/util.h
+++ b/common/util.h
@@ -27,7 +27,7 @@ NEXTPNR_NAMESPACE_BEGIN
// Get a value from a map-style container, returning default if value is not
// found
-template<typename Container, typename KeyType, typename ValueType>
+template <typename Container, typename KeyType, typename ValueType>
ValueType get_or_default(const Container &ct, const KeyType &key,
ValueType def = ValueType())
{
@@ -40,9 +40,8 @@ ValueType get_or_default(const Container &ct, const KeyType &key,
// Get a value from a map-style container, converting to int, and returning
// default if value is not found
-template<typename Container, typename KeyType>
-int int_or_default(const Container &ct, const KeyType &key,
- int def = 0)
+template <typename Container, typename KeyType>
+int int_or_default(const Container &ct, const KeyType &key, int def = 0)
{
auto found = ct.find(key);
if (found == ct.end())
@@ -52,9 +51,8 @@ int int_or_default(const Container &ct, const KeyType &key,
};
// As above, but convert to bool
-template<typename Container, typename KeyType>
-bool bool_or_default(const Container &ct, const KeyType &key,
- bool def = false)
+template <typename Container, typename KeyType>
+bool bool_or_default(const Container &ct, const KeyType &key, bool def = false)
{
return bool(int_or_default(ct, key, int(def)));
};