aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r--common/nextpnr.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 8ef958cd..4cdc4d00 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -27,6 +27,8 @@
#include <unordered_set>
#include <vector>
+#include <boost/functional/hash.hpp>
+
#ifndef NEXTPNR_H
#define NEXTPNR_H
@@ -161,10 +163,27 @@ struct GraphicElement
struct Loc
{
int x = -1, y = -1, z = -1;
+
+ bool operator==(const Loc &other) const { return (x == other.x) && (y == other.y) && (z == other.z); }
+ bool operator!=(const Loc &other) const { return (x != other.x) || (y != other.y) || (z == other.z); }
};
NEXTPNR_NAMESPACE_END
+namespace std {
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX Loc>
+{
+ std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Loc &obj) const noexcept
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, hash<int>()(obj.x));
+ boost::hash_combine(seed, hash<int>()(obj.y));
+ boost::hash_combine(seed, hash<int>()(obj.z));
+ return seed;
+ }
+};
+} // namespace std
+
#include "archdefs.h"
NEXTPNR_NAMESPACE_BEGIN