Constraing to location if provided

This commit is contained in:
Miodrag Milanovic 2024-06-12 10:23:31 +02:00
parent 5d5be7df63
commit c2ce766503
4 changed files with 29 additions and 0 deletions

View File

@ -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);
}
}
}

View File

@ -69,6 +69,7 @@ public:
dict<IdString,BelId> iom_bels;
dict<std::string, std::string> bank_voltage;
dict<BelId,IdString> global_capable_bels;
dict<std::string,BelId> locations;
pool<PipId> blocked_pips;

View File

@ -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

View File

@ -84,6 +84,7 @@ private:
// General helper functions
void flush_cells();
void constrain_location(CellInfo *cell);
// Cell creating
std::unique_ptr<CellInfo> create_cell(IdString type, IdString name);
CellInfo *create_cell_ptr(IdString type, IdString name);