diff options
Diffstat (limited to 'ice40/archdefs.h')
-rw-r--r-- | ice40/archdefs.h | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/ice40/archdefs.h b/ice40/archdefs.h index c2b7019c..6ef5432f 100644 --- a/ice40/archdefs.h +++ b/ice40/archdefs.h @@ -20,9 +20,8 @@ #ifndef ICE40_ARCHDEFS_H #define ICE40_ARCHDEFS_H -#include <boost/functional/hash.hpp> - #include "base_clusterinfo.h" +#include "hashlib.h" #include "idstring.h" #include "nextpnr_namespaces.h" @@ -55,6 +54,7 @@ struct BelId bool operator==(const BelId &other) const { return index == other.index; } bool operator!=(const BelId &other) const { return index != other.index; } bool operator<(const BelId &other) const { return index < other.index; } + unsigned int hash() const { return index; } }; struct WireId @@ -64,6 +64,7 @@ struct WireId bool operator==(const WireId &other) const { return index == other.index; } bool operator!=(const WireId &other) const { return index != other.index; } bool operator<(const WireId &other) const { return index < other.index; } + unsigned int hash() const { return index; } }; struct PipId @@ -73,6 +74,7 @@ struct PipId bool operator==(const PipId &other) const { return index == other.index; } bool operator!=(const PipId &other) const { return index != other.index; } bool operator<(const PipId &other) const { return index < other.index; } + unsigned int hash() const { return index; } }; struct GroupId @@ -96,6 +98,7 @@ struct GroupId bool operator==(const GroupId &other) const { return (type == other.type) && (x == other.x) && (y == other.y); } bool operator!=(const GroupId &other) const { return (type != other.type) || (x != other.x) || (y == other.y); } + unsigned int hash() const { return mkhash(mkhash(x, y), int(type)); } }; struct DecalId @@ -113,6 +116,7 @@ struct DecalId bool operator==(const DecalId &other) const { return (type == other.type) && (index == other.index); } bool operator!=(const DecalId &other) const { return (type != other.type) || (index != other.index); } + unsigned int hash() const { return mkhash(index, int(type)); } }; struct ArchNetInfo @@ -159,48 +163,4 @@ typedef IdString ClusterId; NEXTPNR_NAMESPACE_END -namespace std { -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept { return hash<int>()(bel.index); } -}; - -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept - { - return hash<int>()(wire.index); - } -}; - -template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId> -{ - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept { return hash<int>()(pip.index); } -}; - -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<int>()(group.x)); - boost::hash_combine(seed, hash<int>()(group.y)); - 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<int>()(decal.index)); - return seed; - } -}; - -} // namespace std - #endif /* ICE40_ARCHDEFS_H */ |