3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-12 04:03:45 +00:00

cxxrtl: don't use signed divide with unsigned/pos values

Incorrect for unsigned, wasted effort for positive signed.
This commit is contained in:
Charlotte 2023-06-28 11:51:19 +10:00 committed by Marcelina Kościelnicka
parent b0f69f2cd5
commit 52dc397a50

View file

@ -904,10 +904,12 @@ std::ostream &operator<<(std::ostream &os, const value_formatted<Bits> &vf)
val = val.neg();
if (val.is_zero())
buf += '0';
// TODO: rigorously check our signed behaviour here
while (!val.is_zero()) {
value<Bits> quotient;
val.signedDivideWithRemainder(value<Bits>{10u}, quotient);
if (negative)
val.signedDivideWithRemainder(value<Bits>{10u}, quotient);
else
val.divideWithRemainder(value<Bits>{10u}, quotient);
buf += '0' + val.template slice<3, 0>().val().template get<uint8_t>();
val = quotient;
}