FCVT.S.D

RISC-V FCVT.S.D Instruction Details

Instruction ManualR-type

Convert double-precision FP to single-precision FP; narrowing conversion rounds according to rm.

Instruction Syntax

fcvt.s.d rd, rs1, rm
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
DFloating-Point Convert

Instruction Behavior

fcvt.s.d reads a double-precision source value from FP register rs1, converts it to a single-precision FP result, and writes FP register rd. In the OP-FP encoding, fmt=S (00) denotes the destination format and rs2=D (01) denotes the source format; this narrowing conversion rounds according to rm/frm when the destination format cannot represent the source exactly and may set FP exception flags.

FCVT.S.D Decode And Execute Animation

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

rd
rs1
rm
fcvt.s.d
,
,
Execution Context
fmt=S (00)
rs2=D
rounding: RNE nearest-even
fflags: 0
31..27
26..25
24..20
19..15
14..12
11..7
6..0
01000
FCVT.S
00
fmt=S
00001
rs2=D
01011
rs1
000
rm
01010
rd
1010011
OP-FP
Execution Data Path
instruction
0x40158553
opcode
1010011 -> OP-FP
funct5/fmt
01000 + 00 -> FCVT.S.D
rs2
00001 -> D source
rm
000 -> RNE nearest-even
rd/rs1
fa0(f10) / fa1(f11)
read
fa1(f11) = D 1.5 (0x3FF8000000000000)
convert
D 1.5 -> S 1.5
write
fa0(f10) = S 1.5 (0x3FC00000); 0
Current Step

Fetch: show the 32-bit OP-FP encoding

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

encoding: 0x40158553
syntax : fcvt.s.d fa0(f10), fa1(f11), rne
result : fa0(f10) = 1.5; 0

D-to-S is a floating-point narrowing conversion; the current example is exactly representable by the target format and leaves fflags at 0.

FCVT Conversion View
D FP source
D 1.5 (0x3FF8000000000000)
conversion
D 1.5 -> S 1.5
writeback
fa0(f10) = S 1.5 (0x3FC00000)

D-to-S is a floating-point narrowing conversion; the current example is exactly representable by the target format and leaves fflags at 0.

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.s.d is an FP-to-FP format conversion: rd and rs1 are FP registers, fmt encodes destination S, and rs2 encodes source D. The narrowing conversion rounds according to rm/frm and may set FP exception flags such as NX, OF, or UF.

OP-FP opcode is 1010011; funct5=01000 denotes FP-to-FP format FCVT.
fmt=00 selects destination S (single-precision); rs2=01 selects source D (double-precision).
rd and rs1 are both FP registers; the rs2 field is a source-format selector, not an assembly operand.
The narrowing conversion rounds according to rm or dynamic frm when needed and records applicable FP exception flags in fflags.
NaN-boxing applies to source checking and destination writeback in wider FLEN registers; the animation does not enumerate every NaN payload or special-value combination.

Common Usage Scenarios

Floating-Point Format Conversion

Understand this scenario with real code like «fcvt.s.d f0, f1, rne # f0 = (single-precision)(f1 as double-precision)».

Type Conversion

Understand this scenario with real code like «fcvt.s.d f0, f1, rne # f0 = (single-precision)(f1 as double-precision)».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

fmt=S selects the destination single-precision format; rs2=D selects the source double-precision format and is not a second source register.
This is a floating-point narrowing conversion; rm or dynamic frm selects rounding when the destination format cannot represent the source exactly.
The FP source in a wider FLEN register must satisfy NaN-boxing; the result is NaN-boxed according to the destination format.
The animation shows finite checkable examples only; NaNs, infinities, overflow, underflow, and payload details follow the official manual text.

FAQ

Is rs2 a source register in fcvt.s.d?

No. The assembly syntax has rd, rs1, rm only; the encoded rs2 field selects the source D FP format.

When does fcvt.s.d use rm?

When the destination format cannot exactly represent the source value, rm or dynamic frm selects the rounding direction.

How is fcvt.s.d different from integer FCVT forms?

In this form, both rd and rs1 are FP registers; W/WU/L/LU forms convert between integer and FP registers.