From a5582f59bf8d3afe2032d7da705484221a5ad6e9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Jun 2024 10:34:25 +0200 Subject: [PATCH] existing gck --- himbaechel/uarch/ng-ultra/pack.cc | 84 ++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/himbaechel/uarch/ng-ultra/pack.cc b/himbaechel/uarch/ng-ultra/pack.cc index a8ebe1a6..1d813223 100644 --- a/himbaechel/uarch/ng-ultra/pack.cc +++ b/himbaechel/uarch/ng-ultra/pack.cc @@ -1696,7 +1696,89 @@ void NgUltraImpl::postPlace() void NgUltraPacker::duplicate_gck() { - //log_info("Duplicating existing GCKs...\n"); + // Unbind all GCKs that are inserted + for (auto &cell : ctx->cells) { + CellInfo &ci = *cell.second; + if (!ci.type.in(id_GCK)) + continue; + ctx->unbindBel(ci.bel); + } + + + dict> glb_sources; + glb_sources[id_GCK].insert(id_SO); + + dict> clock_sinks; + clock_sinks[id_BEYOND_FE].insert(id_CK); + //clock_sinks[id_DFF].insert(id_CK); // This is part of BEYOND_FE + clock_sinks[id_RF].insert(id_WCK); + clock_sinks[id_RFSP].insert(id_WCK); + clock_sinks[id_XHRF].insert(id_WCK1); + clock_sinks[id_XHRF].insert(id_WCK2); + clock_sinks[id_XWRF].insert(id_WCK1); + clock_sinks[id_XWRF].insert(id_WCK2); + clock_sinks[id_XPRF].insert(id_WCK1); + clock_sinks[id_XPRF].insert(id_WCK2); + clock_sinks[id_RAM].insert(id_ACK); + clock_sinks[id_RAM].insert(id_BCK); + clock_sinks[id_DSP].insert(id_CK); + //glb_sources[id_BFR].insert(id_O); + //glb_sources[id_GCK].insert(id_SO); + + log_info("Duplicating existing GCKs...\n"); + for (auto &net : ctx->nets) { + NetInfo *glb_net = net.second.get(); + if (!glb_net->driver.cell) + continue; + + // check if we have a global clock net, skip otherwise + if (!(glb_sources.count(glb_net->driver.cell->type) && glb_sources[glb_net->driver.cell->type].count(glb_net->driver.port))) + continue; + + log_info(" Global signal '%s'\n", glb_net->name.c_str(ctx)); + dict> connections; + for (const auto &usr : glb_net->users) { + if (clock_sinks.count(usr.cell->type) && clock_sinks[usr.cell->type].count(usr.port)) { + if (usr.cell->bel==BelId()) { + log_error("Cell '%s' not placed\n",usr.cell->name.c_str(ctx)); + } + int lobe = uarch->tile_lobe(usr.cell->bel.tile); + if (lobe > 0) { + connections[lobe].push_back(usr); + usr.cell->disconnectPort(usr.port); + } + } + } + + if (connections.size()>1) + log_error("Unhandled\n"); + + for (auto &conn : connections) { + pool& gck = uarch->gck_per_lobe[conn.first]; + if (gck.size()==0) + log_error("No GCK left to promote global signal.\n"); + + BelId bel = gck.pop(); + CellInfo *gck_cell = glb_net->driver.cell; + log_info(" Assign GCK '%s' to lobe %d\n",gck_cell->name.c_str(ctx), conn.first); + /* + log_info(" Create GCK for lobe %d\n",conn.first); + CellInfo *gck_cell = create_cell_ptr(id_GCK, ctx->id(glb_net->name.str(ctx) + "$gck_"+ std::to_string(conn.first))); + gck_cell->params[id_std_mode] = Property("BYPASS"); + gck_cell->connectPort(id_SI1, glb_net);*/ + gck_cell->disconnectPort(id_SO); + NetInfo *new_clk = ctx->createNet(ctx->id(gck_cell->name.str(ctx) + "$gck_"+ std::to_string(conn.first))); + gck_cell->connectPort(id_SO, new_clk); + for (const auto &usr : conn.second) { + CellInfo *cell = usr.cell; + IdString port = usr.port; + cell->connectPort(port, new_clk); + } + + ctx->bindBel(bel, gck_cell, PlaceStrength::STRENGTH_LOCKED); + } + } + } void NgUltraPacker::insert_bypass_gck()