From a79f0db7491b4d8b794c9fcc59647ce9d4e877ec Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Mon, 26 Nov 2018 11:03:26 +0100 Subject: [PATCH] ice40: Add helper to know which global network is driven by a SB_GB Bel Signed-off-by: Sylvain Munaut --- ice40/arch.h | 7 +++++++ ice40/arch_place.cc | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ice40/arch.h b/ice40/arch.h index e8c597c9..10255dbe 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -884,6 +884,13 @@ struct Arch : BaseCtx } NPNR_ASSERT_FALSE("Expected PLL pin to share an output with an SB_IO D_IN_{0,1}"); } + + int getDrivenGlobalNetwork(BelId bel) const + { + NPNR_ASSERT(getBelType(bel) == id_SB_GB); + IdString glb_net = getWireName(getBelPinWire(bel, id_GLOBAL_BUFFER_OUTPUT)); + return std::stoi(std::string("") + glb_net.str(this).back()); + } }; void ice40DelayFuzzerMain(Context *ctx); diff --git a/ice40/arch_place.cc b/ice40/arch_place.cc index 41f9b640..90bb62b9 100644 --- a/ice40/arch_place.cc +++ b/ice40/arch_place.cc @@ -165,8 +165,7 @@ bool Arch::isValidBelForCell(CellInfo *cell, BelId bel) const return true; NPNR_ASSERT(cell->ports.at(id_GLOBAL_BUFFER_OUTPUT).net != nullptr); const NetInfo *net = cell->ports.at(id_GLOBAL_BUFFER_OUTPUT).net; - IdString glb_net = getWireName(getBelPinWire(bel, id_GLOBAL_BUFFER_OUTPUT)); - int glb_id = std::stoi(std::string("") + glb_net.str(this).back()); + int glb_id = getDrivenGlobalNetwork(bel); if (net->is_reset && net->is_enable) return false; else if (net->is_reset)