Skip to content

[BUG] UF flag is not set by THMULTI DIVSQRT unit in case of tiny non-zero result that is rounded to exacly +/- b^emin

Bug description

I am running a test that performs a double precision division using the following input values. CVFPU is configured to use THMULTI DivSqrt unit, which instanciates T-HEAD OpenC910.

operands_i = '{64'h800fffffffffffff, 64'h3fefffffffffffff, 'h0}
rnd_mode_i = RDN
op_i = DIV
dst_fmt_i = FP64
src_fmt_i = FP64

The computed result by both my reference model (based on mpfr C library) and cvfpu is 64'h8010000000000000 which is the smallest nagative normal number (-b^{emin}). However, the reference model sets the underflow flag while cvfpu does not.

Root cause

This is a corner case where the computed result, as though the exponent range were unbounded, falls within the subnormal range (ie. between ±b^{emin}). Based on the IEEE 754 specifications section 7.5, a tiny non-zero result should be signaled in this case by raising the underflow flag even if the final rounded result is exactly -b^{emin}.