Home/Instructions/FCVT.WU.Q
FCVT.WU.Q

RISC-V FCVT.WU.Q Instruction Details

Instruction ManualR-type

Round quad-precision FP to unsigned 32-bit integer; RV64 still sign-extends.

Instruction Syntax

fcvt.wu.q rd, rs1, rm

32-bit OP-FP fields: opcode=1010011, funct5=11000, fmt=11; rs2=00001 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 Q (requires D and F); optional rm defaults to dyn using frm. Static 101/110 and dynamic frm=101–111 have reserved behavior. Enable required extensions and FP state.

Round using rm before checking 0..2^32−1: negative out-of-range/−infinity writes 0, positive out-of-range/+infinity/NaN writes 2^32−1 with NV. A changed result sets NX only without NV. RV64 sign-extends bit 31.

The Q source uses FLEN=128. Exception flags accrue in fflags; flag setting alone causes no base FP exception trap.

QFloating-Point Convert

Instruction Behavior

fcvt.wu.q rounds the quad-precision value in FP register rs1 to an unsigned 32-bit integer in integer rd. Validity is checked after rounding against 0 through 2^32−1. RV64 sign-extends bit 31 to XLEN, including WU results.

FCVT.WU.Q Decode And Execute Animation

Shows the Q-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.q
,
,

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=Q (11)
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
11
fmt=Q
00001
rs2=WU
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0xC6158553
opcode
1010011 -> OP-FP
funct5/fmt
11000 + 11 -> FCVT.WU.Q
rs2
00001 -> WU target
rm
000 -> RNE nearest-even
rd/rs1
a0(x10) / fa1(f11)
read
fa1(f11) = 3.5
convert
3.5 -> uint32 0x00000004 (4)
write
a0(x10) = 0x00000004 (4); 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: 0xC6158553
syntax : fcvt.wu.q a0(x10), fa1(f11), rne
result : a0(x10) = 0x00000004 (4); 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
Q FP source
3.5
conversion
3.5 -> uint32 0x00000004 (4)
writeback
a0(x10) = 0x00000004 (4)

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 Q-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.q rounds the quad-precision value in FP register rs1 to an unsigned 32-bit integer in integer rd. Validity is checked after rounding against 0 through 2^32−1. RV64 sign-extends bit 31 to XLEN, including WU results.

32-bit OP-FP encoding: opcode=1010011, funct5=11000, fmt=11, rs2=00001 selects WU; rs2 is not a second source register.
rd is an integer register and rs1 is an FP register; W/WU forms are available on RV32 and RV64.
rm=000/001/010/011/100 select RNE/RTZ/RDN/RUP/RMM; rm=111 uses frm. Reserved rounding modes have reserved behavior.
NX is set when the rounded result differs from the source, provided NV is not set; fflags accrues exceptions, and the base FP ISA does not trap merely because these flags are set.

Common Usage Scenarios

FP-to-unsigned-integer conversion

Understand this scenario with real code like «# f0 = 3.5; initial fflags = 0 fcvt.wu.q x10, f0, rtz # x10 = 3; NX = 1».

Pre-Use Checklist

Syntax Check
  • 32-bit OP-FP fields: opcode=1010011, funct5=11000, fmt=11; rs2=00001 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.
Semantic Check
  • RV32/RV64 Q (requires D and F); optional rm defaults to dyn using frm. Static 101/110 and dynamic frm=101–111 have reserved behavior. Enable required extensions and FP state.
  • Round using rm before checking 0..2^32−1: negative out-of-range/−infinity writes 0, positive out-of-range/+infinity/NaN writes 2^32−1 with NV. A changed result sets NX only without NV. RV64 sign-extends bit 31.
  • The Q source uses FLEN=128. Exception flags accrue in fflags; flag setting alone causes no base FP exception trap.

Pitfalls / Common Confusions

Check range after rounding: RNE converts -0.5 to 0 with NX; RDN rounds it to -1, clips to 0, and sets NV.
A rounded value below 0 or −∞ writes 0; a rounded value above 2^32−1, +∞, or NaN writes 2^32−1 with NV. NX is not set when NV is set.
RV64 sign-extends the 32-bit result; rd=x0 discards the integer write but fflags still accrues.
Q uses FLEN=128.

FAQ

Does every negative input set NV?

No. Range is checked after rounding: -0.5 under RNE or RTZ becomes 0 with NX, while RDN produces an out-of-range −1 and sets NV.

Does WU zero-extend on RV64?

No. The 32-bit result is sign-extended to XLEN. For example, unsigned target 2^32−1 writes 0xFFFFFFFFFFFFFFFF.