Overview
FCVTMOD.W.D is a floating-point-to-integer conversion instruction in the RISC-V ISA. It is part of the Zfa extension for additional floating-point operations and is implemented in the sail-riscv reference model.
Semantics
The FCVTMOD.W.D instruction is defined similarly to FCVT.W.D, with the following differences:
- Rounding mode: FCVTMOD.W.D always rounds towards zero.
- Result truncation: Bits 31:0 are taken from the rounded, unbounded two's complement result, then sign-extended to XLEN bits and written to integer register
rd. - Exceptional inputs: Positive infinity, negative infinity, and NaN are converted to zero.
Zfa Extension Context
FCVTMOD.W.D was introduced alongside other Zfa instructions, including:
FLI.[HSD]FMINM.[HSD]andFMAXM.[HSD]FROUND.[HSD]andFROUNDNX.[HSD]FMVH.X.DandFMVP.D.XFLEQ.[HSD]andFLTQ.[HSD]
Quad-precision floating-point variants are excluded from this initial Zfa implementation.
Implementation
The sail-riscv formal specification model added Zfa extension support (excluding quad-precision) in commit f2d8e1b9, which includes the FCVTMOD.W.D instruction along with the necessary infrastructure (such as the Zfa existence macro).
Relationships
- Part of: Zfa extension
- Derived from: FCVT.W.D
- Implemented by: sail-riscv