[BUG] Incorrect Setting of DZ Flag for 0/0 Division
Created by: youzi27
Is there an existing CVA6 bug for this?
-
I have searched the existing bug issues
Bug Description
I have observed an incorrect behavior in the CVA6 core regarding the handling of the 0/0 division operation. Specifically, the Divide by Zero (DZ
) flag is incorrectly set for this operation, which according to IEEE 754 standards (Standard for Floating-Point Arithmetic section 7.3):
7.3 Division by zero 7.3.0 The divideByZero exception shall be signaled if and only if an exact infinite result is defined for an operation on finite operands. The default result of divideByZero shall be an ∞ correctly signed according to the operation: ― For division, when the divisor is zero and the dividend is a finite non-zero number, the sign of the infinity is the exclusive OR of the operands’ signs (see 6.3).
So, it should only trigger the Invalid Operation (NV
) flag, since 0/0 is an undefined operation resulting in NaN.
The log is as follows:
core 0: 0x0000000080005aa0 (0x001025f3) csrrs a1, fflags, zero
1 0x0000000080005aa0 (0x001025f3) x11 0x0000000000000000
core 0: 0x0000000080005aa4 (0x221080d3) fsgnj.d ft1, ft1, ft1
1 0x0000000080005aa4 (0x221080d3) f 1 0x0000000000000000
core 0: 0x0000000080005aa8 (0x1a10f953) fdiv.d fs2, ft1, ft1
1 0x0000000080005aa8 (0x1a10f953) f18 0x7ff8000000000000
core 0: 0x0000000080005aac (0x00102673) csrrs a2, fflags, zero
1 0x0000000080005aac (0x00102673) x12 0x0000000000000018