From c2ce766503aae9f2224f2890e405c9b2e6475a67 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 12 Jun 2024 10:23:31 +0200 Subject: [PATCH] Constraing to location if provided --- himbaechel/uarch/ng-ultra/ng_ultra.cc | 3 +++ himbaechel/uarch/ng-ultra/ng_ultra.h | 1 + himbaechel/uarch/ng-ultra/pack.cc | 24 ++++++++++++++++++++++++ himbaechel/uarch/ng-ultra/pack.h | 1 + 4 files changed, 29 insertions(+) diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.cc b/himbaechel/uarch/ng-ultra/ng_ultra.cc index 7308d59a..791c521e 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.cc +++ b/himbaechel/uarch/ng-ultra/ng_ultra.cc @@ -64,6 +64,9 @@ void NgUltraImpl::init(Context *ctx) global_capable_bels.emplace(bel,id_P19RI); } } + if (ctx->getBelType(bel).in(id_PLL, id_WFG)) { + locations.emplace(stringf("%s:%s",tile_name(bel.tile).c_str(), ctx->getBelName(bel)[1].c_str(ctx)),bel); + } } } diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.h b/himbaechel/uarch/ng-ultra/ng_ultra.h index c86b3c8c..80e98270 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.h +++ b/himbaechel/uarch/ng-ultra/ng_ultra.h @@ -69,6 +69,7 @@ public: dict iom_bels; dict bank_voltage; dict global_capable_bels; + dict locations; pool blocked_pips; diff --git a/himbaechel/uarch/ng-ultra/pack.cc b/himbaechel/uarch/ng-ultra/pack.cc index e0f8f829..c809eb7b 100644 --- a/himbaechel/uarch/ng-ultra/pack.cc +++ b/himbaechel/uarch/ng-ultra/pack.cc @@ -1105,6 +1105,28 @@ void NgUltraPacker::insert_wfb(CellInfo *cell, IdString port) } } +void NgUltraPacker::constrain_location(CellInfo *cell) +{ + std::string location = str_or_default(cell->params, ctx->id("location"), ""); + if (!location.empty()) { + if (uarch->locations.count(location)) { + BelId bel = uarch->locations[location]; + if (ctx->getBelType(bel)!= cell->type) { + log_error("Location '%s' is wrong for bel type '%s'.\n", location.c_str(), cell->type.c_str(ctx)); + } + if (ctx->checkBelAvail(bel)) { + log_info(" Constraining %s '%s' to '%s'\n", cell->type.c_str(ctx), cell->name.c_str(ctx), location.c_str()); + ctx->bindBel(bel, cell, PlaceStrength::STRENGTH_LOCKED); + } else { + log_error("Bel at location '%s' is already used by other cell.\n", location.c_str()); + } + + } else { + log_error("Unknown location '%s' for cell '%s'.\n", location.c_str(), cell->name.c_str(ctx)); + } + } +} + void NgUltraPacker::pack_plls(void) { log_info("Packing PLLs..\n"); @@ -1113,6 +1135,7 @@ void NgUltraPacker::pack_plls(void) if (!ci.type.in(id_NX_PLL_U)) continue; ci.type = id_PLL; + constrain_location(&ci); disconnect_if_gnd(&ci, id_FBK); disconnect_if_gnd(&ci, id_CLK_CAL); @@ -1146,6 +1169,7 @@ void NgUltraPacker::pack_wfgs(void) if (!ci.type.in(id_NX_WFG_U)) continue; ci.type = id_WFG; + constrain_location(&ci); int mode = int_or_default(ci.params, ctx->id("mode"), 1); if (mode == 0) { // WFB - bypass mode // must not be used, zero is tollerated diff --git a/himbaechel/uarch/ng-ultra/pack.h b/himbaechel/uarch/ng-ultra/pack.h index 86a1a1c9..46341040 100644 --- a/himbaechel/uarch/ng-ultra/pack.h +++ b/himbaechel/uarch/ng-ultra/pack.h @@ -84,6 +84,7 @@ private: // General helper functions void flush_cells(); + void constrain_location(CellInfo *cell); // Cell creating std::unique_ptr create_cell(IdString type, IdString name); CellInfo *create_cell_ptr(IdString type, IdString name);