3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-05-10 17:25:49 +00:00

kernel: handle unsigned case for as_int_saturating correctly

* This fixes #5105
This commit is contained in:
George Rennie 2025-05-08 11:08:20 +02:00
parent af933b4f38
commit e2485000c7

View file

@ -396,6 +396,9 @@ std::optional<int> RTLIL::Const::try_as_int(bool is_signed) const
int RTLIL::Const::as_int_saturating(bool is_signed) const int RTLIL::Const::as_int_saturating(bool is_signed) const
{ {
if (!convertible_to_int(is_signed)) { if (!convertible_to_int(is_signed)) {
if (!is_signed)
return std::numeric_limits<int>::max();
const auto min_size = get_min_size(is_signed); const auto min_size = get_min_size(is_signed);
log_assert(min_size > 0); log_assert(min_size > 0);
const auto neg = get_bits().at(min_size - 1); const auto neg = get_bits().at(min_size - 1);