From 534465d3ad5a2d42766088418eb37f88b029b195 Mon Sep 17 00:00:00 2001 From: David Shah Date: Wed, 1 Aug 2018 15:30:28 +0200 Subject: ecp5: Adding tilegrid helper functions to Arch Signed-off-by: David Shah --- ecp5/arch.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ecp5') diff --git a/ecp5/arch.h b/ecp5/arch.h index 0685042c..002d69c2 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -759,6 +759,27 @@ struct Arch : BaseCtx return range; } + std::string getTileByTypeAndLocation(int row, int col, std::string type) const + { + auto &tileloc = chip_info->tile_info[row * chip_info->width + col]; + for (int i = 0; i < tileloc.num_tiles; i++) { + if (chip_info->tiletype_names[tileloc.tile_names[i].type_idx].get() == type) + return tileloc.tile_names[i].name.get(); + } + NPNR_ASSERT_FALSE_STR("no tile at (" + std::to_string(col) + ", " + std::to_string(row) + ") with type " + + type); + } + + std::string getPipTilename(PipId pip) const + { + auto &tileloc = chip_info->tile_info[pip.location.y * chip_info->width + pip.location.x]; + for (int i = 0; i < tileloc.num_tiles; i++) { + if (tileloc.tile_names[i].type_idx == locInfo(pip)->pip_data[pip.index].tile_type) + return tileloc.tile_names[i].name.get(); + } + NPNR_ASSERT_FALSE("failed to find Pip tile"); + } + std::string getPipTiletype(PipId pip) const { return chip_info->tiletype_names[locInfo(pip)->pip_data[pip.index].tile_type].get(); -- cgit v1.2.3