Run toposort in both directions for better results

This commit is contained in:
Akash Levy 2025-09-09 07:45:25 -07:00
parent 2d5c16b798
commit 41dfe4fc61
2 changed files with 6 additions and 3 deletions

View File

@ -524,8 +524,11 @@ struct WreduceWorker
unified_toposort.analyze_loops = false;
unified_toposort.sort();
// Process cells and wires together in unified topological order
for (auto name : unified_toposort.sorted) {
// Process cells and wires together in unified topological order (both forwards and backwards)
std::vector<IdString> sorted_cells_and_wires_both_ways;
sorted_cells_and_wires_both_ways.insert(sorted_cells_and_wires_both_ways.end(), unified_toposort.sorted.begin(), unified_toposort.sorted.end());
sorted_cells_and_wires_both_ways.insert(sorted_cells_and_wires_both_ways.end(), unified_toposort.sorted.rbegin(), unified_toposort.sorted.rend());
for (auto name : sorted_cells_and_wires_both_ways) {
Cell *c = module->cell(name);
Wire *w = module->wire(name);

View File

@ -11,7 +11,7 @@ prep
design -save gold
alumacc
opt_clean
select -assert-count 2 t:$macc_v2
select -assert-count 1 t:$macc_v2
maccmap -unmap
design -copy-from gold -as gold gate
equiv_make gold gate equiv