Skip to content

Commit

Permalink
peepopt: handle offset too large in shiftadd
Browse files Browse the repository at this point in the history
If the offset is larger than the signal itself,
meaning the signal is completely shifted out,
it tried to extract a negative amount of bits from the old signal.

This RTL pattern is suspicious since it is a complicated way of
arriving at a constant value, so we warn the user.
  • Loading branch information
Philippe Sauter committed Jan 26, 2024
1 parent 80511ce commit 68a9aa7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions passes/pmgen/peepopt_shiftadd.pmg
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,18 @@ code
new_a.append(old_a);
} else {
// data >> (...+c) transformed to data[MAX:c] >> (...)
new_a.append(old_a.extract_end(offset));

if(offset < GetSize(old_a)) // some signal bits left?
new_a.append(old_a.extract_end(offset));
else {
if(shift->type.in($shiftx))
log_warning("at %s: result of indexed part-selection is always constant (selecting from '%s' with index '%s + %d')\n", \
shift->get_src_attribute().c_str(), log_signal(old_a), log_signal(var_signal), offset);
else
log_warning("at %s: result of shift operation is always constant (shifting '%s' by '%s + %d'-bits)\n", \
shift->get_src_attribute().c_str(), log_signal(old_a), log_signal(var_signal), offset);
}

// is it fine to leave new_a empty? (size 0)
}

SigSpec new_b = {var_signal, SigSpec(State::S0, log2scale)};
Expand Down

0 comments on commit 68a9aa7

Please sign in to comment.