Webcentive RISC-V Reference

flt.s

Floating-Point Less Than Single-Precision

Extension
F
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
flt.s xd, fs1, fs2
Length
32-bit

Encoding

312726252420191514121176210
1010000rs2rs1001rd1010011

Match 0xa0001053, mask 0xfe00707f. Source: flt.s rd rs1 rs2 31..27=0x14 14..12=1 26..25=0 6..2=0x14 1..0=3 in riscv-opcodes/extensions/rv_f.

FieldBitsriscv-opcodes name
rs224:20rs2
rs119:15rs1
rd11:7rd

Description

The flt.s instruction writes 1 to xd if fs1 is less than fs2, and 0 otherwise. If either operand is NaN, the result is 0 (not equal). If either operand is a NaN (signaling or quiet), the invalid flag is set.

Description from riscv-unified-db, reformatted.

Operation

check_f_ok($encoding);

Bits<32> sp_value_a = F[fs1][31:0];
Bits<32> sp_value_b = F[fs2][31:0];
Bits<1> sign_a = sp_value_a[31];
Bits<1> sign_b = sp_value_b[31];

if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
  set_fp_flag(FpFlag::NV);
  X[xd] = 0;
} else {
  if (sign_a != sign_b) {
    X[xd] = (
      (sign_a == 1) # a is neg and b is pos
      && ((sp_value_a[30:0] | sp_value_b[30:0]) != 0) # a and b are not both zero
     ) ? 1 : 0;
  } else {
    X[xd] = (
      (sp_value_a != sp_value_b) # a and b are not equal
      && ((sign_a ^ ((sp_value_a < sp_value_b) ? 1 : 0)) != 0)# a < b
    ) ? 1 : 0;
  }
}

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages