From e13fc7edabb449d21ad6473bab23d5c1b2cf3761 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 22 Jul 2018 12:08:52 +0200 Subject: Add Arch::getBelPins() to generic and iCE40 archs Signed-off-by: Clifford Wolf --- generic/arch.cc | 7 +++++++ generic/arch.h | 1 + ice40/arch.cc | 15 +++++++++++++++ ice40/arch.h | 2 ++ 4 files changed, 25 insertions(+) diff --git a/generic/arch.cc b/generic/arch.cc index 8c7a7670..0f2f5fe3 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -226,6 +226,13 @@ BelPin Arch::getBelPinUphill(WireId wire) const { return wires.at(wire).uphill_b const std::vector &Arch::getBelPinsDownhill(WireId wire) const { return wires.at(wire).downhill_bel_pins; } +std::vector Arch::getBelPins(BelId bel) const +{ + std::vector ret; + for (auto &it : bels.at(bel).pins) + ret.push_back(it.first); +} + // --------------------------------------------------------------- WireId Arch::getWireByName(IdString name) const diff --git a/generic/arch.h b/generic/arch.h index 2a74b1ae..e650906d 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -150,6 +150,7 @@ struct Arch : BaseCtx PortType getBelPinType(BelId bel, PortPin pin) const; BelPin getBelPinUphill(WireId wire) const NPNR_DEPRECATED; const std::vector &getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED; + std::vector getBelPins(BelId bel) const; WireId getWireByName(IdString name) const; IdString getWireName(WireId wire) const; diff --git a/ice40/arch.cc b/ice40/arch.cc index 5f0384a3..65b21afd 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -340,6 +340,21 @@ WireId Arch::getBelPinWire(BelId bel, PortPin pin) const return ret; } +std::vector Arch::getBelPins(BelId bel) const +{ + std::vector ret; + + NPNR_ASSERT(bel != BelId()); + + int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires; + const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get(); + + for (int i = 0; i < num_bel_wires; i++) + ret.push_back(bel_wires[i].port); + + return ret; +} + // ----------------------------------------------------------------------- WireId Arch::getWireByName(IdString name) const diff --git a/ice40/arch.h b/ice40/arch.h index f3016424..2e2018fb 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -494,6 +494,8 @@ struct Arch : BaseCtx return range; } + std::vector getBelPins(BelId bel) const; + // ------------------------------------------------- WireId getWireByName(IdString name) const; -- cgit v1.2.3