Skip to content

Commit 0a28964

Browse files
committed
Added previously created operations description by dhower
Signed-off-by: Afonso Oliveira <[email protected]>
1 parent 1bae44e commit 0a28964

File tree

12 files changed

+180
-3
lines changed

12 files changed

+180
-3
lines changed

arch/inst/F/fclass.s.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,29 @@ fclass.s:
4545
vu: always
4646
data_independent_timing: false
4747
operation(): |
48-
48+
check_f_ok();
49+
50+
Bits<32> sp_value = f[fs1][31:0];
51+
52+
if (is_sp_neg_inf?(sp_value)) {
53+
X[rd] = 1 << 0;
54+
} else if (is_sp_neg_norm?(sp_value)) {
55+
X[rd] = 1 << 1;
56+
} else if (is_sp_neg_subnorm?(sp_value)) {
57+
X[rd] = 1 << 2;
58+
} else if (is_sp_neg_zero?(sp_value)) {
59+
X[rd] = 1 << 3;
60+
} else if (is_sp_pos_zero?(sp_value)) {
61+
X[rd] = 1 << 4;
62+
} else if (is_sp_pos_subnorm?(sp_value)) {
63+
X[rd] = 1 << 5;
64+
} else if (is_sp_pos_norm?(sp_value)) {
65+
X[rd] = 1 << 6;
66+
} else if (is_sp_pos_inf?(sp_value)) {
67+
X[rd] = 1 << 7;
68+
} else if (is_sp_signaling_nan?(sp_value)) {
69+
X[rd] = 1 << 8;
70+
} else {
71+
assert(is_sp_quiet_nan?(sp_value), "Unexpected SP value");
72+
X[rd] = 1 << 9;
73+
}

arch/inst/F/fcvt.s.w.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,20 @@ fcvt.s.w:
3131
vu: always
3232
data_independent_timing: false
3333
operation(): |
34+
check_f_ok();
35+
36+
Bits<32> int_value = X[rs1];
37+
38+
Bits<1> sign = int_value[31];
39+
40+
RoundingMode rouding_mode = rm_to_mode(rm, $encoding);
41+
42+
if (! (int_value & 32'h7fff_ffff)) {
43+
X[fd] = (sign == 1) ? packToF32UI(1, 0x9E, 0) : 0;
44+
} else {
45+
Bits<32> absA = (sign == 1) ? -int_value : int_value;
46+
X[fd] = softfloat_normRoundPackToF32( sign, 0x9C, absA, rounding_mode );
47+
}
48+
49+
mark_f_state_dirty();
3450
35-

arch/inst/F/fcvt.w.s.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,30 @@ fcvt.w.s:
5151
vu: always
5252
data_independent_timing: true
5353
operation(): |
54-
54+
check_f_ok();
55+
56+
Bits<32> sp_value = f[fs1][31:0];
57+
58+
Bits<1> sign = sp_value[31];
59+
Bits<8> exp = sp_value[30:23];
60+
Bits<23> sig = sp_value[22:0];
61+
62+
RoundingMode rounding_mode = rm_to_mode(rm, $encoding);
63+
64+
if ( (exp == 0xff) && (sig != 0)) {
65+
sign = 0;
66+
set_fp_flag(FpFlag::NV);
67+
X[rd] = SP_CANONICAL_NAN;
68+
} else {
69+
if (exp != 0) {
70+
sig = sig | 0x00800000;
71+
}
72+
Bits<64> sig64 = sig << 32;
73+
Bits<16> shift_dist = 0xAA - exp;
74+
if (0 < shift_dist) {
75+
sig64 = softfloat_shiftRightJam64(sig64, shift_dist );
76+
}
77+
X[rd] = softfloat_roundToI32( sign, sig64, rounding_mode );
78+
}
79+
80+

arch/inst/F/feq.s.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,19 @@ feq.s:
2727
vu: always
2828
data_independent_timing: true
2929
operation(): |
30+
check_f_ok();
31+
32+
Bits<32> sp_value_a = f[fs1][31:0];
33+
Bits<32> sp_value_b = f[fs1][31:0];
34+
35+
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
36+
if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
37+
set_fp_flag(FpFlag::NV);
38+
}
39+
X[rd] = 0;
40+
} else {
41+
X[rd] = (
42+
(sp_value_a == sp_value_b)
43+
|| ((sp_value_a | sp_value_b)[30:0] == 0) # pos 0 is equal to neg zero
44+
) ? 1 : 0;
45+
}

arch/inst/F/fle.s.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,19 @@ fle.s:
2828
vu: always
2929
data_independent_timing: true
3030
operation(): |
31+
check_f_ok();
32+
33+
Bits<32> sp_value_a = f[fs1][31:0];
34+
Bits<32> sp_value_b = f[fs1][31:0];
35+
36+
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
37+
if (is_sp_signaling_nan?(sp_value_a) || is_sp_signaling_nan?(sp_value_b)) {
38+
set_fp_flag(FpFlag::NV);
39+
}
40+
X[rd] = 0;
41+
} else {
42+
X[rd] = (
43+
(sp_value_a == sp_value_b)
44+
|| ((sp_value_a | sp_value_b)[30:0] == 0) # pos 0 is equal to neg zero
45+
) ? 1 : 0;
46+
}

arch/inst/F/flt.s.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,23 @@ flt.s:
2626
vu: always
2727
data_independent_timing: true
2828
operation(): |
29+
check_f_ok();
30+
31+
Bits<32> sp_value_a = f[fs1][31:0];
32+
Bits<32> sp_value_b = f[fs1][31:0];
33+
34+
if (is_sp_nan?(sp_value_a) || is_sp_nan?(sp_value_b)) {
35+
set_fp_flag(FpFlag::NV);
36+
X[rd] = 0;
37+
} else {
38+
Boolean sign_a = sp_value_a[31] == 1;
39+
Boolean sign_b = sp_value_b[31] == 1;
40+
41+
Boolean a_lt_b =
42+
(sign_a != sign_b)
43+
? (sign_a && ((sp_value_a[30:0] | sp_value_b[30:0]) != 0)) # opposite sign, a is negative. a is less than b as long as both are not zero
44+
: ((sp_value_a != sp_value_b) && (sign_a != (sp_value_a < sp_value_b)));
45+
X[rd] = a_lt_b ? 1 : 0;
46+
}
2947
3048

arch/inst/F/flw.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,16 @@ flw:
2525
vu: always
2626
data_independent_timing: true
2727
operation(): |
28+
check_f_ok();
29+
30+
XReg virtual_address = X[rs1] + $signed(imm);
31+
32+
Bits<32> sp_value = read_memory<32>(virtual_address);
33+
34+
if (implemented?(ExtensionName::D)) {
35+
f[fd] = nan_box(sp_value);
36+
} else {
37+
f[fd] = sp_value;
38+
}
39+
40+
mark_f_state_dirty();

arch/inst/F/fmv.w.x.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,14 @@ fmv.w.x:
2323
vu: always
2424
data_independent_timing: true
2525
operation(): |
26+
check_f_ok();
2627
28+
Bits<32> sp_value = X[rs1][31:0];
29+
30+
if (implemented?(ExtensionName::D)) {
31+
f[fd] = nan_box(sp_value);
32+
} else {
33+
f[fd] = sp_value;
34+
}
35+
36+
mark_f_state_dirty();

arch/inst/F/fsgnj.s.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ fsgnj.s:
2525
vu: always
2626
data_independent_timing: true
2727
operation(): |
28+
check_f_ok();
29+
30+
Bits<32> sp_value = {f[fs2][31], f[fs1][30:0]};
31+
32+
if (implemented?(ExtensionName::D)) {
33+
f[fd] = nan_box(sp_value);
34+
} else {
35+
f[fd] = sp_value;
36+
}
37+
38+
mark_f_state_dirty();

arch/inst/F/fsgnjn.s.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,14 @@ fsgnjn.s:
2424
vu: always
2525
data_independent_timing: true
2626
operation(): |
27+
check_f_ok();
28+
29+
Bits<32> sp_value = {~f[fs2][31], f[fs1][30:0]};
30+
31+
if (implemented?(ExtensionName::D)) {
32+
f[fd] = nan_box(sp_value);
33+
} else {
34+
f[fd] = sp_value;
35+
}
36+
37+
mark_f_state_dirty();

0 commit comments

Comments
 (0)