diff options
author | gatecat <gatecat@ds0.me> | 2021-02-19 08:41:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 08:41:58 +0000 |
commit | 5dcb59b13decab276ac736b0b06b4ccebcf83f62 (patch) | |
tree | 67017806da1d36a6ec13fc538390b875b30309ab /common/util.h | |
parent | b4a97efe4da95084ba5585c48d20681f68742fd4 (diff) | |
parent | c21e23b3eb6fee48c2b2da384b2dd0cd2d4ad91f (diff) | |
download | nextpnr-5dcb59b13decab276ac736b0b06b4ccebcf83f62.tar.gz nextpnr-5dcb59b13decab276ac736b0b06b4ccebcf83f62.tar.bz2 nextpnr-5dcb59b13decab276ac736b0b06b4ccebcf83f62.zip |
Merge pull request #576 from litghost/add_cell_bel_pin_mapping
Complete FPGA interchange Arch to the point where it can route a wire
Diffstat (limited to 'common/util.h')
-rw-r--r-- | common/util.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h index 07ebac75..55718344 100644 --- a/common/util.h +++ b/common/util.h @@ -158,6 +158,29 @@ inline NetInfo *get_net_or_empty(CellInfo *cell, const IdString port) return nullptr; } +// Get only value from a forward iterator begin/end pair. +// +// Generates assertion failure if std::distance(begin, end) != 1. +template <typename ForwardIterator> +inline const typename ForwardIterator::reference get_only_value(ForwardIterator begin, ForwardIterator end) +{ + NPNR_ASSERT(begin != end); + const typename ForwardIterator::reference ret = *begin; + ++begin; + NPNR_ASSERT(begin == end); + return ret; +} + +// Get only value from a forward iterator range pair. +// +// Generates assertion failure if std::distance(r.begin(), r.end()) != 1. +template <typename ForwardRange> inline auto get_only_value(ForwardRange r) +{ + auto b = r.begin(); + auto e = r.end(); + return get_only_value(b, e); +} + NEXTPNR_NAMESPACE_END #endif |