aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-07-20 17:33:57 +0200
committerClifford Wolf <clifford@clifford.at>2018-07-20 17:33:57 +0200
commitf6fa0300ae95a0896a12b9acf0c7e76851c13d37 (patch)
tree13fbcf6ace44f5c523830469104314474534009e /common
parente16b4a325e2b0721e29cba93804923dedf74a68c (diff)
downloadnextpnr-f6fa0300ae95a0896a12b9acf0c7e76851c13d37.tar.gz
nextpnr-f6fa0300ae95a0896a12b9acf0c7e76851c13d37.tar.bz2
nextpnr-f6fa0300ae95a0896a12b9acf0c7e76851c13d37.zip
Improve iCE40 and common Loc code
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'common')
-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