From c910846c5cefe03ce60d50418389f158846f8341 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 19 Jun 2018 12:08:37 +0200 Subject: Refactor Arch/Context design hierarchy Signed-off-by: Clifford Wolf --- ice40/arch.cc | 2 +- ice40/arch.h | 41 +++++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 23 deletions(-) (limited to 'ice40') 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 std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelId &bel) const noexcept { - return bel.index; + return hash()(bel.index); } }; @@ -267,18 +266,21 @@ template <> struct hash std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept { - return wire.index; + return hash()(wire.index); } }; template <> struct hash { - 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()(pip.index); } }; + +template <> struct hash : hash {}; +template <> struct hash : hash {}; } // 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 -{ - std::size_t operator()(NEXTPNR_NAMESPACE_PREFIX BelType bt) const noexcept - { - return std::hash()(int(bt)); - } -}; -} // namespace std - -#endif +#endif // NEXTPNR_ARCH_BOTTOM -- cgit v1.2.3