[libre-riscv-dev] [Bug 117] RISCV FCLASS instruction needed

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Sun Jul 28 12:08:18 BST 2019


--- Comment #7 from Jacob Lifshay <programmerjake at gmail.com> ---
(In reply to Luke Kenneth Casson Leighton from comment #6)
> ok added fclass test, including adding some extra functions to
> FPFormat, jacob can you verify the logic there, i had to add
> not just the hardware-check, there's no softfloat-3 "fclass"
> function so had to write that as well: that's unverified-check
> against unverified-check.

FPFormat.is_nan is either misimplemented or misnamed/misdocumented. as written,
it detects only quiet NaNs. to detect any NaN, the exponent has to be the max
value and the mantissa non-zero.

the documentation on FPFormat.mantissa_mask and FPFormat.is_zero is incorrect.

I would rename get_mantissa to get_mantissa_field, since it seems reasonable to
add a get_mantissa_value function that includes the implicit 1 bit (except on
denormals/zero -- implicit 0 bit for those cases) since that is the
mathematical mantissa value, not the version missing the implicit bit.

FPFormat.get_sign should be named get_sign_field and the docs adjusted, since I
would expect get_sign to return 1 or -1, not 0 or 1.

is_subnormal needs a ')' in the doc string

I think I probably messed up this one: the doc string for mantissa_mask says
exponent field

not that it matters much: FPFormat.is_nan_signalling: spell using one l, since
that's how it's spelled in IEEE 754

handy addition: add a get_exponent_field that returns the bits without
subtracting the bias and implement in terms of that, just compare
get_exponent_field with exponent_(inf_nan|denormal_zero) without needing emax
or e_sub, since that saves a subtraction and matches the rest of the class.

maybe add a exponent_mask property, like mantissa_mask, then implement
get_exponent_field as:
def get_exponent_field(self, x):
    """ Returns the biased exponent of its input number, x. """
    return (x & self.exponent_mask) >> self.m_width

other than all that, FPFormat appears to be correct

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

More information about the libre-riscv-dev mailing list