From 936d65828321457a4efae7949aceb64a2f8d1352 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 17 Jun 2024 10:05:25 +0200 Subject: [PATCH] Post placement optimization for CY --- himbaechel/uarch/ng-ultra/ng_ultra.h | 1 + himbaechel/uarch/ng-ultra/pack.cc | 48 ++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.h b/himbaechel/uarch/ng-ultra/ng_ultra.h index 728491f2..b9e37bac 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.h +++ b/himbaechel/uarch/ng-ultra/ng_ultra.h @@ -45,6 +45,7 @@ struct NgUltraImpl : HimbaechelAPI // Flow management void pack() override; + void postPlace() override; void preRoute() override; void postRoute() override; diff --git a/himbaechel/uarch/ng-ultra/pack.cc b/himbaechel/uarch/ng-ultra/pack.cc index 801ac5e0..f78ed186 100644 --- a/himbaechel/uarch/ng-ultra/pack.cc +++ b/himbaechel/uarch/ng-ultra/pack.cc @@ -20,6 +20,7 @@ #include "pack.h" #include +#include #include #include #include @@ -73,13 +74,16 @@ void NgUltraPacker::pack_constants(void) h.replace_constants(CellTypePort(id_BEYOND_FE, id_LO), CellTypePort(id_BEYOND_FE, id_LO), vcc_params, gnd_params); } -void NgUltraPacker::remove_constants() +void remove_constants(Context *ctx) { log_info("Removing constants..\n"); auto fnd_cell = ctx->cells.find(ctx->id("$PACKER_VCC_DRV")); if (fnd_cell != ctx->cells.end()) { auto fnd_net = ctx->nets.find(ctx->id("$PACKER_VCC")); if (fnd_net != ctx->nets.end() && fnd_net->second->users.entries()==0) { + BelId bel = (*fnd_cell).second.get()->bel; + if (bel != BelId()) + ctx->unbindBel(bel); ctx->cells.erase(fnd_cell); ctx->nets.erase(fnd_net); log_info(" Removed unused VCC cell\n"); @@ -89,6 +93,9 @@ void NgUltraPacker::remove_constants() if (fnd_cell != ctx->cells.end()) { auto fnd_net = ctx->nets.find(ctx->id("$PACKER_GND")); if (fnd_net != ctx->nets.end() && fnd_net->second->users.entries()==0) { + BelId bel = (*fnd_cell).second.get()->bel; + if (bel != BelId()) + ctx->unbindBel(bel); ctx->cells.erase(fnd_cell); ctx->nets.erase(fnd_net); log_info(" Removed unused GND cell\n"); @@ -1261,10 +1268,47 @@ void NgUltraImpl::pack() packer.pack_cys(); packer.pack_lut_dffs(); packer.pack_dffs(); - packer.remove_constants(); packer.promote_globals(); } + +void NgUltraImpl::postPlace() +{ + log_break(); + log_info("Limiting routing...\n"); + for (auto &cell : ctx->cells) { + CellInfo &ci = *cell.second; + if (!ci.type.in(id_CY)) + continue; + // In case A input is actually used, but it is connectd to GND + // it is considered that signal is comming from RI1 crossbar. + // We need to prevent router to use that crossbar output for + // any other signal. + Loc loc = ctx->getBelLocation(ci.bel); + for (int i=1;i<=4;i++) { + IdString port = ctx->idf("A%d",i); + NetInfo *net = ci.getPort(port); + if (!net) + continue; + if (net->name.in(ctx->id("$PACKER_GND"))) { + BelId bel = ctx->getBelByLocation(loc); + WireId dwire = ctx->getBelPinWire(bel, port); + for (PipId pip : ctx->getPipsUphill(dwire)) { + WireId src = ctx->getPipSrcWire(pip); + std::string src_name = ctx->getWireName(src)[1].c_str(ctx); + if (boost::starts_with(src_name,"RI1")) { + for (PipId pip2 : ctx->getPipsDownhill(src)) { + blocked_pips.emplace(pip2); + } + } + } + ci.disconnectPort(port); // Disconnect A + } + } + } + remove_constants(ctx); +} + void NgUltraImpl::route_clocks() { log_info("Routing global clocks...\n");