fcvt.s.h
Convert half-precision float to a single-precision float
Converts a half-precision number in floating-point register fs1 into a single-precision floating-point number in floating-point register fd.
fcvt.s.h will never round, and so the 'rm' field is effectively ignored.
Decode Variables
Bits<5> fs1 = $encoding[19:15];
Bits<3> rm = $encoding[14:12];
Bits<5> fd = $encoding[11:7];
Execution
check_f_ok($encoding);
Bits<16> hp_value = F[fs1][15:0];
Bits<1> sign = hp_value[15];
Bits<5> exp = hp_value[14:10];
Bits<10> frac = hp_value[9:0];
Bits<32> sp_value = 0;
if (exp == 0x1F) {
if (frac != 0) {
if ((hp_value & 0x0200) == 0) {
set_fp_flag(FpFlag::NV);
}
sp_value = SP_CANONICAL_NAN;
} else {
sp_value = packToF32UI(sign, 0xFF, 0);
}
} else if (exp == 0) {
if (frac == 0) {
sp_value = packToF32UI(sign, 0, 0);
} else {
Bits<16> frac16 = frac;
Bits<8> shift_dist = count_leading_zeros(16, frac16) - 5;
Bits<32> norm_frac = frac16 << shift_dist) & 0x3FF); sp_value = packToF32UI(sign, 0x71 - shift_dist, norm_frac << 13); } } else { Bits<8> sp_exp = exp; Bits<32> frac32 = frac; sp_value = packToF32UI(sign, sp_exp + 0x70, frac32 << 13); } if (implemented?(ExtensionName::D {
F[fd] = nan_box(32, 64, sp_value);
} else {
F[fd] = sp_value;
}
mark_f_state_dirty();