feq.s
Floating-Point Equal Single-Precision
- Extension
- F
- XLEN
- RV32 and RV64
- Assembly (riscv-unified-db)
feq.s xd, fs1, fs2- Length
- 32-bit
Encoding
| 3127 | 2625 | 2420 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 10100 | 00 | rs2 | rs1 | 010 | rd | 10100 | 11 | ||||||||||||||||||||||||
Match 0xa0002053, mask 0xfe00707f. Source: feq.s rd rs1 rs2 31..27=0x14 14..12=2 26..25=0 6..2=0x14 1..0=3 in riscv-opcodes/extensions/rv_f.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs2 | 24:20 | rs2 |
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
The feq.s instruction writes 1 to xd if fs1 and fs2 are equal, and 0 otherwise.
If either operand is NaN, the result is 0 (not equal). If either operand is a signaling NaN,
the invalid flag is set. Positive zero is considered equal to negative zero.
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];
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
set_fp_flag(FpFlag::NV);
}
X[xd] = 0;
} else {
X[xd] = (
(sp_value_a == sp_value_b)
|| ((sp_value_a | sp_value_b)[30:0] == 0) # pos 0 is equal to neg zero
) ? 1 : 0;
}Pseudocode in riscv-unified-db’s IDL, quoted unchanged.