aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/arch_pybindings_shared.h3
-rw-r--r--common/design_utils.cc4
-rw-r--r--common/hash_table.h33
-rw-r--r--common/timing_opt.cc45
4 files changed, 33 insertions, 52 deletions
diff --git a/common/arch_pybindings_shared.h b/common/arch_pybindings_shared.h
index ef355a54..69d7025f 100644
--- a/common/arch_pybindings_shared.h
+++ b/common/arch_pybindings_shared.h
@@ -116,6 +116,9 @@ fn_wrapper_0a<Context, decltype(&Context::archId), &Context::archId, conv_to_str
fn_wrapper_2a_v<Context, decltype(&Context::writeSVG), &Context::writeSVG, pass_through<std::string>,
pass_through<std::string>>::def_wrap(ctx_cls, "writeSVG");
+fn_wrapper_1a<Context, decltype(&Context::isBelLocationValid), &Context::isBelLocationValid, pass_through<bool>,
+ conv_from_str<BelId>>::def_wrap(ctx_cls, "isBelLocationValid");
+
// const\_range\<BelBucketId\> getBelBuckets() const
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets,
wrap_context<BelBucketRange>>::def_wrap(ctx_cls, "getBelBuckets");
diff --git a/common/design_utils.cc b/common/design_utils.cc
index b81449b7..7eaffdc3 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -67,12 +67,12 @@ void print_utilisation(const Context *ctx)
// Sort by Bel type
std::map<IdString, int> used_types;
for (auto &cell : ctx->cells) {
- used_types[cell.second.get()->type]++;
+ used_types[ctx->getBelBucketName(ctx->getBelBucketForCellType(cell.second.get()->type))]++;
}
std::map<IdString, int> available_types;
for (auto bel : ctx->getBels()) {
if (!ctx->getBelHidden(bel)) {
- available_types[ctx->getBelType(bel)]++;
+ available_types[ctx->getBelBucketName(ctx->getBelBucketForBel(bel))]++;
}
}
log_break();
diff --git a/common/hash_table.h b/common/hash_table.h
index 759580da..21ca8887 100644
--- a/common/hash_table.h
+++ b/common/hash_table.h
@@ -20,29 +20,44 @@
#ifndef HASH_TABLE_H
#define HASH_TABLE_H
-#if defined(NPNR_DISABLE_THREADS)
-#include <unordered_map>
-#include <unordered_set>
-#else
+#if defined(USE_ABSEIL)
#include <absl/container/flat_hash_map.h>
#include <absl/container/flat_hash_set.h>
+#else
+#include <unordered_map>
+#include <unordered_set>
#endif
+#include <boost/functional/hash.hpp>
+
#include "nextpnr_namespaces.h"
NEXTPNR_NAMESPACE_BEGIN
namespace HashTables {
-#if defined(NPNR_DISABLE_THREADS)
-template <typename Key, typename Value> using HashMap = std::unordered_map<Key, Value>;
-template <typename Value> using HashSet = std::unordered_set<Value>;
+#if defined(USE_ABSEIL)
+template <typename Key, typename Value, typename Hash = std::hash<Key>>
+using HashMap = absl::flat_hash_map<Key, Value, Hash>;
+template <typename Value, typename Hash = std::hash<Value>> using HashSet = absl::flat_hash_set<Value, Hash>;
#else
-template <typename Key, typename Value> using HashMap = absl::flat_hash_map<Key, Value>;
-template <typename Value> using HashSet = absl::flat_hash_set<Value>;
+template <typename Key, typename Value, typename Hash = std::hash<Key>>
+using HashMap = std::unordered_map<Key, Value, Hash>;
+template <typename Value, typename Hash = std::hash<Value>> using HashSet = std::unordered_set<Value, Hash>;
#endif
}; // namespace HashTables
+struct PairHash
+{
+ template <typename T1, typename T2> std::size_t operator()(const std::pair<T1, T2> &idp) const noexcept
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, std::hash<T1>()(idp.first));
+ boost::hash_combine(seed, std::hash<T2>()(idp.second));
+ return seed;
+ }
+};
+
NEXTPNR_NAMESPACE_END
#endif /* HASH_TABLE_H */
diff --git a/common/timing_opt.cc b/common/timing_opt.cc
index fd2a3f83..dba96bf1 100644
--- a/common/timing_opt.cc
+++ b/common/timing_opt.cc
@@ -35,44 +35,7 @@
#include "timing.h"
#include "util.h"
-namespace std {
-
-template <> struct hash<std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, NEXTPNR_NAMESPACE_PREFIX IdString>>
-{
- std::size_t operator()(
- const std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, NEXTPNR_NAMESPACE_PREFIX IdString> &idp) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(idp.first));
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(idp.second));
- return seed;
- }
-};
-
-template <> struct hash<std::pair<int, NEXTPNR_NAMESPACE_PREFIX BelId>>
-{
- std::size_t operator()(const std::pair<int, NEXTPNR_NAMESPACE_PREFIX BelId> &idp) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<int>()(idp.first));
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX BelId>()(idp.second));
- return seed;
- }
-};
-#if !defined(ARCH_GOWIN)
-template <> struct hash<std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, NEXTPNR_NAMESPACE_PREFIX BelId>>
-{
- std::size_t
- operator()(const std::pair<NEXTPNR_NAMESPACE_PREFIX IdString, NEXTPNR_NAMESPACE_PREFIX BelId> &idp) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(idp.first));
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX BelId>()(idp.second));
- return seed;
- }
-};
-#endif
-} // namespace std
+#include "hash_table.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -478,9 +441,9 @@ class TimingOptimiser
// Actual BFS path optimisation algorithm
std::unordered_map<IdString, std::unordered_map<BelId, delay_t>> cumul_costs;
- std::unordered_map<std::pair<IdString, BelId>, std::pair<IdString, BelId>> backtrace;
+ std::unordered_map<std::pair<IdString, BelId>, std::pair<IdString, BelId>, PairHash> backtrace;
std::queue<std::pair<int, BelId>> visit;
- std::unordered_set<std::pair<int, BelId>> to_visit;
+ std::unordered_set<std::pair<int, BelId>, PairHash> to_visit;
for (auto startbel : cell_neighbour_bels[path_cells.front()]) {
// Swap for legality check
@@ -609,7 +572,7 @@ class TimingOptimiser
std::unordered_map<IdString, std::unordered_set<BelId>> cell_neighbour_bels;
std::unordered_map<BelId, std::unordered_set<IdString>> bel_candidate_cells;
// Map cell ports to net delay limit
- std::unordered_map<std::pair<IdString, IdString>, delay_t> max_net_delay;
+ std::unordered_map<std::pair<IdString, IdString>, delay_t, PairHash> max_net_delay;
Context *ctx;
TimingOptCfg cfg;
TimingAnalyser tmg;