FDIV.S

RISC-V FDIV.S Instruction Details

Instruction ManualR-type

Performs single-precision floating-point division: f[rd] = f[rs1] / f[rs2].

Instruction Syntax

fdiv.s rd, rs1, rs2, rm
Operand Breakdown
rd: destination floating-point register receiving the formatted result.
rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for rounding mode.
FFloating-Point Arithmetic

Instruction Behavior

FDIV.S uses OP-FP encoding with fmt=S to divide two single-precision floating-point operands, rounds according to rm or dynamic frm, and writes the result to FP register rd. Divide-by-zero, 0/0, infinities, NaNs, inexact, overflow, and underflow cases produce results and fflags according to the RISC-V F-extension floating-point rules; not every zero-divisor case is the same result.

FDIV.S Decode And Execute Animation

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

rd
rs1
rs2
rm
fdiv.s
,
,
,
Execution Context
FLEN=32 / fmt=S (00)
rounding: RNE nearest-even
fflags: example fflags remains 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
00011
FDIV
00
fmt=S
01100
rs2
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x18C58553
opcode
1010011 -> OP-FP
funct5/fmt
00011 + S(00) -> FDIV.S
rm
000 -> RNE nearest-even
rd/rs
fa0(f10) / fa1(f11) / fa2(f12)
read
7.5, 2.5
FP op
7.5 / 2.5 = 3.0
write
fa0(f10) = 3.0; example fflags remains 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: 0x18C58553
syntax : fdiv.s fa0(f10), fa1(f11), fa2(f12), rne
result : fa0(f10) = 3.0; example fflags remains 0

The default example 7.5 / 2.5 = 3.0 is exactly representable, so example fflags remains 0.

Single-precision Calculation
rs1
fa1(f11) = 7.5
rs2
fa2(f12) = 2.5
result
7.5 / 2.5 = 3.0

The default example 7.5 / 2.5 = 3.0 is exactly representable, so example fflags remains 0.

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

FDIV.S is the F-extension single-precision divide. The machine encoding uses opcode=OP-FP, funct5=FDIV, fmt=S, and rm; the result is written to an FP register, while special values and exception flags follow the official FP rules.

The syntax operands are rd, rs1, rs2, and rm; source values and fflags are execution context, not assembly operands.
fmt=S denotes 32-bit single precision; rounding comes from rm or dynamic frm.
The animation uses the exact example 7.5 / 2.5 = 3.0, so example fflags remains 0; real inexact or special-value cases may still set fflags.

Common Usage Scenarios

Multiplication & Division

Understand this scenario with real code like «fdiv.s f0, f1, f2 # f0 = f1/f2 (RNE)».

Pre-Use Checklist

Syntax Check
  • rd: destination floating-point register receiving the formatted result.
  • rs1/rs2: source floating-point registers; arithmetic/rounding forms with rm use rm or dynamic frm for 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

rm=111 selects dynamic frm rounding; other valid rm values are static rounding modes.
Floating-point exceptions are recorded in fflags, not integer traps or condition codes.
0/0 is an invalid operation; finite nonzero division by zero and NaN/infinity combinations must not be collapsed into one simple rule.

FAQ

Why does the FDIV.S animation not directly show division by zero?

The animation teaches encoding, register read, rounding-field decode, and the ordinary execution path. Zero divisors, 0/0, NaNs, and infinities are covered in static text to avoid oversimplifying special-value rules.

Does FDIV.S raise integer exceptions?

It does not report results through integer condition codes; floating-point exceptions are recorded in fflags and results follow the RISC-V FP rules.