The Division That Isn't
matters at ISA because the verified content is the F/D chapters' invalid-operation contract: 0.0/0.0 raises NV alone, the quotient is the canonical quiet NaN, and no trap fires. The module probes all three halves against the manual's statements: the fcsr triple 0x0 to 0x10 to 0x0, the 0x7FF8000000000000 quotient readback, and the trap counter at zero. The canonical-NaN wording and the payload-refusal reasoning are the spec's own.
not at Microarch because the values under test are architectural constants: the NV definition, the canonical NaN pattern, and the no-trap rule are fixed in the spec's text, so no implementation choice changes a readback. The proof never times anything, and the QEMU 8.2.2 numbers are labeled as the model's, not the architecture's.
matters at Firmware because the module runs at firmware's own privilege level: it reads the boot mstatus, moves FS from Off to Initial before the first floating-point instruction (Off would raise illegal-instruction), installs an M-mode trap handler as the witness, and reads the trap counter back at zero. That is the enable, arm, and leave-no-trace discipline of M-mode boot code around the floating-point unit.
matters at Kernel because the no-trap discipline fixes the kernel's contract with user space: there is no exception path to audit and no trap handler to write, an invalid operation is detected by polling fflags after the computation, and fflags is per-hart state the context switch must save and clear so one process's invalid never accuses another.
not at Algorithm because the verified claim is the hardware's flag contract, not a portable computation: the fourteen checks are CSR readback assertions judged against the spec's text, and no host-independent computation can reproduce an fcsr readback. The indeterminate-form mathematics motivates the rule, but the proof targets the flag, not the math.
Clear fcsr to 0x00, execute one fdiv.d of 0.0 by 0.0, read fcsr back: 0x10. The NV bit, bit 4, stands alone: NX, UF, OF, and DZ all clear, the rounding mode still RNE, the trap counter at zero. The quotient comes back as 0x7FF8000000000000. Fourteen checks, zero mismatches, three byte-identical runs on QEMU 8.2.2. But the interesting half of this proof is not the checks; it is why the standard declares this operation invalid in the first place.
Divide 1.0 by 0.0 and the answer is honest: positive infinity, with the DZ flag raised. The earlier divide-by-zero module probed exactly that case. But 0.0 divided by 0.0 has no answer, because the limit depends on how you approach it: x over x tends to 1, 2x over x tends to 2, x-squared over x tends to 0. The arithmetic cannot name a number, so it must not name one. Infinity minus infinity, infinity times zero, and the square root of a negative number sit in the same box, and IEEE 754 gathers them all under one heading: invalid operation.
The obvious design would be to stop the machine: raise a trap and hand the program an exception. SPARC did exactly that, with hardware trap-enable modes for each flag. RISC-V does not trap. Its rule is quieter: return a NaN, set the NV bit, keep going. That behavior is deliberate. Feed a NaN into further arithmetic and a NaN comes back out, so the error rides the data all the way to wherever you finally look. Finish the work, then read the receipt. One register that remembers, no wire that interrupts. The NaN you get is always the canonical one, 0x7FF8000000000000 for a double: positive sign, all significand bits clear except the quiet bit, in the manual's own words. Carrying the error's origin in payload bits was considered and refused: the manual states plainly that it would have raised the hardware cost, and since payloads are optional in the standard they cannot be used in portable code.
The module is built so the only floating-point actor in the room is the FPU. It compiles for rv64imac_zicsr, which has no F or D, so the C compiler cannot even name the float registers; the operands travel from integer registers through fmv.d.x, and the divide runs inside volatile in-asm so the compiler cannot fold 0.0/0.0 at compile time. A bare fdiv.d assembles with the dynamic rounding mode, so the source spells out the ,rne. The whole divide is five lines:
__asm__ volatile(
"fmv.d.x f2, %1\n\t" /* +0.0 as a bit pattern, into f2 */
"fmv.d.x f3, %2\n\t" /* +0.0 as a bit pattern, into f3 */
"fdiv.d f1, f2, f3, rne\n\t" /* the real instruction under test */
"fmv.x.d %0, f1\n\t"); /* quotient back through an integer register */
Fourteen checks proved three things at once: the operation admits it has no answer, the bit remembers that it happened, and the machine never stops. One sentence to carry away: an operation with no answer returns a value that admits it, sets a bit that remembers it, and lets the machine keep going.
Code: src/fflags-nv-invalid