[libre-riscv-dev] [Bug 43] create an IEEE754 FP "sqrt"

Aleksandar Kostovic alexandar.kostovic at gmail.com
Thu Apr 25 20:32:36 BST 2019


will look into this carefully! i just need to understand and assemble it in
my head before i build it

On Thu, Apr 25, 2019 at 9:25 PM <bugzilla-daemon at libre-riscv.org> wrote:

> http://bugs.libre-riscv.org/show_bug.cgi?id=43
>
> --- Comment #6 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
> > > paper) into python, which we will *need anyway as part of the unit
> > > tests*.
> > >
>
> > Yes i will convert that code to python.
>
> great.  look fwd to seeing it.  always wanted to impl.
>
> idea.
>
> sqrt of num on 2-bit boundary always whole num.
>
> sqrt 1 -> 1
> sqrt 4 -> 2
> sqrt 16 -> 4
> sqrt 64 -> 8
>
> sqrt of num on *odd* 2-bit boundry *never* whole.
>
> why?
>
> represent as exponent / mantissa, basically exponent LSB has to be zero.
>
> to sqrt exponent, just divide exponent by two.
>
> except, if exp LSB == 1, CANNOT DO THAT.
>
> however... there is a trick:
>
> * add 1 to exponent
> * shift mantissa DOWN by 1 bit to compensate
>
> *NOW* exp LSB is guaranteed to be zero.
>
> *NOW* can divide exp by 2 without destroying (losing) info.
>
> mantissa shifted by 1 means, interestingly, 2-bit loop now has input
> shifted by 1 compared to before.
>
> fascinating.
>
> example
>
> exp = 0b1101, m = 01101011
> ADD 1, SHIFT -->
> exp = 0b1110, m = 00110101 (lose 1 bit, must make room internally!
>                            this is what extra bits are for)
>
> before, m would be divided 01 | 10 | 10 | 11
> now it is divided 00 | 11 | 01 | 01
>
> sqrt: exp /= 2 --> 0b0111, mant = pipealgorithm(00 | 11 | 01 | 01)
>
> example
>
> exp = 0b0100, m = 01010101
> exp LSB = 0, -->
> *NO SHIFT*
>
> sqrt: exp /= 2 --> 0b0010, mant = pipealgorithm(01 | 01 | 01 | 01)
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> _______________________________________________
> libre-riscv-dev mailing list
> libre-riscv-dev at lists.libre-riscv.org
> http://lists.libre-riscv.org/mailman/listinfo/libre-riscv-dev
>


More information about the libre-riscv-dev mailing list