aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-06-19 12:08:37 +0200
committerClifford Wolf <clifford@clifford.at>2018-06-19 12:08:37 +0200
commitc910846c5cefe03ce60d50418389f158846f8341 (patch)
tree6c0da0ba4c22c4309ed5c6ee7b11e66826950b7f /ice40
parente3519ddfcdfa0e0d3a2942ecf4802c3751db0e17 (diff)
downloadnextpnr-c910846c5cefe03ce60d50418389f158846f8341.tar.gz
nextpnr-c910846c5cefe03ce60d50418389f158846f8341.tar.bz2
nextpnr-c910846c5cefe03ce60d50418389f158846f8341.zip
Refactor Arch/Context design hierarchy
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/arch.cc2
-rw-r--r--ice40/arch.h41
2 files changed, 20 insertions, 23 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 83a6e542..ba372410 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -54,7 +54,7 @@ BelType Arch::belTypeFromId(IdString type) const
// -----------------------------------------------------------------------
-void IdString::initialize_arch(const Context *ctx)
+void IdString::initialize_arch(const BaseCtx *ctx)
{
#define X(t) initialize_add(ctx, #t, PIN_##t);
#include "portpins.inc"
diff --git a/ice40/arch.h b/ice40/arch.h
index 2702e70e..0fdacfde 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -17,13 +17,12 @@
*
*/
-#ifndef CHIP_H
-#define CHIP_H
-
#ifndef NEXTPNR_H
#error Include "arch.h" via "nextpnr.h" only.
#endif
+#ifdef NEXTPNR_ARCH_TOP
+
NEXTPNR_NAMESPACE_BEGIN
typedef int delay_t;
@@ -258,7 +257,7 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelId>
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const
noexcept
{
- return bel.index;
+ return hash<int>()(bel.index);
}
};
@@ -267,18 +266,21 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId>
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const
noexcept
{
- return wire.index;
+ return hash<int>()(wire.index);
}
};
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId>
{
- std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &wire) const
+ std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const
noexcept
{
- return wire.index;
+ return hash<int>()(pip.index);
}
};
+
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelType> : hash<int> {};
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PortPin> : hash<int> {};
} // namespace std
NEXTPNR_NAMESPACE_BEGIN
@@ -435,8 +437,16 @@ struct PipRange
PipIterator end() const { return e; }
};
+NEXTPNR_NAMESPACE_END
+
+#endif // NEXTPNR_ARCH_TOP
+
// -----------------------------------------------------------------------
+#ifdef NEXTPNR_ARCH_BOTTOM
+
+NEXTPNR_NAMESPACE_BEGIN
+
struct ArchArgs
{
enum
@@ -452,7 +462,7 @@ struct ArchArgs
std::string package;
};
-struct Arch
+struct Arch : BaseCtx
{
const ChipInfoPOD *chip_info;
const PackageInfoPOD *package_info;
@@ -471,9 +481,6 @@ struct Arch
std::string getChipName();
- virtual IdString id(const std::string &s) const { abort(); }
- virtual IdString id(const char *s) const { abort(); }
-
IdString belTypeToId(BelType type) const;
BelType belTypeFromId(IdString id) const;
@@ -747,14 +754,4 @@ struct Arch
NEXTPNR_NAMESPACE_END
-namespace std {
-template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelType>
-{
- std::size_t operator()(NEXTPNR_NAMESPACE_PREFIX BelType bt) const noexcept
- {
- return std::hash<int>()(int(bt));
- }
-};
-} // namespace std
-
-#endif
+#endif // NEXTPNR_ARCH_BOTTOM