aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/arch.cc
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-20 16:27:27 +0000
committerDavid Shah <davey1576@gmail.com>2018-07-20 16:27:27 +0000
commit0d6f6f410d456b6dc456b5c1f919f3620926b6af (patch)
treea051a9eef682ab922c474850d235f301c2c708fd /ice40/arch.cc
parent6c835d76f27af79813299419780c039eb2a8b02e (diff)
parentfd8239e170a7391d9c25d8681083507d9960abef (diff)
downloadnextpnr-0d6f6f410d456b6dc456b5c1f919f3620926b6af.tar.gz
nextpnr-0d6f6f410d456b6dc456b5c1f919f3620926b6af.tar.bz2
nextpnr-0d6f6f410d456b6dc456b5c1f919f3620926b6af.zip
Merge branch 'gridapi' into 'master'
Gridapi See merge request SymbioticEDA/nextpnr!11
Diffstat (limited to 'ice40/arch.cc')
-rw-r--r--ice40/arch.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc
index 786d8ba1..e9a7d2b6 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;