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

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Sat Apr 27 04:13:50 BST 2019


http://bugs.libre-riscv.org/show_bug.cgi?id=74

--- Comment #3 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
            (v.get_unbiased_exponent_value() & (signed_type)1) !=
(signed_type)0 ?
                from_bits(construct_float(false,
fractional_sqrt(v.get_unsigned_mantissa_value() << 1),
(v.get_unbiased_exponent_value() - (signed_type)1) / (signed_type)2)) :
            from_bits(construct_float(false,
fractional_sqrt(v.get_unsigned_mantissa_value()),
v.get_unbiased_exponent_value() / (signed_type)2));
    }

okaaay, so that's... really hard to decipher... :)
however it's basically what i said in the comment above.

if exponent & 1 != 0: # test LSB
   return ieeefloat(intsqrt(mantissa << 1), # shift mantissa up
                    (exponent - 1) / 2))    # subtract 1 from exp to compensate
else:
   return ieeefloat(intsqrt(mantissa),      # mantissa as-is
                    exponent / 2)           # no compensating needed on exp

basically exactly like is done in FPBase.op_normalise:

                op.e.eq(op.e - 1),  # DECREASE exponent
                op.m.eq(op.m << 1), # shift mantissa UP

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


More information about the libre-riscv-dev mailing list