aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/arch.cc7
-rw-r--r--generic/arch.h1
-rw-r--r--ice40/arch.cc15
-rw-r--r--ice40/arch.h2
4 files changed, 25 insertions, 0 deletions
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<BelPin> &Arch::getBelPinsDownhill(WireId wire) const { return wires.at(wire).downhill_bel_pins; }
+std::vector<PortPin> Arch::getBelPins(BelId bel) const
+{
+ std::vector<PortPin> 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<BelPin> &getBelPinsDownhill(WireId wire) const NPNR_DEPRECATED;
+ std::vector<PortPin> 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<PortPin> Arch::getBelPins(BelId bel) const
+{
+ std::vector<PortPin> 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<PortPin> getBelPins(BelId bel) const;
+
// -------------------------------------------------
WireId getWireByName(IdString name) const;