[Libre-soc-isa] [Bug 817] Big Integer Math (sv.adde, sv.subfe, sv.madded, 128 by 64-bit -> 64-bit div/rem, maybe more...)

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Mon Apr 25 10:20:56 BST 2022


https://bugs.libre-soc.org/show_bug.cgi?id=817

--- Comment #26 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #25)
> (In reply to Jacob Lifshay from comment #23)
> > (In reply to Luke Kenneth Casson Leighton from comment #20)
> > >      divisor = (RC) || (RB)
> > >      dividend = EXTZ128(RA)
> > >      RT = UDIV(dividend, divisor)
> > >      RS = UREM(dividend, divisor)
> > looks good!

actually, that's *totally broken*...I just now noticed. you want dividend to be
(RC) || (RB), not divisor. they're accidentally swapped.

> detecting the overflow conditions need adapting,
> in fixedarith divdeu it is:

> it's looking for the scenario where the result
> cannot fit into 64 bit, right?

yeah.

I'd just write it as:
`divrem2du RT,RA,RB,RC`

dividend = (RC) || (RB)
divisor = (RA)
if divisor == 0 or (RC) >= divisor:
    overflow = 1
    RT = 0xFFFF_FFFF_FFFF_FFFF # saturate .. makes some stuff nicer
    RS = 0 # pick a value that won't be bigger than RC
else:
    RT = UDIV(dividend, EXTZ128(divisor))
    RS = UREM(dividend, EXTZ128(divisor))

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Libre-SOC-ISA mailing list