aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/arch.cc
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-23 10:53:07 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-23 10:53:07 +0200
commit54d1b8adcee3d1a89bf86b87be281e683d1cea93 (patch)
tree6bb99b1d7e31008347a1e378c9a9dfe429b7029e /ecp5/arch.cc
parentd0ed23d673013b4fc44f5e938bc74103d1268c13 (diff)
downloadnextpnr-54d1b8adcee3d1a89bf86b87be281e683d1cea93.tar.gz
nextpnr-54d1b8adcee3d1a89bf86b87be281e683d1cea93.tar.bz2
nextpnr-54d1b8adcee3d1a89bf86b87be281e683d1cea93.zip
ecp5: Implement new Grid APIs
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ecp5/arch.cc')
-rw-r--r--ecp5/arch.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 90950492..a817651e 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -344,6 +344,42 @@ std::vector<PortPin> Arch::getBelPins(BelId bel) const
return ret;
}
+BelId Arch::getBelByLocation(Loc loc) const {
+ if (loc.x >= chip_info->width || loc.y >= chip_info->height)
+ return BelId();
+ const LocationTypePOD &locI = chip_info->locations[chip_info->location_type[loc.y * chip_info->width + loc.x]];
+ for (int i = 0; i < locI.num_bels; i++) {
+ if (locI.bel_data[i].z == loc.z) {
+ BelId bi;
+ bi.location.x = loc.x;
+ bi.location.y = loc.y;
+ bi.index = i;
+ return bi;
+ }
+ }
+ return BelId();
+}
+
+BelRange Arch::getBelsByTile(int x, int y) const {
+ BelRange br;
+
+ int num_bels = 0;
+
+ if (x < chip_info->width && y < chip_info->height) {
+ const LocationTypePOD &locI = chip_info->locations[chip_info->location_type[y * chip_info->width + x]];
+ num_bels = locI.num_bels;
+ }
+
+ br.b.cursor_tile = y * chip_info->width + x;
+ br.e.cursor_tile = y * chip_info->width + x;
+ br.b.cursor_index = 0;
+ br.e.cursor_index = num_bels - 1;
+ br.b.chip = chip_info;
+ br.e.chip = chip_info;
+ ++br.e;
+ return br;
+}
+
// -----------------------------------------------------------------------
void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const