ice40/arch: Add helper to check if a BEL is LOCKED or not

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2018-11-17 10:18:17 +01:00
parent 70e1fe423f
commit b29165eeba
2 changed files with 21 additions and 0 deletions

View File

@ -284,6 +284,25 @@ std::vector<IdString> Arch::getBelPins(BelId bel) const
return ret; return ret;
} }
bool Arch::isBelLocked(BelId bel) const
{
const BelConfigPOD *bel_config = nullptr;
for (int i = 0; i < chip_info->num_belcfgs; i++) {
if (chip_info->bel_config[i].bel_index == bel.index) {
bel_config = &chip_info->bel_config[i];
break;
}
}
NPNR_ASSERT(bel_config != nullptr);
for (int i = 0; i < bel_config->num_entries; i++) {
if (strcmp("LOCKED", bel_config->entries[i].cbit_name.get()))
continue;
if ("LOCKED_" + archArgs().package == bel_config->entries[i].entry_name.get())
return true;
}
return false;
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
WireId Arch::getWireByName(IdString name) const WireId Arch::getWireByName(IdString name) const

View File

@ -510,6 +510,8 @@ struct Arch : BaseCtx
PortType getBelPinType(BelId bel, IdString pin) const; PortType getBelPinType(BelId bel, IdString pin) const;
std::vector<IdString> getBelPins(BelId bel) const; std::vector<IdString> getBelPins(BelId bel) const;
bool isBelLocked(BelId bel) const;
// ------------------------------------------------- // -------------------------------------------------
WireId getWireByName(IdString name) const; WireId getWireByName(IdString name) const;