aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-23 19:15:59 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-23 19:15:59 +0200
commit730e56e3ddf4959c061211eacf1180170b0c4b1b (patch)
tree85e799401db7b832393b0c02f719d2949633a0a8
parentbaa673f9edcd03a9a0e7be39a69e6223425edd5f (diff)
downloadnextpnr-730e56e3ddf4959c061211eacf1180170b0c4b1b.tar.gz
nextpnr-730e56e3ddf4959c061211eacf1180170b0c4b1b.tar.bz2
nextpnr-730e56e3ddf4959c061211eacf1180170b0c4b1b.zip
ecp5: Add some more PIO helper functions
Signed-off-by: David Shah <davey1576@gmail.com>
-rw-r--r--ecp5/arch.cc38
-rw-r--r--ecp5/arch.h4
2 files changed, 42 insertions, 0 deletions
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 7ac56378..7d67dd0c 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -329,6 +329,44 @@ std::string Arch::getBelPackagePin(BelId bel) const
return "";
}
+int Arch::getPioBelBank(BelId bel) const
+{
+ for (int i = 0; i < chip_info->num_pios; i++) {
+ if (chip_info->pio_info[i].abs_loc == bel.location && chip_info->pio_info[i].bel_index == bel.index) {
+ return chip_info->pio_info[i].bank;
+ }
+ }
+ NPNR_ASSERT_FALSE("failed to find PIO");
+}
+
+std::string Arch::getPioFunctionName(BelId bel) const
+{
+ for (int i = 0; i < chip_info->num_pios; i++) {
+ if (chip_info->pio_info[i].abs_loc == bel.location && chip_info->pio_info[i].bel_index == bel.index) {
+ const char *func = chip_info->pio_info[i].function_name.get();
+ if (func == nullptr)
+ return "";
+ else
+ return func;
+ }
+ }
+ NPNR_ASSERT_FALSE("failed to find PIO");
+}
+
+BelId Arch::getPioByFunctionName(const std::string &name) const
+{
+ for (int i = 0; i < chip_info->num_pios; i++) {
+ const char *func = chip_info->pio_info[i].function_name.get();
+ if (func != nullptr && func == name) {
+ BelId bel;
+ bel.location = chip_info->pio_info[i].abs_loc;
+ bel.index = chip_info->pio_info[i].bel_index;
+ return bel;
+ }
+ }
+ return BelId();
+}
+
std::vector<PortPin> Arch::getBelPins(BelId bel) const
{
diff --git a/ecp5/arch.h b/ecp5/arch.h
index b3ef5195..ce2b90c3 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -733,6 +733,10 @@ struct Arch : BaseCtx
BelId getPackagePinBel(const std::string &pin) const;
std::string getBelPackagePin(BelId bel) const;
+ int getPioBelBank(BelId bel) const;
+ // For getting GCLK, PLL, Vref, etc, pins
+ std::string getPioFunctionName(BelId bel) const;
+ BelId getPioByFunctionName(const std::string &name) const;
PortType getBelPinType(BelId bel, PortPin pin) const;