3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-23 23:52:32 +00:00

Merge branch 'YosysHQ:main' into main

This commit is contained in:
Akash Levy 2025-06-23 02:30:24 -07:00 committed by GitHub
commit 7e9e4c7afe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 83 additions and 7 deletions

View file

@ -760,7 +760,11 @@ struct OptDffWorker
ModWalker modwalker(module->design, module);
QuickConeSat qcsat(modwalker);
// Run as a separate sub-pass, so that we don't mutate (non-FF) cells under ModWalker.
// Defer mutating cells by removing them/emiting new flip flops so that
// cell references in modwalker are not invalidated
std::vector<RTLIL::Cell*> cells_to_remove;
std::vector<FfData> ffs_to_emit;
bool did_something = false;
for (auto cell : module->selected_cells()) {
if (!RTLIL::builtin_ff_cell_types().count(cell->type))
@ -852,16 +856,20 @@ struct OptDffWorker
if (!removed_sigbits.count(i))
keep_bits.push_back(i);
if (keep_bits.empty()) {
module->remove(cell);
cells_to_remove.emplace_back(cell);
did_something = true;
continue;
}
ff = ff.slice(keep_bits);
ff.cell = cell;
ff.emit();
ffs_to_emit.emplace_back(ff);
did_something = true;
}
}
for (auto* cell : cells_to_remove)
module->remove(cell);
for (auto& ff : ffs_to_emit)
ff.emit();
return did_something;
}
};