[libre-riscv-dev] [Bug 74] preliminary exploratory software emulation of FP SQRT
bugzilla-daemon at libre-riscv.org
bugzilla-daemon at libre-riscv.org
Mon Apr 29 15:42:40 BST 2019
http://bugs.libre-riscv.org/show_bug.cgi?id=74
--- Comment #32 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
shock! near-total guess-work, and this works!
m |= 1<<23 # set top bit (the missing "1" from mantissa)
m <<= 25
sm, se = main(m, e)
sm >>= 1
sm = get_mantissa(sm)
ok so the |= 1<<23 wasn't total guess-work, that's what softfloat does:
sigA = (sigA | 0x00800000)<<8;
which is to set bit 23 (and then shift up by 8)
i shifted up by 25 - as a guess - to give a couple extra bits in the
mantissa, then shifted down by one (sm >>= 1)
the call to get_mantissa() masks out the top bits... we should really
call "normalise" to adjust exp/mantissa...
so quite a lot to be done, however that's the hard part.
dang that was lucky.
x 1234.1234130859375 <class 'sfpy.float.Float32'>
sqrt 35.13009262084961
1150960627 <class 'int'>
x decode 0 10 1721331 0x1a43f3
our sqrt 0 5 820535 0xc8537 0b11001000010100110111
sf32 sqrt 0 5 820535 0xc8537 0b11001000010100110111
x 32.099998474121094 <class 'sfpy.float.Float32'>
sqrt 5.665686130523682
1107322470 <class 'int'>
x decode 0 5 26214 0x6666
our sqrt 0 2 3493196 0x354d4c 0b1101010100110101001100
sf32 sqrt 0 2 3493197 0x354d4d 0b1101010100110101001101
x 16.0 <class 'sfpy.float.Float32'>
sqrt 4.0
1098907648 <class 'int'>
x decode 0 4 0 0x0
our sqrt 0 2 0 0x0 0b0
sf32 sqrt 0 2 0 0x0 0b0
x 8.0 <class 'sfpy.float.Float32'>
sqrt 2.8284270763397217
1090519040 <class 'int'>
x decode 0 3 0 0x0
our sqrt 0 1 3474675 0x3504f3 0b1101010000010011110011
sf32 sqrt 0 1 3474675 0x3504f3 0b1101010000010011110011
x 8.5 <class 'sfpy.float.Float32'>
sqrt 2.915475845336914
1091043328 <class 'int'>
x decode 0 3 524288 0x80000
our sqrt 0 1 3839784 0x3a9728 0b1110101001011100101000
sf32 sqrt 0 1 3839784 0x3a9728 0b1110101001011100101000
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-riscv-dev
mailing list