mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-07 06:33:24 +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:
parent
b0f69f2cd5
commit
52dc397a50
1 changed files with 4 additions and 2 deletions
|
@ -904,10 +904,12 @@ std::ostream &operator<<(std::ostream &os, const value_formatted<Bits> &vf)
|
||||||
val = val.neg();
|
val = val.neg();
|
||||||
if (val.is_zero())
|
if (val.is_zero())
|
||||||
buf += '0';
|
buf += '0';
|
||||||
// TODO: rigorously check our signed behaviour here
|
|
||||||
while (!val.is_zero()) {
|
while (!val.is_zero()) {
|
||||||
value<Bits> quotient;
|
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>();
|
buf += '0' + val.template slice<3, 0>().val().template get<uint8_t>();
|
||||||
val = quotient;
|
val = quotient;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue