From 682de724a8f84ee5106a1fd8ad68888605eafa89 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Sun, 6 Dec 2020 22:35:25 -0500 Subject: machxo2: Implement 2 Bel API functions. --- machxo2/arch.cc | 19 +++++++++++++++++-- machxo2/arch.h | 9 ++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'machxo2') 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()); -- cgit v1.2.3