[libre-riscv-dev] [Bug 74] preliminary exploratory software emulation of FP SQRT

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Sun Apr 28 14:54:29 BST 2019


--- Comment #17 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Aleksandar Kostovic from comment #16)
> > try this:
> >
> >for Q in range(1, int(1e7)):
> >    print(Q, sqrt(Q), sqrtsimple(Q), int(Q**0.5))
> >    assert int(Q**0.5) == sqrtsimple(Q), "Q sqrtsimpl fail %d" % Q
> >    assert int(Q**0.5) == sqrt(Q), "Q sqrt fail %d" % Q
> Thats interesting, so as you said it may fail, it fails! Left out the
> sqrtsimple and let sqrt run for a while. It worked well

 great.  so... bye bye sqrt for now.  can always track that down later.

> >you should be able to write the function which takes e and m as arguments,
> > (from comment #3) that handles the core algorithm, in about... 6 lines.
> Got it. Made a function for that and pushed it. Take a look :)

great.  ok so the call to Q() wasn't needed (or, we could do an Object
named Q, but hey, let's keep it dead-simple for now)

btw do you already have sfpy installed and built?  if so, we can move
to the next phase of "from sfpy import Float32" and use that to
mangle/de-mangle FP numbers into sign/mantissa/exponent, using

plus use sfpy.Float32.sqrt function.

i added some "convenience" functions which, given a 32-bit value, will
allow extraction of mantissa, sign and exponent.  and reconstruction.

so, next stage, you want to write a test for-loop around the main() function?
maybe run another for-loop "for e in range(25)" or something, and maaybe
reduce the for-loop around mantissa just a tad? :)

don't delete the existing for-loop and asserts, add *another* for-loop
(this one with 2 nested for's, one for e one for m)

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

More information about the libre-riscv-dev mailing list