aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/idstring.h2
-rw-r--r--common/idstringlist.h9
-rw-r--r--docs/archapi.md14
-rw-r--r--ecp5/archdefs.h7
-rw-r--r--fpga_interchange/archdefs.h5
-rw-r--r--ice40/archdefs.h6
-rw-r--r--machxo2/archdefs.h5
-rw-r--r--mistral/archdefs.h4
-rw-r--r--nexus/archdefs.h6
9 files changed, 51 insertions, 7 deletions
diff --git a/common/idstring.h b/common/idstring.h
index c3ccbc6b..aba40ae6 100644
--- a/common/idstring.h
+++ b/common/idstring.h
@@ -56,6 +56,8 @@ struct IdString
bool operator!=(const IdString &other) const { return index != other.index; }
bool empty() const { return index == 0; }
+
+ unsigned int hash() const { return index; }
};
NEXTPNR_NAMESPACE_END
diff --git a/common/idstringlist.h b/common/idstringlist.h
index 24a46731..753b408c 100644
--- a/common/idstringlist.h
+++ b/common/idstringlist.h
@@ -22,6 +22,7 @@
#define IDSTRING_LIST_H
#include <boost/functional/hash.hpp>
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
#include "sso_array.h"
@@ -67,6 +68,14 @@ struct IdStringList
static IdStringList concat(IdStringList a, IdStringList b);
IdStringList slice(size_t s, size_t e) const;
+
+ unsigned int hash() const
+ {
+ unsigned int h = mkhash_init;
+ for (const auto &val : ids)
+ h = mkhash(h, val.hash());
+ return h;
+ }
};
NEXTPNR_NAMESPACE_END
diff --git a/docs/archapi.md b/docs/archapi.md
index 6d17f01a..80aa1d96 100644
--- a/docs/archapi.md
+++ b/docs/archapi.md
@@ -45,31 +45,31 @@ A scalar type that is used to represent delays. May be an integer or float type
### BelId
-A type representing a bel name. `BelId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a specialization for `std::hash<BelId>`.
+A type representing a bel name. `BelId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a `unsigned int hash() const` member function.
### WireId
-A type representing a wire name. `WireId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a specialization for `std::hash<WireId>`.
+A type representing a wire name. `WireId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a `unsigned int hash() const` member function.
### PipId
-A type representing a pip name. `PipId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a specialization for `std::hash<PipId>`.
+A type representing a pip name. `PipId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a `unsigned int hash() const` member function.
### BelBucketId
-A type representing a bel bucket. `BelBucketId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a specialization for `std::hash<BelBucketId>`.
+A type representing a bel bucket. `BelBucketId()` must construct a unique null-value. Must provide `==`, `!=`, and `<` operators and a `unsigned int hash() const` member function.
### GroupId
-A type representing a group name. `GroupId()` must construct a unique null-value. Must provide `==` and `!=` operators and a specialization for `std::hash<GroupId>`.
+A type representing a group name. `GroupId()` must construct a unique null-value. Must provide `==` and `!=` operators and a `unsigned int hash() const` member function.
### DecalId
-A type representing a reference to a graphical decal. `DecalId()` must construct a unique null-value. Must provide `==` and `!=` operators and a specialization for `std::hash<DecalId>`.
+A type representing a reference to a graphical decal. `DecalId()` must construct a unique null-value. Must provide `==` and `!=` operators and a `unsigned int hash() const` member function.
### ClusterId
-A type representing a reference to a constrained cluster of cells. `ClusterId()` must construct a unique null-value. Must provide `==` and `!=` operators and a specialization for `std::hash<ClusterId>`.
+A type representing a reference to a constrained cluster of cells. `ClusterId()` must construct a unique null-value. Must provide `==` and `!=` operators and `unsigned int hash() const` member function.
### ArchNetInfo
diff --git a/ecp5/archdefs.h b/ecp5/archdefs.h
index 2b4590e5..57168af3 100644
--- a/ecp5/archdefs.h
+++ b/ecp5/archdefs.h
@@ -24,6 +24,7 @@
#include <boost/functional/hash.hpp>
#include "base_clusterinfo.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
@@ -63,6 +64,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 +80,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 +94,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 +108,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 +124,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 +148,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
diff --git a/fpga_interchange/archdefs.h b/fpga_interchange/archdefs.h
index c145b893..aa3f1e6e 100644
--- a/fpga_interchange/archdefs.h
+++ b/fpga_interchange/archdefs.h
@@ -25,6 +25,7 @@
#include <cstdint>
#include "hash_table.h"
+#include "hashlib.h"
#include "luts.h"
#include "nextpnr_namespaces.h"
@@ -48,6 +49,7 @@ struct BelId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
struct WireId
@@ -62,6 +64,7 @@ struct WireId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
struct PipId
@@ -75,6 +78,7 @@ struct PipId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
struct GroupId
@@ -96,6 +100,7 @@ struct BelBucketId
bool operator==(const BelBucketId &other) const { return (name == other.name); }
bool operator!=(const BelBucketId &other) const { return (name != other.name); }
bool operator<(const BelBucketId &other) const { return name < other.name; }
+ unsigned int hash() const { return name.hash(); }
};
typedef IdString ClusterId;
diff --git a/ice40/archdefs.h b/ice40/archdefs.h
index c2b7019c..2d962851 100644
--- a/ice40/archdefs.h
+++ b/ice40/archdefs.h
@@ -23,6 +23,7 @@
#include <boost/functional/hash.hpp>
#include "base_clusterinfo.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
@@ -55,6 +56,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 +66,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 +76,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 +100,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 +118,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
diff --git a/machxo2/archdefs.h b/machxo2/archdefs.h
index 2d50dddb..afcc72aa 100644
--- a/machxo2/archdefs.h
+++ b/machxo2/archdefs.h
@@ -22,6 +22,7 @@
#define MACHXO2_ARCHDEFS_H
#include "base_clusterinfo.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
@@ -59,6 +60,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); }
@@ -74,6 +76,7 @@ struct BelId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
struct WireId
@@ -87,6 +90,7 @@ struct WireId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
struct PipId
@@ -100,6 +104,7 @@ struct PipId
{
return location == other.location ? index < other.index : location < other.location;
}
+ unsigned int hash() const { return mkhash(location.hash(), index); }
};
typedef IdString GroupId;
diff --git a/mistral/archdefs.h b/mistral/archdefs.h
index 60bdcfeb..9d953223 100644
--- a/mistral/archdefs.h
+++ b/mistral/archdefs.h
@@ -25,6 +25,7 @@
#include "base_clusterinfo.h"
#include "cyclonev.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_assertions.h"
#include "nextpnr_namespaces.h"
@@ -84,6 +85,7 @@ struct BelId
bool operator==(const BelId &other) const { return pos == other.pos && z == other.z; }
bool operator!=(const BelId &other) const { return pos != other.pos || z != other.z; }
bool operator<(const BelId &other) const { return pos < other.pos || (pos == other.pos && z < other.z); }
+ unsigned int hash() const { return mkhash(pos, z); }
};
static constexpr auto invalid_rnode = std::numeric_limits<CycloneV::rnode_t>::max();
@@ -104,6 +106,7 @@ struct WireId
bool operator==(const WireId &other) const { return node == other.node; }
bool operator!=(const WireId &other) const { return node != other.node; }
bool operator<(const WireId &other) const { return node < other.node; }
+ unsigned int hash() const { return unsigned(node); }
};
struct PipId
@@ -115,6 +118,7 @@ struct PipId
bool operator==(const PipId &other) const { return src == other.src && dst == other.dst; }
bool operator!=(const PipId &other) const { return src != other.src || dst != other.dst; }
bool operator<(const PipId &other) const { return dst < other.dst || (dst == other.dst && src < other.src); }
+ unsigned int hash() const { return mkhash(src, dst); }
};
typedef IdString DecalId;
diff --git a/nexus/archdefs.h b/nexus/archdefs.h
index 660f166c..db8a3af4 100644
--- a/nexus/archdefs.h
+++ b/nexus/archdefs.h
@@ -24,6 +24,7 @@
#include <unordered_map>
#include "base_clusterinfo.h"
+#include "hashlib.h"
#include "idstring.h"
#include "nextpnr_namespaces.h"
@@ -62,6 +63,7 @@ struct BelId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
struct WireId
@@ -80,6 +82,7 @@ struct WireId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
struct PipId
@@ -97,6 +100,7 @@ struct PipId
{
return tile < other.tile || (tile == other.tile && index < other.index);
}
+ unsigned int hash() const { return mkhash(tile, index); }
};
typedef IdString BelBucketId;
@@ -111,6 +115,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
@@ -134,6 +139,7 @@ struct DecalId
{
return (type != other.type) || (index != other.index) || (active != other.active);
}
+ unsigned int hash() const { return mkhash(index, int(type)); }
};
struct ArchNetInfo