diff options
author | D. Shah <dave@ds0.me> | 2021-01-29 13:30:56 +0000 |
---|---|---|
committer | D. Shah <dave@ds0.me> | 2021-02-02 17:00:32 +0000 |
commit | d792bce0fb03529ee57b6f6ed5b0c234f503e452 (patch) | |
tree | dbc54e0d44ccd0ecfcb4a8c746e00ab2bdfa148b /common/nextpnr.h | |
parent | 9614d3722929f99520c6b83600641c14ef37188b (diff) | |
download | nextpnr-d792bce0fb03529ee57b6f6ed5b0c234f503e452.tar.gz nextpnr-d792bce0fb03529ee57b6f6ed5b0c234f503e452.tar.bz2 nextpnr-d792bce0fb03529ee57b6f6ed5b0c234f503e452.zip |
ecp5: Implement IdStringList for all arch object names
This is a complete implementation of IdStringList for ECP5; excluding
the GUI (which you will have to disable for it to build).
Signed-off-by: D. Shah <dave@ds0.me>
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r-- | common/nextpnr.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index 9523e418..19d919e1 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -235,8 +235,28 @@ struct IdStringList const IdString *begin() const { return ids.begin(); } const IdString *end() const { return ids.end(); } const IdString &operator[](size_t idx) const { return ids[idx]; } + bool operator==(const IdStringList &other) const { return ids == other.ids; } + bool operator!=(const IdStringList &other) const { return ids != other.ids; } }; +NEXTPNR_NAMESPACE_END + +namespace std { +template <> struct hash<NEXTPNR_NAMESPACE_PREFIX IdStringList> +{ + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX IdStringList &obj) const noexcept + { + std::size_t seed = 0; + boost::hash_combine(seed, hash<size_t>()(obj.size())); + for (auto &id : obj) + boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(id)); + return seed; + } +}; +} // namespace std + +NEXTPNR_NAMESPACE_BEGIN + // A ring buffer of strings, so we can return a simple const char * pointer for %s formatting - inspired by how logging // in Yosys works Let's just hope noone tries to log more than 100 things in one call.... class StrRingBuffer @@ -890,8 +910,11 @@ struct BaseCtx const char *nameOfPip(PipId pip) const; const char *nameOfGroup(GroupId group) const; - // Overrides of arch functions that take a string and handle IdStringList parsing + // Wrappers of arch functions that take a string and handle IdStringList parsing BelId getBelByNameStr(const std::string &str); + WireId getWireByNameStr(const std::string &str); + PipId getPipByNameStr(const std::string &str); + GroupId getGroupByNameStr(const std::string &str); // -------------------------------------------------------------- |