From 15b917b349cf8fc190f722585a706d57da114a94 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 19 Jul 2024 15:41:30 +0200 Subject: [PATCH] Make boundbox fit NG-Ultra internal design --- himbaechel/uarch/ng-ultra/extra_data.h | 11 ++++++++++- himbaechel/uarch/ng-ultra/gen/arch_gen.py | 23 +++++++++++++++++++++-- himbaechel/uarch/ng-ultra/ng_ultra.cc | 22 ++++++++++++++-------- himbaechel/uarch/ng-ultra/ng_ultra.h | 1 + 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/himbaechel/uarch/ng-ultra/extra_data.h b/himbaechel/uarch/ng-ultra/extra_data.h index e6552a5a..1164d7ce 100644 --- a/himbaechel/uarch/ng-ultra/extra_data.h +++ b/himbaechel/uarch/ng-ultra/extra_data.h @@ -8,7 +8,7 @@ NEXTPNR_NAMESPACE_BEGIN NPNR_PACKED_STRUCT(struct NGUltraTileInstExtraDataPOD { int32_t name; uint8_t lobe; - uint8_t dummy1; + uint8_t tile_type; uint16_t dummy2; }); @@ -223,6 +223,15 @@ enum BelExtra BEL_EXTRA_FE_SCC = 2, }; +enum TileTypeExtra +{ + TILE_EXTRA_FABRIC = 0, + TILE_EXTRA_TUBE = 1, + TILE_EXTRA_SOC = 2, + TILE_EXTRA_RING = 3, + TILE_EXTRA_FENCE = 4 +}; + NEXTPNR_NAMESPACE_END #endif diff --git a/himbaechel/uarch/ng-ultra/gen/arch_gen.py b/himbaechel/uarch/ng-ultra/gen/arch_gen.py index f3f9e3f5..d021ce5b 100644 --- a/himbaechel/uarch/ng-ultra/gen/arch_gen.py +++ b/himbaechel/uarch/ng-ultra/gen/arch_gen.py @@ -14,13 +14,14 @@ from himbaechel_dbgen.chip import * class TileExtraData(BBAStruct): name: IdString lobe: int = 0 + tile_type: int = 0 def serialise_lists(self, context: str, bba: BBAWriter): pass def serialise(self, context: str, bba: BBAWriter): bba.u32(self.name.index) bba.u8(self.lobe) - bba.u8(0) # dummy + bba.u8(self.tile_type) bba.u16(0) # dummy @dataclass @@ -80,6 +81,12 @@ PIP_EXTRA_VIRTUAL = 6 BEL_EXTRA_FE_CSC = 1 BEL_EXTRA_FE_SCC = 2 +TILE_EXTRA_FABRIC = 0 +TILE_EXTRA_TUBE = 1 +TILE_EXTRA_SOC = 2 +TILE_EXTRA_RING = 3 +TILE_EXTRA_FENCE = 4 + def bel_z(tile_type, bel_name, bel_type): if tile_type.startswith("CKG"): if (bel_type=="PLL"): @@ -674,7 +681,19 @@ def main(): lobe = 7 case "IOB4" | "IOB5" | "HSSL4" | "HSSL5" | "HSSL6" | "HSSL7": lobe = 8 - ti.extra_data = TileExtraData(ch.strs.id(name),lobe) + tile_type = 0 + if item["orig"] in ["TILE","CGB","MESH"]: + tile_type = TILE_EXTRA_FABRIC + elif item["orig"] in ["TUBE"]: + tile_type = TILE_EXTRA_TUBE + elif item["orig"] in ["SOCBank"]: + tile_type = TILE_EXTRA_SOC + elif item["orig"].startswith("IOB") or item["orig"].startswith("HSSL") or item["orig"].startswith("CKG"): + tile_type = TILE_EXTRA_RING + elif item["orig"].startswith("FENCE"): + tile_type = TILE_EXTRA_FENCE + + ti.extra_data = TileExtraData(ch.strs.id(name),lobe, tile_type) for name, data in tilegrid.items(): print(f"Generate nodes for {name}...") diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.cc b/himbaechel/uarch/ng-ultra/ng_ultra.cc index 49147b90..e243a9f7 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.cc +++ b/himbaechel/uarch/ng-ultra/ng_ultra.cc @@ -234,6 +234,12 @@ int NgUltraImpl::tile_lobe(int tile) const return data.lobe; } +TileTypeExtra NgUltraImpl::tile_type(int tile) const +{ + const auto &data = *tile_extra_data(tile); + return (TileTypeExtra)data.tile_type; +} + void NgUltraImpl::preRoute() { log_break(); @@ -686,6 +692,9 @@ bool NgUltraImpl::getClusterPlacement(ClusterId cluster, BelId root_bel, BoundingBox NgUltraImpl::getRouteBoundingBox(WireId src, WireId dst) const { + if ((tile_type(src.tile)!=TILE_EXTRA_FABRIC || tile_type(dst.tile)!=TILE_EXTRA_FABRIC)) { + return { 0, 0, ctx->getGridDimX(), ctx->getGridDimY() }; + } int x0, y0, x1, y1; auto expand = [&](int x, int y) { x0 = std::min(x0, x); @@ -699,14 +708,11 @@ BoundingBox NgUltraImpl::getRouteBoundingBox(WireId src, WireId dst) const int dx, dy; tile_xy(ctx->chip_info, dst.tile, dx, dy); expand(dx, dy); - // Two TILEs left and up, and one tile right and down - int exp = 8; - if (x0 == 0 || y0==0 || y1==52*4 || x1==96*4) - exp = 24; // more expansion around IO - return {(x0 & 0xfffc) - exp, - (y0 & 0xfffc) - exp, - (x1 & 0xfffc) + exp, - (y1 & 0xfffc) + exp}; + // Reach 7 MESH above and below (3 left and 3 right of TILE/CGB) + return {(x0 & 0xfffc) - 3*4, // 3 MESH on left + (y0 & 0xfffc) - 4, // row above + (x1 & 0xfffc) + 4*4, // MESH bellow and 3 right + (y1 & 0xfffc) + 8}; // current and row bellow } delay_t NgUltraImpl::estimateDelay(WireId src, WireId dst) const diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.h b/himbaechel/uarch/ng-ultra/ng_ultra.h index a5a91594..43a0656c 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.h +++ b/himbaechel/uarch/ng-ultra/ng_ultra.h @@ -71,6 +71,7 @@ struct NgUltraImpl : HimbaechelAPI public: int tile_lobe(int tile) const; + TileTypeExtra tile_type(int tile) const; IdString tile_name_id(int tile) const; std::string tile_name(int tile) const;