mirror of https://github.com/YosysHQ/yosys.git
cxxrtl: Assert well-formedness of input to `udivmod`
This commit is contained in:
parent
6206a3af30
commit
18d1907fa8
|
@ -583,8 +583,9 @@ 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 = divisor.ctlz() - dividend.ctlz();
|
||||
divisor = divisor.shl(value<Bits>{divisor_shift});
|
||||
int64_t divisor_shift = divisor.ctlz() - dividend.ctlz();
|
||||
assert(divisor_shift >= 0);
|
||||
divisor = divisor.shl(value<Bits>{(chunk::type) divisor_shift});
|
||||
for (size_t step = 0; step <= divisor_shift; step++) {
|
||||
quotient = quotient.shl(value<Bits>{1u});
|
||||
if (!dividend.ucmp(divisor)) {
|
||||
|
|
Loading…
Reference in New Issue