aboutsummaryrefslogtreecommitdiffstats
path: root/fpga_interchange
diff options
context:
space:
mode:
authorKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-17 10:18:24 -0800
committerKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-17 12:03:17 -0800
commit558a753d3da5a2243a74b8d4e1c24044bdfb5c2e (patch)
tree391052b070b0965e5a73d27c204089c042499275 /fpga_interchange
parent9e0ca7282743afd6a17fe347c1ad3a5d1cd4070d (diff)
downloadnextpnr-558a753d3da5a2243a74b8d4e1c24044bdfb5c2e.tar.gz
nextpnr-558a753d3da5a2243a74b8d4e1c24044bdfb5c2e.tar.bz2
nextpnr-558a753d3da5a2243a74b8d4e1c24044bdfb5c2e.zip
Refactor "get only from iterator" to a utility.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
Diffstat (limited to 'fpga_interchange')
-rw-r--r--fpga_interchange/arch.cc7
-rw-r--r--fpga_interchange/arch.h6
-rw-r--r--fpga_interchange/arch_pack_io.cc8
3 files changed, 9 insertions, 12 deletions
diff --git a/fpga_interchange/arch.cc b/fpga_interchange/arch.cc
index 561f495d..cce93844 100644
--- a/fpga_interchange/arch.cc
+++ b/fpga_interchange/arch.cc
@@ -806,11 +806,8 @@ void Arch::map_cell_pins(CellInfo *cell, int32_t mapping) const
void Arch::map_port_pins(BelId bel, CellInfo *cell) const
{
IdStringRange pins = getBelPins(bel);
- NPNR_ASSERT(pins.begin() != pins.end());
- auto b = pins.begin();
- IdString pin = *b;
- ++b;
- NPNR_ASSERT(b == pins.end());
+ IdString pin = get_only_value(pins);
+
NPNR_ASSERT(cell->ports.size() == 1);
cell->cell_bel_pins[cell->ports.begin()->first].clear();
cell->cell_bel_pins[cell->ports.begin()->first].push_back(pin);
diff --git a/fpga_interchange/arch.h b/fpga_interchange/arch.h
index 556aa566..1daf5526 100644
--- a/fpga_interchange/arch.h
+++ b/fpga_interchange/arch.h
@@ -656,7 +656,11 @@ struct BelPinRange
BelPinIterator end() const { return e; }
};
-struct IdStringIterator
+struct IdStringIterator : std::iterator<std::forward_iterator_tag,
+ /*T=*/IdString,
+ /*Distance=*/ptrdiff_t,
+ /*pointer=*/IdString *,
+ /*reference=*/IdString>
{
const int32_t *cursor;
diff --git a/fpga_interchange/arch_pack_io.cc b/fpga_interchange/arch_pack_io.cc
index 8a0fdc05..6a0ffe0b 100644
--- a/fpga_interchange/arch_pack_io.cc
+++ b/fpga_interchange/arch_pack_io.cc
@@ -20,6 +20,7 @@
#include "log.h"
#include "nextpnr.h"
+#include "util.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -235,12 +236,7 @@ void Arch::pack_ports()
placed_cells.emplace(port_cell);
IdStringRange package_bel_pins = getBelPins(package_bel);
- // NPNR_ASSERT(std::distance(package_bel_pins.begin(), package_bel_pins.end()) == 1);
- IdStringIterator b = package_bel_pins.begin();
- NPNR_ASSERT(b != package_bel_pins.end());
- ++b;
- NPNR_ASSERT(b == package_bel_pins.end());
- IdString pad_pin = *package_bel_pins.begin();
+ IdString pad_pin = get_only_value(package_bel_pins);
WireId pad_wire = getBelPinWire(package_bel, pad_pin);
place_iobufs(pad_wire, ports[port_pair.first].net, tightly_attached_bels, &placed_cells);