Skip to content

Commit

Permalink
proc_dff: optimize repeated values at bit granularity
Browse files Browse the repository at this point in the history
  • Loading branch information
georgerennie committed Nov 28, 2024
1 parent ed989f8 commit 08479a0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions passes/proc/proc_dff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,24 @@ class Dff {

// Combine adjacent async rules that assign the same value into one rule
// with a disjunction of triggers. The resulting trigger is optimized by
// constant evaluation.
// constant evaluation. We apply all of these optimizations that can be
// done to the LSB and shrink the size of the signal we are considering if
// higher bits cannot be optimized in the same way.
void optimize_same_value(ConstEval& ce) {
for (size_t i = 0; i + 1 < async_rules.size();) {
if (async_rules[i].value != async_rules[i + 1].value) {
const auto bit_optimizable = [&](const size_t bit) {
return async_rules[i].value[bit] == async_rules[i + 1].value[bit];
};

const bool lsb_optimizable = bit_optimizable(0);

size_t new_size;
for (new_size = 1; new_size < size(); new_size++)
if (bit_optimizable(new_size) != lsb_optimizable)
break;
resize(new_size);

if (!lsb_optimizable) {
i++;
continue;
}
Expand Down

0 comments on commit 08479a0

Please sign in to comment.