[libre-riscv-dev] fcvt and exponent/mantissa shifting

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sun Jul 21 12:44:30 BST 2019


code that was formerly exclusively used in post-normalisation, i've
just separated out into a separate module
https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/ieee754/fpcommon/postnormalise.py;hb=HEAD#l119

there's now two classes:

* FPMSBHigh - this one is designed to *decrease* the exponent
(subtract) and shift the mantissa up so that the MSB is "1".  this
(jacob) is the class that should be adopted / adapted to add the
option to have the exponent be an even number

* FPEXPHigh - this one is designed to *increase* the exponent (add)
and shift the mantissa *down*, and it is specifically, specifically
designed to "accumulate" the LSBs into the last bit, as the "sticky"
bit.

https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/ieee754/fpcommon/exphigh.py;hb=HEAD
https://git.libre-riscv.org/?p=ieee754fpu.git;a=blob;f=src/ieee754/fpcommon/msbhigh.py;hb=HEAD

i previously mentioned the places where FPMSBHigh was being used:
FPMUL alignment, FCVT int to FP (where the INT is treated directly as
the mantissa, and the exponent is the *width* of the integer:
FPMSBHigh churns on that and, ta-daa, the output *is* the normalised
result).

the reason i've had to split out FPEXPHigh as well (from where it was
formerly used exclusively in postnormalise) is because FCVT FP to int
requires the *reverse* of the int-to-FP process.  the FP mantissa has
to be shifted *down* until the exponent equals (exactly) the width of
the target integer.

just an fyi so that code doesn't get duplicated.

l.



More information about the libre-riscv-dev mailing list