diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-07-12 17:22:29 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-07-12 17:22:29 +0200 |
commit | a436035424368b3d424822c7b72f99044c93dafd (patch) | |
tree | 9bbf888bc6db482b42677656f4ee3fd4357355e8 /ice40/archdefs.h | |
parent | 1245eb6343f272b6aeb096b0d41407c5ea6bc5cd (diff) | |
download | nextpnr-a436035424368b3d424822c7b72f99044c93dafd.tar.gz nextpnr-a436035424368b3d424822c7b72f99044c93dafd.tar.bz2 nextpnr-a436035424368b3d424822c7b72f99044c93dafd.zip |
Add Groups API
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'ice40/archdefs.h')
-rw-r--r-- | ice40/archdefs.h | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/ice40/archdefs.h b/ice40/archdefs.h index 061e9b44..62c248c7 100644 --- a/ice40/archdefs.h +++ b/ice40/archdefs.h @@ -109,11 +109,42 @@ struct PipId bool operator!=(const PipId &other) const { return index != other.index; } }; +struct GroupId +{ + enum : int8_t { + TYPE_NONE, + TYPE_FRAME, + TYPE_MAIN_SW, + TYPE_LOCAL_SW, + TYPE_LC0_SW, + TYPE_LC1_SW, + TYPE_LC2_SW, + TYPE_LC3_SW, + TYPE_LC4_SW, + TYPE_LC5_SW, + TYPE_LC6_SW, + TYPE_LC7_SW + } type = TYPE_NONE; + int8_t x = 0, y = 0; + + 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); } +}; + struct DecalId { - char type = 0; // Bel/Wire/Pip/Frame (b/w/p/f) - uint8_t x = 0, y = 0; - uint32_t z = 0; + enum : int8_t { + TYPE_NONE, + TYPE_FRAME, + TYPE_BEL, + TYPE_WIRE, + TYPE_PIP, + TYPE_GROUP + } type = TYPE_NONE; + int32_t index = -1; + + 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); } }; NEXTPNR_NAMESPACE_END @@ -145,14 +176,23 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PortPin> : hash<int> { }; +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.x)); - boost::hash_combine(seed, hash<int>()(decal.y)); - boost::hash_combine(seed, hash<int>()(decal.z)); + boost::hash_combine(seed, hash<int>()(decal.index)); return seed; } }; |