diff options
author | William D. Jones <thor0505@comcast.net> | 2020-12-06 22:35:25 -0500 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2021-02-12 10:36:59 +0000 |
commit | 682de724a8f84ee5106a1fd8ad68888605eafa89 (patch) | |
tree | 27bf754dfedeecb85925bdcd168970cf5fddfb81 /machxo2 | |
parent | 3e6be4bbfd3be2bb57075d8b76ba239ff6a0ee54 (diff) | |
download | nextpnr-682de724a8f84ee5106a1fd8ad68888605eafa89.tar.gz nextpnr-682de724a8f84ee5106a1fd8ad68888605eafa89.tar.bz2 nextpnr-682de724a8f84ee5106a1fd8ad68888605eafa89.zip |
machxo2: Implement 2 Bel API functions.
Diffstat (limited to 'machxo2')
-rw-r--r-- | machxo2/arch.cc | 19 | ||||
-rw-r--r-- | machxo2/arch.h | 9 |
2 files changed, 25 insertions, 3 deletions
diff --git a/machxo2/arch.cc b/machxo2/arch.cc index 821fb7e7..8c8dda5e 100644 --- a/machxo2/arch.cc +++ b/machxo2/arch.cc @@ -135,10 +135,25 @@ BelId Arch::getBelByName(IdString name) const return BelId(); } -IdString Arch::getBelName(BelId bel) const { return IdString(); } - BelId Arch::getBelByLocation(Loc loc) const { + BelId ret; + + if(loc.x >= chip_info->width || loc.y >= chip_info->height) + return BelId(); + + ret.location.x = loc.x; + ret.location.y = loc.y; + + const TileTypePOD *tilei = tileInfo(ret); + for(int i = 0; i < tilei->num_bels; i++) { + if(tilei->bel_data[i].z == loc.z) + { + ret.index = i; + return ret; + } + } + return BelId(); } diff --git a/machxo2/arch.h b/machxo2/arch.h index c6aae931..1c848388 100644 --- a/machxo2/arch.h +++ b/machxo2/arch.h @@ -351,7 +351,14 @@ struct Arch : BaseCtx int getTilePipDimZ(int x, int y) const { return 2; } BelId getBelByName(IdString name) const; - IdString getBelName(BelId bel) const; + IdString getBelName(BelId bel) const + { + NPNR_ASSERT(bel != BelId()); + std::stringstream name; + name << "X" << bel.location.x << "/Y" << bel.location.y << "/" << tileInfo(bel)->bel_data[bel.index].name.get(); + return id(name.str()); + } + Loc getBelLocation(BelId bel) const { NPNR_ASSERT(bel != BelId()); |