diff options
-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()); |