FROUND.S

RISC-V FROUND.S Instruction Details

Instruction ManualR-type

Round a single-precision floating-point value to an integral value in the same FP format, without setting NX.

Instruction Syntax

fround.s rd, rs1[, rm]
Operand Breakdown
rd, rs1: FP registers f0–f31 or ABI names; f0 is writable and rd may overlap rs1.
rs1 is the only source; rs2=00100 is a fixed selector. Optional rm defaults to dyn; 111 uses frm. Static 101/110 and dynamic frm=101–111 have reserved behavior.
ZfaFFP Precision

Instruction Behavior

FROUND.S requires RV32/RV64 Zfa+F and enabled FP state. It rounds the single-precision value in f[rs1] to an integral value according to rm and writes it in S format to f[rd]. Zero and infinity are copied unchanged. NaN results are canonical; signaling NaN accrues NV. It does not set NX. It sets no DZ, OF or UF and does not clear existing fflags.

FROUND.S Decode And Execute Animation

Shows the Zfa + F-extension single-precision OP-FP flow: decode fields, read FP operands, perform FROUND semantics, then write rd.

rd
rs1
rm
fround.s
,
,

Leave rm empty to use the assembly default dyn encoding and fcsr.frm below.

Execution Context
FLEN>=32 / fmt=S (00)
rounding: RNE nearest-even
fflags: initial 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
01000
FROUND
00
fmt=S
00100
rs2=4 (roundToIntegral)
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x40458553
opcode
1010011 -> OP-FP
funct5/fmt
01000 + S(00) -> FROUND.S
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / rs2=00100 (fixed)
read
Source registers not read yet
FP op
Awaiting Execute
write
Not written yet; initial fflags=0
Current Step

Fetch: show the 32-bit OP-FP encoding

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

encoding: 0x40458553
syntax : fround.s fa0(f10), fa1(f11), rne
result : Not written yet; initial fflags=0

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUND.S writes the integral value in S format. Zero and infinity are copied. FROUND does not set NX and sets no exception flags other than NV.

Single-precision Calculation
rs1
fa1(f11) = 1.5
result
Awaiting Execute

This bounded teaching model computes whitelisted finite examples plus zero, infinity, and NaN; FROUND.S writes the integral value in S format. Zero and infinity are copied. FROUND does not set NX and sets no exception flags other than NV.

Assumes Zfa + F, FS enabled, correctly NaN-boxed inputs, and initial fflags=0. Accepts the listed exact finite whitelist, signed zeros, infinity, qNaN, and sNaN. Rounding uses rm/frm; zero and infinity are copied, and sNaN sets NV. FROUND does not set NX. rd may overlap rs1, and f0 accepts writeback. Steps are teaching views.

This animation shows only Zfa + F-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

FROUND.S rounds a single-precision value to an integral value in an FP register. It does not set NX. It does not convert to an integer register.

Requires Zfa 1.0 and F; Zfa depends on F. rd and rs1 are FP registers f0–f31; f0 is writable and rd may overlap rs1.
32-bit OP-FP: funct5=01000, fmt=00 (S), rs2=00100, rs1, rm, rd, opcode=1010011. rs2 is a fixed selector, not a second source.
Optional rm defaults to dyn: 000/001/010/011/100 select rne/rtz/rdn/rup/rmm; 111 uses frm. Static 101/110 and dynamic frm=101–111 have reserved behavior.
Operands narrower than FLEN must be correctly NaN-boxed; otherwise they are treated as canonical NaNs in their format. Narrower results get their upper FLEN minus format-width bits set to ones.
Zero and infinity are copied unchanged; NaN results are canonical and signaling NaN accrues NV. It does not set NX. No DZ, OF or UF is set; existing fflags are not cleared and setting a flag does not itself cause an FP exception trap.
The animation assumes valid NaN-boxing and initial fflags=0. It accepts the listed exact finite whitelist plus signed zeros, infinity, qNaN and sNaN; arbitrary decimal inputs are not simulated.

Common Usage Scenarios

Floating-Point Rounding

Assume required extensions and FP state enabled, f11=1.5 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the rne example writes f10=2.0 in an FP register; no exception flags are added, so fflags remains 0.

Numeric Format Handling

Assume required extensions and FP state enabled, f11=1.5 in this format (validly NaN-boxed when narrower than FLEN), and initial fflags=0: the rne example writes f10=2.0 in an FP register; no exception flags are added, so fflags remains 0.

Pre-Use Checklist

Syntax Check
  • rd, rs1: FP registers f0–f31 or ABI names; f0 is writable and rd may overlap rs1.
  • rs1 is the only source; rs2=00100 is a fixed selector. Optional rm defaults to dyn; 111 uses frm. Static 101/110 and dynamic frm=101–111 have reserved behavior.
Semantic Check
  • Confirm Zfa, the matching precision extension, enabled FP state, and valid NaN-boxing for narrower sources.
  • The result stays in the same FP format. Zero and infinity are copied; NaN results are canonical, and sNaN adds NV. No NX is added. No DZ, OF or UF is added; existing fflags are preserved.

Pitfalls / Common Confusions

FROUND does not set NX; use FROUNDNX to set NX when the input differs from the rounded result and is not NaN.
The result stays in an FP register; for an integer-register result use FCVT.W[U].S, or FCVT.L[U].S on RV64 only.
rm controls the direction for rounding to an integral value.

FAQ

Does FROUND.S write an integer register?

No. The result is written to FP register f[rd] in the original precision; zero, infinity and NaN follow the special rules listed on this page.

How does FROUND.S differ from the other FROUND form?

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