Home/Instructions/Float to Unsigned Int Double
FCVT.WU.D

RISC-V FCVT.WU.D Instruction Details

Instruction ManualOP-FP conversion fields

Round a double-precision source using rm to an unsigned 32-bit integer; RV64 sign-extends bit 31 to XLEN.

Instruction Syntax

fcvt.wu.d rd, rs1[, rm]

rd is integer x0–x31; rs1 is FP f0–f31 (ABI names accepted). x10 and f10 are different registers. rs2 selects integer type; no immediate. rd=x0 discards only the integer result; NV/NX still accrue in fflags.

32-bit OP-FP: funct5=11000, fmt=01 (FP source), rs2=00001 (WU), opcode=1010011.

RV32/RV64; requires D (F). Enable required extensions and FP state. Optional rm defaults to dyn using frm; static 101/110 and dynamic frm=101–111 have reserved behavior.

Round using rm before testing the 0..2^32-1 range. Negative out-of-range/-infinity yields 0; positive out-of-range/+infinity/NaN yields 2^32-1 and sets NV. A changed result sets NX only without NV. RV64 sign-extends bit 31, including WU.

A source narrower than FLEN needs NaN-boxing with all upper bits set; otherwise convert its canonical NaN. Exception flags accrue in fflags; flag setting alone causes no FP exception trap. Animation assumes valid applicable NaN-boxing and initial fflags=0; numeric previews commit at Writeback.

DFloating-Point Convert

Instruction Behavior

fcvt.wu.d converts a double-precision source operand to an unsigned 32-bit integer result. Floating-point-to-integer conversion rounds according to rm and writes integer register rd.

FCVT.WU.D Decode And Execute Animation

Shows the D-extension FCVT flow: decode OP-FP fields, fmt/rs2 conversion selection, the rm rounding field, read the floating-point source, then write the integer destination.

rd
rs1
rm
fcvt.wu.d
,
,

Leave rm empty for the assembly default dyn (111); this DYN example fixes frm=RNE. Use lowercase rne/rtz/rdn/rup/rmm/dyn only.

Execution Context
fmt=D (01)
rs2=WU
rounding: RNE nearest-even
fflags: NX

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.

31..27
26..25
24..20
19..15
14..12
11..7
6..0
11000
FCVT.WU
01
fmt=D
00001
rs2=WU
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0xC2158553
opcode
1010011 -> OP-FP
funct5/fmt
11000 + 01 -> FCVT.WU.D
rs2
00001 -> WU target
rm
000 -> RNE nearest-even
rd/rs1
a0(x10) / fa1(f11)
read
fa1(f11) = 42.75
convert
42.75 -> uint32 0x0000002B (43)
write
a0(x10) = 0x0000002B (43); NX
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; FCVT uses opcode 1010011.

encoding: 0xC2158553
syntax : fcvt.wu.d a0(x10), fa1(f11), rne
result : a0(x10) = 0x0000002B (43); NX

The current example rounds to a 32-bit integer according to rm and shows NX because the source has a fractional part.

FCVT Conversion View
D FP source
42.75
conversion
42.75 -> uint32 0x0000002B (43)
writeback
a0(x10) = 0x0000002B (43)

The current example rounds to a 32-bit integer according to rm and shows NX because the source has a fractional part.

This animation shows only D-extension FCVT ISA-visible encoding, source/destination register direction, rounding field, and example fflags; it does not model FPU pipelines, exception handling, NaN payloads, or microarchitecture.

Quick Understanding & Search Notes

fcvt.wu.d converts a double-precision source operand to an unsigned 32-bit integer result. Floating-point-to-integer conversion rounds according to rm and writes integer register rd.

OP-FP opcode is 1010011; funct5=11000 denotes FP-to-integer FCVT and fmt=01 denotes D source format.
rs2=00001 selects the WU unsigned 32-bit integer target; rm controls rounding.
rd is an integer register and rs1 is a double-precision FP register; the result is not an FP encoding.
NX is set only when the rounded result differs from the source and NV is not set; NaN, negative out-of-range, or out-of-range uint32 inputs set NV by the official rule.
On RV64, a WU result is still sign-extended to XLEN from its 32-bit bit pattern.

Common Usage Scenarios

Double-Precision to unsigned 32-bit integer conversion

Understand this scenario with real code like «fcvt.wu.d x10, f11, rtz # f11=1.5 -> x10=1; fflags=NX # RV32/RV64; required extensions and FP state enabled # Valid NaN-boxing when required; initial fflags=0».

Pre-Use Checklist

Syntax Check
  • rd is integer x0–x31; rs1 is FP f0–f31 (ABI names accepted). x10 and f10 are different registers. rs2 selects integer type; no immediate. rd=x0 discards only the integer result; NV/NX still accrue in fflags.
  • 32-bit OP-FP: funct5=11000, fmt=01 (FP source), rs2=00001 (WU), opcode=1010011.
Semantic Check
  • RV32/RV64; requires D (F). Enable required extensions and FP state. Optional rm defaults to dyn using frm; static 101/110 and dynamic frm=101–111 have reserved behavior.
  • Round using rm before testing the 0..2^32-1 range. Negative out-of-range/-infinity yields 0; positive out-of-range/+infinity/NaN yields 2^32-1 and sets NV. A changed result sets NX only without NV. RV64 sign-extends bit 31, including WU.
  • A source narrower than FLEN needs NaN-boxing with all upper bits set; otherwise convert its canonical NaN. Exception flags accrue in fflags; flag setting alone causes no FP exception trap. Animation assumes valid applicable NaN-boxing and initial fflags=0; numeric previews commit at Writeback.

Pitfalls / Common Confusions

On RV64, W/WU 32-bit results are sign-extended to XLEN even though WU has an unsigned numeric interpretation.
For unsigned WU, negative out-of-range inputs or -infinity write 0; positive out-of-range inputs, +infinity, or NaN write 2^32-1 and set NV.
Floating-point source operands in wider FLEN registers must satisfy NaN-boxing rules.

FAQ

Can rm be omitted?

Yes; it defaults to dyn and uses frm.

When are NV and NX set?

Check the range after rounding. Invalid conversion sets NV; a result differing from the source sets NX only without NV.