How is fcvtmod.w.d different from fcvt.w.d?
fcvtmod.w.d takes the low 32 bits of the unbounded RTZ conversion result modulo 2^32; fcvt.w.d uses the official invalid-conversion result for out-of-range integer conversion.
Modular convert double-precision float to signed word (mod 2^32)
32-bit OP-FP fields: opcode=1010011, funct5=11000, fmt=01; rs2=01000 is a fixed selector, not a second source.
rd is x0–x31 and rs1 is f0–f31; rd=x0 discards only the integer write, while fflags still accrues.
RV32/RV64 Zfa+D; explicit rtz is required, rm=001, and other rm encodings are reserved. Enable required extensions and FP state.
After fixed RTZ, sign-extend the low 32 bits of the unbounded result to XLEN; NaN/infinity writes 0. Flags match FCVT.W.D with RTZ for the same input.
Sources narrower than FLEN require valid NaN-boxing, otherwise read canonical NaN. Exception flags accrue in fflags; flag setting alone causes no base FP exception trap.
fcvtmod.w.d is a Zfa instruction. It converts a double-precision value toward zero to an unbounded two's-complement integer, takes the low 32 bits, sign-extends to XLEN, and converts NaN and infinities to zero.
Shows the Zfa + D-extension FCVTMOD flow: decode OP-FP fields, fmt/rs2 conversion selection, fixed rm=001 (RTZ), read the floating-point source, then write the integer destination.
Assume required extensions and FP state are enabled, applicable source NaN-boxing is valid, and initial fflags=0. Results preview the current input; Writeback represents commit.
The word is split as an R-type OP-FP instruction; FCVTMOD uses opcode 1010011.
The current example uses fixed RTZ, takes the low 32 bits of the unbounded two's-complement result, and sign-extends them; fflags shows the NX outcome of FCVT.W.D for the same input.
The current example uses fixed RTZ, takes the low 32 bits of the unbounded two's-complement result, and sign-extends them; fflags shows the NX outcome of FCVT.W.D for the same input.
This animation shows only Zfa + D-extension FCVTMOD ISA-visible encoding, source/destination register direction, rounding field, and example fflags; it does not model FPU pipelines, exception handling, NaN payloads, or microarchitecture.
fcvtmod.w.d is a Zfa instruction. It converts a double-precision value toward zero to an unbounded two's-complement integer, takes the low 32 bits, sign-extends to XLEN, and converts NaN and infinities to zero.
Understand this scenario with real code like «# f0 = 4294967297; initial fflags = 0 fcvtmod.w.d x10, f0, rtz # x10 = 1; NV = 1».
Understand this scenario with real code like «# f0 = 4294967297; initial fflags = 0 fcvtmod.w.d x10, f0, rtz # x10 = 1; NV = 1».
fcvtmod.w.d takes the low 32 bits of the unbounded RTZ conversion result modulo 2^32; fcvt.w.d uses the official invalid-conversion result for out-of-range integer conversion.
Zfa requires assembly syntax to explicitly specify RTZ; other rm encodings are reserved.