Better forced_die implementation

This commit is contained in:
Miodrag Milanovic 2025-09-26 16:57:31 +02:00
parent fc4be25663
commit 9b8e1e9d4c
3 changed files with 30 additions and 8 deletions

View File

@ -98,7 +98,6 @@ void GateMateImpl::init_database(Arch *arch)
: timing_mode == 3 ? "SPEED"
: "");
arch->set_speed_grade(speed_grade);
force_die = args.options.count("force_die") != 0;
}
void GateMateImpl::init(Context *ctx)
@ -154,8 +153,24 @@ void GateMateImpl::init(Context *ctx)
const GateMateChipExtraDataPOD *extra =
reinterpret_cast<const GateMateChipExtraDataPOD *>(ctx->chip_info->extra_data.get());
for (auto &die : extra->dies)
ctx->createRectangularRegion(IdString(die.name), die.x1, die.y1, die.x2, die.y2);
const ArchArgs &args = ctx->args;
std::string die_name;
if (args.options.count("force_die"))
die_name = args.options.at("force_die");
bool found = false;
int index = 0;
for (auto &die : extra->dies) {
IdString name(die.name);
die_to_index[name] = index++;
ctx->createRectangularRegion(name, die.x1, die.y1, die.x2, die.y2);
if (die_name == name.c_str(ctx)) {
found = true;
forced_die = name;
}
}
if (!die_name.empty() && !found)
log_error("Unable to select forced die '%s'.\n", die_name.c_str());
}
bool GateMateImpl::isBelLocationValid(BelId bel, bool explain_invalid) const
@ -165,10 +180,6 @@ bool GateMateImpl::isBelLocationValid(BelId bel, bool explain_invalid) const
return true;
}
if (force_die && cell->belStrength != PlaceStrength::STRENGTH_FIXED &&
tile_extra_data(bel.tile)->die != preferred_die)
return false;
if (getBelBucketForBel(bel) == id_CPE_FF) {
Loc loc = ctx->getBelLocation(bel);
const CellInfo *adj_half = ctx->getBoundBelCell(

View File

@ -126,7 +126,8 @@ struct GateMateImpl : HimbaechelAPI
std::map<BelId, std::map<IdString, const GateMateBelPinConstraintPOD *>> pin_to_constr;
std::map<IdString, const GateMateTimingExtraDataPOD *> timing;
dict<IdString, int> ram_signal_clk;
bool force_die;
IdString forced_die;
dict<IdString, int> die_to_index;
};
NEXTPNR_NAMESPACE_END

View File

@ -385,6 +385,9 @@ void GateMateImpl::pack()
parse_ccf(args.options.at("ccf"));
}
if (forced_die != IdString())
preferred_die = die_to_index[forced_die];
GateMatePacker packer(ctx, this);
packer.pack_constants();
packer.cleanup();
@ -401,6 +404,13 @@ void GateMateImpl::pack()
packer.pack_cpe();
packer.copy_clocks();
packer.remove_constants();
if (forced_die != IdString()) {
for (auto &cell : ctx->cells) {
if (cell.second->belStrength != PlaceStrength::STRENGTH_FIXED)
ctx->constrainCellToRegion(cell.second->name, forced_die);
}
}
}
void GateMateImpl::repack()