Home/Instructions/FROUNDNX-Q
FROUNDNX.Q

RISC-V FROUNDNX.Q Instruction Details

Instruction ManualR-type

Round a quad-precision floating-point value to an integral value in the same FP format; set NX only when the input is not NaN and differs from the rounded result.

Instruction Syntax

froundnx.q rd, rs1, rm
Operand Breakdown
rd: destination floating-point register receiving the rounded result in the same format.
rs1: the only source floating-point register; the encoded rs2 field is fixed to 00101 (decimal 5), not a second source floating-point register.
rm: rounding-mode field; rm=111 uses the dynamic frm rounding mode.
ZfaQFP Precision

Instruction Behavior

When the Q extension is implemented, FROUNDNX.Q rounds the quad-precision floating-point value in f[rs1] to an integral value according to rm, but writes the result back to f[rd] in the same quad-precision floating-point format. It sets NX only when the input is not NaN and differs from the rounded result. A signaling NaN sets NV; a quiet NaN produces the canonical NaN under the general FP NaN rule.

FROUNDNX.Q Decode And Execute Animation

Shows the Zfa + Q-extension quad-precision OP-FP flow: decode fields, read FP operands, perform FROUNDNX semantics, then write rd.

rd
rs1
rm
froundnx.q
,
,
Execution Context
FLEN=128 / fmt=Q (11)
rounding: RNE nearest-even
fflags: NX
31..27
26..25
24..20
19..15
14..12
11..7
6..0
01000
FROUNDNX
11
fmt=Q
00101
rs2=5 (roundToIntegralExact)
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x46558553
opcode
1010011 -> OP-FP
funct5/fmt
01000 + Q(11) -> FROUNDNX.Q
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / rs2=00101 (fixed)
read
1.5
FP op
roundToIntegralExact(1.5, RNE nearest-even) = 2.0
write
fa0(f10) = 2.0; NX
Current Step

Fetch: show the 32-bit OP-FP encoding

The word is split as an R-type OP-FP instruction; quad-precision OP-FP instructions use opcode 1010011.

encoding: 0x46558553
syntax : froundnx.q fa0(f10), fa1(f11), rne
result : fa0(f10) = 2.0; NX

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUNDNX.Q writes the integral value in Q format. Zero and infinity are copied. NX is set when the input differs from the rounded result and is not NaN.

Quad-precision Calculation
rs1
fa1(f11) = 1.5
rs2
ft5(f5) = 0.0
result
roundToIntegralExact(1.5, RNE nearest-even) = 2.0

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUNDNX.Q writes the integral value in Q format. Zero and infinity are copied. NX is set when the input differs from the rounded result and is not NaN.

This animation shows only Zfa + Q-extension ISA-visible OP-FP encoding, example numeric results, and fflags relationship; it does not model FPU pipelines, latency, every IEEE 754 corner case, or microarchitecture.

Quick Understanding & Search Notes

FROUNDNX.Q differs from FCVT by output type: FROUNDNX.Q still writes a floating-point register, with the value rounded to an integral value. It reports NX when a non-NaN input changes.

rm selects the rounding direction, with frm supplying dynamic rounding; rm=101/110 and reserved frm values under DYN have reserved behavior.
Special values such as zero and infinity follow the Zfa rules; signaling NaNs still set NV.

Common Usage Scenarios

Floating-Point Rounding

Understand this scenario with real code like «froundnx.q f0, f1, rne # NX only when non-NaN f1 changes after rounding».

Numeric Format Handling

Understand this scenario with real code like «froundnx.q f0, f1, rne # NX only when non-NaN f1 changes after rounding».

Pre-Use Checklist

Syntax Check
  • rd: destination floating-point register receiving the rounded result in the same format.
  • rs1: the only source floating-point register; the encoded rs2 field is fixed to 00101 (decimal 5), not a second source floating-point register.
  • rm: rounding-mode field; rm=111 uses the dynamic frm rounding mode.
Semantic Check
  • Confirm the floating-point format suffix (.H/.S/.D/.Q) matches the data width.
  • Decide whether software must inspect fflags for NV, DZ, OF, UF, or NX.

Pitfalls / Common Confusions

FROUNDNX sets NX only when the input is not NaN and differs from the rounded result; do not confuse it with FROUND, which does not set NX.
The result is still floating-point, not an integer-register result; use FCVT for an integer result.
rm controls the direction for rounding to an integral value; static rm=101/110 and reserved frm values under DYN have reserved behavior.

FAQ

Does FROUNDNX.Q write an integer register?

No. The result is written to floating-point register f[rd]; the floating-point value is integral.

How does FROUNDNX.Q differ from the other FROUND form?

FROUNDNX sets NX only when the input is not NaN and differs from the rounded result; FROUND does not set NX.