diff options
author | Sergiusz Bazanski <q3k@q3k.org> | 2018-07-21 20:00:42 +0100 |
---|---|---|
committer | Sergiusz Bazanski <q3k@q3k.org> | 2018-07-21 20:00:42 +0100 |
commit | 6588aafdb8038625e8ce0cc265a2851cbb16b1c9 (patch) | |
tree | 44bc45b6ae06d52c60d15431db6c47feff036aff /ice40/arch.cc | |
parent | be14e161ae1963203e380bfbe02cfaeda828f838 (diff) | |
parent | f438fc615b829170679971110b5d1bb57fba6a86 (diff) | |
download | nextpnr-6588aafdb8038625e8ce0cc265a2851cbb16b1c9.tar.gz nextpnr-6588aafdb8038625e8ce0cc265a2851cbb16b1c9.tar.bz2 nextpnr-6588aafdb8038625e8ce0cc265a2851cbb16b1c9.zip |
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr into q3k/lock-2-electric-boogaloo
Diffstat (limited to 'ice40/arch.cc')
-rw-r--r-- | ice40/arch.cc | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index e09f26be..7c183f6c 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -255,11 +255,52 @@ BelId Arch::getBelByName(IdString name) const return ret; } +BelId Arch::getBelByLocation(Loc loc) const +{ + BelId bel; + + if (bel_by_loc.empty()) { + 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); + if (it != bel_by_loc.end()) + 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; + + 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) { + while (br.e.cursor < chip_info->num_bels && + chip_info->bel_data[br.e.cursor].x == x && + chip_info->bel_data[br.e.cursor].y == y) + br.e.cursor++; + } + + return br; +} + BelRange Arch::getBelsAtSameTile(BelId bel) const { BelRange br; NPNR_ASSERT(bel != BelId()); - // This requires Bels at the same tile are consecutive int x = chip_info->bel_data[bel.index].x; int y = chip_info->bel_data[bel.index].y; int start = bel.index, end = bel.index; |