From 27ed77ea2428433e4efc1ff29d0ebc36753f9458 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 15 Apr 2025 10:25:39 +0200 Subject: [PATCH] share: Keep filtered activation patterns for the supercell The previous commit introduced code that optimizes the activation patterns to be able to generate smaller activation logic. The resulting supercell was then enqueued as shareable using those optimized activation patterns. The condition represented by the optimized patterns is an over-approximation of the actual activiation condition. This means using it as activiation for the supercell loses precision and pessimises sharing of the supercell with further cells, breaking the sat/share test. This commit fixes that by using the optimized activiation patterns only for the generation of activation logic and using the original patterns for enqueuing the supercell. --- passes/opt/share.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/passes/opt/share.cc b/passes/opt/share.cc index 7ffe26b2b..eb6476d57 100644 --- a/passes/opt/share.cc +++ b/passes/opt/share.cc @@ -1365,6 +1365,9 @@ struct ShareWorker continue; } + pool optimized_cell_activation_patterns = filtered_cell_activation_patterns; + pool optimized_other_cell_activation_patterns = filtered_other_cell_activation_patterns; + if (pattern_only_solve) { qcsat.ez->non_incremental(); @@ -1389,12 +1392,12 @@ struct ShareWorker log(" According to the SAT solver this pair of cells can be shared.\n"); } else { log(" According to the SAT solver this pair of cells can be shared. (Pattern only case)\n"); - restrict_activiation_patterns(filtered_cell_activation_patterns, filtered_other_cell_activation_patterns); + restrict_activiation_patterns(optimized_cell_activation_patterns, optimized_other_cell_activation_patterns); - for (auto &p : filtered_cell_activation_patterns) + for (auto &p : optimized_cell_activation_patterns) log(" Simplified activation pattern for cell %s: %s = %s\n", log_id(cell), log_signal(p.first), log_signal(p.second)); - for (auto &p : filtered_other_cell_activation_patterns) + for (auto &p : optimized_other_cell_activation_patterns) log(" Simplified activation pattern for cell %s: %s = %s\n", log_id(other_cell), log_signal(p.first), log_signal(p.second)); } @@ -1413,20 +1416,20 @@ struct ShareWorker int cell_select_score = 0; int other_cell_select_score = 0; - for (auto &p : filtered_cell_activation_patterns) + for (auto &p : optimized_cell_activation_patterns) cell_select_score += p.first.size(); - for (auto &p : filtered_other_cell_activation_patterns) + for (auto &p : optimized_other_cell_activation_patterns) other_cell_select_score += p.first.size(); RTLIL::Cell *supercell; pool supercell_aux; if (cell_select_score <= other_cell_select_score) { - RTLIL::SigSpec act = make_cell_activation_logic(filtered_cell_activation_patterns, supercell_aux); + RTLIL::SigSpec act = make_cell_activation_logic(optimized_cell_activation_patterns, supercell_aux); supercell = make_supercell(cell, other_cell, act, supercell_aux); log(" Activation signal for %s: %s\n", log_id(cell), log_signal(act)); } else { - RTLIL::SigSpec act = make_cell_activation_logic(filtered_other_cell_activation_patterns, supercell_aux); + RTLIL::SigSpec act = make_cell_activation_logic(optimized_other_cell_activation_patterns, supercell_aux); supercell = make_supercell(other_cell, cell, act, supercell_aux); log(" Activation signal for %s: %s\n", log_id(other_cell), log_signal(act)); }