[libre-riscv-dev] [Bug 74] preliminary exploratory software emulation of FP SQRT
bugzilla-daemon at libre-riscv.org
bugzilla-daemon at libre-riscv.org
Thu Apr 25 20:27:06 BST 2019
http://bugs.libre-riscv.org/show_bug.cgi?id=74
Luke Kenneth Casson Leighton <lkcl at lkcl.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lkcl at lkcl.net
NLnet milestone|--- |NLnet.2019.02
--- Comment #1 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
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.
More information about the libre-riscv-dev
mailing list