mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-14 09:56:16 +00:00
Merge pull request #2340 from andy-knowles/cxxrtl-fix-alu-carryout
cxxrtl.h: Fix incorrect CarryOut in alu when Bits % 32 != 0 && Invert == False
This commit is contained in:
commit
a74a43d85d
1 changed files with 2 additions and 1 deletions
|
@ -452,10 +452,11 @@ struct value : public expr_base<value<Bits>> {
|
||||||
bool carry = CarryIn;
|
bool carry = CarryIn;
|
||||||
for (size_t n = 0; n < result.chunks; n++) {
|
for (size_t n = 0; n < result.chunks; n++) {
|
||||||
result.data[n] = data[n] + (Invert ? ~other.data[n] : other.data[n]) + carry;
|
result.data[n] = data[n] + (Invert ? ~other.data[n] : other.data[n]) + carry;
|
||||||
|
if (result.chunks - 1 == n)
|
||||||
|
result.data[result.chunks - 1] &= result.msb_mask;
|
||||||
carry = (result.data[n] < data[n]) ||
|
carry = (result.data[n] < data[n]) ||
|
||||||
(result.data[n] == data[n] && carry);
|
(result.data[n] == data[n] && carry);
|
||||||
}
|
}
|
||||||
result.data[result.chunks - 1] &= result.msb_mask;
|
|
||||||
return {result, carry};
|
return {result, carry};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue