Merge pull request #4165 from phsauter/shiftadd-offset-fix

peepopt: handle offset too large in `shiftadd`
This commit is contained in:
Martin Povišer 2024-01-31 13:47:39 +01:00 committed by GitHub
commit 6c4bc5aae5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 2 deletions

View File

@ -103,8 +103,20 @@ code
new_a.append(old_a); new_a.append(old_a);
} else { } else {
// data >> (...+c) transformed to data[MAX:c] >> (...) // 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 {
// warn user in case data is empty (no bits left)
std::string location = shift->get_src_attribute();
if (location.empty())
location = shift->name.str();
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", \
location.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", \
location.c_str(), log_signal(old_a), log_signal(var_signal), offset);
}
} }
SigSpec new_b = {var_signal, SigSpec(State::S0, log2scale)}; SigSpec new_b = {var_signal, SigSpec(State::S0, log2scale)};