From c0f1af87f6c1c6843e536a87ef88e39fa3428c5b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 17 Jul 2018 17:03:44 +0200 Subject: Add Loc struct for x/y/z bel locations Signed-off-by: Clifford Wolf --- common/nextpnr.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 50465869..375e1cd7 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -157,6 +157,11 @@ struct GraphicElement std::string text; }; +struct Loc +{ + int x = -1, y = -1, z = -1; +}; + NEXTPNR_NAMESPACE_END #include "archdefs.h" @@ -310,6 +315,10 @@ struct Context : Arch Context(ArchArgs args) : Arch(args) {} + BelId getBelByLocation(Loc loc) const { + return getBelByLocation(loc.x, loc.y, loc.z); + } + // -------------------------------------------------------------- // provided by router1.cc -- cgit v1.2.3 From f6fa0300ae95a0896a12b9acf0c7e76851c13d37 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 20 Jul 2018 17:33:57 +0200 Subject: Improve iCE40 and common Loc code Signed-off-by: Clifford Wolf --- common/nextpnr.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common/nextpnr.h') 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 #include +#include + #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 +{ + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Loc &obj) const noexcept + { + std::size_t seed = 0; + boost::hash_combine(seed, hash()(obj.x)); + boost::hash_combine(seed, hash()(obj.y)); + boost::hash_combine(seed, hash()(obj.z)); + return seed; + } +}; +} // namespace std + #include "archdefs.h" NEXTPNR_NAMESPACE_BEGIN -- cgit v1.2.3 From fd8239e170a7391d9c25d8681083507d9960abef Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 20 Jul 2018 18:09:22 +0200 Subject: Add Location APIs to generic arch Signed-off-by: Clifford Wolf --- common/nextpnr.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 4cdc4d00..40fd3d13 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -339,10 +339,6 @@ struct Context : Arch Context(ArchArgs args) : Arch(args) {} - BelId getBelByLocation(Loc loc) const { - return getBelByLocation(loc.x, loc.y, loc.z); - } - // -------------------------------------------------------------- // provided by router1.cc -- cgit v1.2.3