aboutsummaryrefslogtreecommitdiffstats
path: root/machxo2/archdefs.h
diff options
context:
space:
mode:
authorWilliam D. Jones <thor0505@comcast.net>2020-12-07 17:41:34 -0500
committergatecat <gatecat@ds0.me>2021-02-12 10:36:59 +0000
commita7917c9c63efe654a24a4136a91fa4558ee2c625 (patch)
treeca683477bc179094c7672d687016df1de57c971b /machxo2/archdefs.h
parentbbc683dd75fcf54b8f215704a932c5c2f1a39c93 (diff)
downloadnextpnr-a7917c9c63efe654a24a4136a91fa4558ee2c625.tar.gz
nextpnr-a7917c9c63efe654a24a4136a91fa4558ee2c625.tar.bz2
nextpnr-a7917c9c63efe654a24a4136a91fa4558ee2c625.zip
machxo2: Implement WireId/PipId, complete Bel part of API.
Diffstat (limited to 'machxo2/archdefs.h')
-rw-r--r--machxo2/archdefs.h48
1 files changed, 46 insertions, 2 deletions
diff --git a/machxo2/archdefs.h b/machxo2/archdefs.h
index d33a3a3d..5852d24b 100644
--- a/machxo2/archdefs.h
+++ b/machxo2/archdefs.h
@@ -90,8 +90,32 @@ struct BelId
}
};
-typedef IdString WireId;
-typedef IdString PipId;
+struct WireId
+{
+ Location location;
+ int32_t index = -1;
+
+ bool operator==(const WireId &other) const { return index == other.index && location == other.location; }
+ bool operator!=(const WireId &other) const { return index != other.index || location != other.location; }
+ bool operator<(const WireId &other) const
+ {
+ return location == other.location ? index < other.index : location < other.location;
+ }
+};
+
+struct PipId
+{
+ Location location;
+ int32_t index = -1;
+
+ bool operator==(const PipId &other) const { return index == other.index && location == other.location; }
+ bool operator!=(const PipId &other) const { return index != other.index || location != other.location; }
+ bool operator<(const PipId &other) const
+ {
+ return location == other.location ? index < other.index : location < other.location;
+ }
+};
+
typedef IdString GroupId;
typedef IdString DecalId;
@@ -135,4 +159,24 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId>
}
};
+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;
+ }
+};
+
}