aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/archdefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'ecp5/archdefs.h')
-rw-r--r--ecp5/archdefs.h77
1 files changed, 7 insertions, 70 deletions
diff --git a/ecp5/archdefs.h b/ecp5/archdefs.h
index 2b4590e5..6243a9df 100644
--- a/ecp5/archdefs.h
+++ b/ecp5/archdefs.h
@@ -21,9 +21,8 @@
#ifndef ECP5_ARCHDEFS_H
#define ECP5_ARCHDEFS_H
-#include <boost/functional/hash.hpp>
-
#include "base_clusterinfo.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
@@ -63,6 +62,7 @@ struct Location
bool operator==(const Location &other) const { return x == other.x && y == other.y; }
bool operator!=(const Location &other) const { return x != other.x || y != other.y; }
bool operator<(const Location &other) const { return y == other.y ? x < other.x : y < other.y; }
+ unsigned int hash() const { return mkhash(x, y); }
};
inline Location operator+(const Location &a, const Location &b) { return Location(a.x + b.x, a.y + b.y); }
@@ -78,6 +78,7 @@ struct BelId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
struct WireId
@@ -91,6 +92,7 @@ struct WireId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
struct PipId
@@ -104,6 +106,7 @@ struct PipId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
typedef IdString BelBucketId;
@@ -119,6 +122,7 @@ struct GroupId
bool operator==(const GroupId &other) const { return (type == other.type) && (location == other.location); }
bool operator!=(const GroupId &other) const { return (type != other.type) || (location != other.location); }
+ unsigned int hash() const { return mkhash(location.hash(), int(type)); }
};
struct DecalId
@@ -142,6 +146,7 @@ struct DecalId
{
return type != other.type || location != other.location || z != other.z || active != other.active;
}
+ unsigned int hash() const { return mkhash(location.hash(), mkhash(z, int(type))); }
};
struct ArchNetInfo
@@ -180,72 +185,4 @@ struct ArchCellInfo : BaseClusterInfo
};
NEXTPNR_NAMESPACE_END
-
-namespace std {
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX Location>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Location &loc) const noexcept
- {
- std::size_t seed = std::hash<int>()(loc.x);
- seed ^= std::hash<int>()(loc.y) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
- return seed;
- }
-};
-
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept
- {
- std::size_t seed = std::hash<NEXTPNR_NAMESPACE_PREFIX Location>()(bel.location);
- seed ^= std::hash<int>()(bel.index) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
- return seed;
- }
-};
-
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept
- {
- std::size_t seed = std::hash<NEXTPNR_NAMESPACE_PREFIX Location>()(wire.location);
- seed ^= std::hash<int>()(wire.index) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
- return seed;
- }
-};
-
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept
- {
- std::size_t seed = std::hash<NEXTPNR_NAMESPACE_PREFIX Location>()(pip.location);
- seed ^= std::hash<int>()(pip.index) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
- return seed;
- }
-};
-
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX GroupId>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX GroupId &group) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<int>()(group.type));
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX Location>()(group.location));
- return seed;
- }
-};
-
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
-{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX DecalId &decal) const noexcept
- {
- std::size_t seed = 0;
- boost::hash_combine(seed, hash<int>()(decal.type));
- boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX Location>()(decal.location));
- boost::hash_combine(seed, hash<int>()(decal.z));
- boost::hash_combine(seed, hash<bool>()(decal.active));
- return seed;
- }
-};
-
-} // namespace std
-
#endif /* ECP5_ARCHDEFS_H */