ice40: Don't constrain multiple potentially-incompatible FFs to same tile (#1413)

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
myrtle 2025-01-02 11:08:42 +01:00 committed by GitHub
parent c565e364bc
commit 55bd760808
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1619,6 +1619,7 @@ void pack_plls(Context *ctx)
bool found_lut = false; bool found_lut = false;
bool all_luts = true; bool all_luts = true;
bool found_carry = false; bool found_carry = false;
bool found_ff = false;
unsigned int lut_count = 0; unsigned int lut_count = 0;
for (const auto &user : port.net->users) { for (const auto &user : port.net->users) {
NPNR_ASSERT(user.cell != nullptr); NPNR_ASSERT(user.cell != nullptr);
@ -1626,6 +1627,10 @@ void pack_plls(Context *ctx)
if (bool_or_default(user.cell->params, id_CARRY_ENABLE, false)) { if (bool_or_default(user.cell->params, id_CARRY_ENABLE, false)) {
found_carry = true; found_carry = true;
all_luts = false; all_luts = false;
} else if (bool_or_default(user.cell->params, id_DFF_ENABLE, false)) {
found_lut = true;
found_ff = true;
lut_count++;
} else { } else {
found_lut = true; found_lut = true;
lut_count++; lut_count++;
@ -1635,9 +1640,9 @@ void pack_plls(Context *ctx)
} }
} }
if (found_lut && all_luts && lut_count < 8) { if (found_lut && all_luts && (!found_ff || lut_count == 1) && lut_count < 8) {
// Every user is a LUT, carry on now. // Every user is a LUT, carry on now.
} else if (found_lut && !all_luts && !found_carry && lut_count < 8) { } else if (found_lut && !all_luts && !found_carry && !found_ff && lut_count < 8) {
// Strategy: create a pass-through LUT, move all non-LUT users behind it. // Strategy: create a pass-through LUT, move all non-LUT users behind it.
log_info(" LUT strategy for %s: move non-LUT users to new LUT\n", port.name.c_str(ctx)); log_info(" LUT strategy for %s: move non-LUT users to new LUT\n", port.name.c_str(ctx));
auto pt = spliceLUT(ctx, packed.get(), port.name, true); auto pt = spliceLUT(ctx, packed.get(), port.name, true);