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

cxxrtl: Fix udivmod logic

This commit is contained in:
Martin Povišer 2023-12-11 22:11:35 +01:00
parent bcf5e92389
commit c848d98d91

View file

@ -583,7 +583,7 @@ struct value : public expr_base<value<Bits>> {
value<Bits> dividend = *this;
if (dividend.ucmp(divisor))
return {/*quotient=*/value<Bits>{0u}, /*remainder=*/dividend};
uint32_t divisor_shift = dividend.ctlz() - divisor.ctlz();
uint32_t divisor_shift = divisor.ctlz() - dividend.ctlz();
divisor = divisor.shl(value<Bits>{divisor_shift});
for (size_t step = 0; step <= divisor_shift; step++) {
quotient = quotient.shl(value<Bits>{1u});