diff options
Diffstat (limited to 'ice40')
| -rw-r--r-- | ice40/arch.cc | 26 | ||||
| -rw-r--r-- | ice40/arch.h | 2 |
2 files changed, 20 insertions, 8 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index ceafca17..e9a7d2b6 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -255,24 +255,36 @@ BelId Arch::getBelByName(IdString name) const return ret; } -BelId Arch::getBelByLocation(int x, int y, int z) const +BelId Arch::getBelByLocation(Loc loc) const { + BelId bel; + if (bel_by_loc.empty()) { - for (int i = 0; i < chip_info->num_bels; i++) - bel_by_loc[getBelLocation(BelId{i})] = i; + for (int i = 0; i < chip_info->num_bels; i++) { + BelId b; + b.index = i; + bel_by_loc[getBelLocation(b)] = i; + } } - auto it = bel_by_loc.find(Loc{x, y, z}); + auto it = bel_by_loc.find(loc); if (it != bel_by_loc.end()) - return BelId{it->second}; - return BelId(); + bel.index = it->second; + + return bel; } BelRange Arch::getBelsByTile(int x, int y) const { // In iCE40 chipdb bels at the same tile are consecutive and dense z ordinates are used BelRange br; - br.b.cursor = Arch::getBelByLocation(x, y, 0); + + Loc loc; + loc.x = x; + loc.y = y; + loc.z = 0; + + br.b.cursor = Arch::getBelByLocation(loc).index; br.e.cursor = br.b.cursor; if (br.e.cursor != -1) { diff --git a/ice40/arch.h b/ice40/arch.h index f86428a9..beba2ccf 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -450,7 +450,7 @@ struct Arch : BaseCtx return loc; } - BelId getBelByLocation(int x, int y, int z) const; + BelId getBelByLocation(Loc loc) const; BelRange getBelsByTile(int x, int y) const; bool getBelGlobalBuf(BelId bel) const |
