File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 33$schema : " inst_schema.json#"
44kind : instruction
55name : fcvt.s.wu
6- long_name : No synopsis available.
6+ long_name : Convert unsigned 32-bit integer to single-precision float
77description : |
8- No description available.
8+ Converts a 32-bit unsigned integer in integer register _rs1_ into a floating-point number in
9+ floating-point register _fd_.
10+
11+ All floating-point to integer and integer to floating-point conversion instructions round
12+ according to the _rm_ field.
13+ A floating-point register can be initialized to floating-point positive zero using
14+ `fcvt.s.w rd, x0`, which will never set any exception flags.
15+
16+ All floating-point conversion instructions set the Inexact exception flag if the rounded
17+ result differs from the operand value and the Invalid exception flag is not set.
918definedBy : F
1019assembly : fd, xs1, rm
1120encoding :
@@ -24,7 +33,10 @@ access:
2433 vu : always
2534data_independent_timing : true
2635operation() : |
27-
36+ check_f_ok($encoding);
37+ RoundingMode rounding_mode = rm_to_mode(rm, $encoding);
38+ X[fd] = ui32_to_f32(X[rs1], rounding_mode);
39+ mark_f_state_dirty();
2840sail() : |
2941 {
3042 assert(sizeof(xlen) >= 64);
Original file line number Diff line number Diff line change @@ -901,3 +901,23 @@ function i32_to_f32 {
901901 return softfloat_normRoundPackToF32(sign, 0x9C, magnitude_of_A, mode);
902902 }
903903}
904+
905+ function ui32_to_f32 {
906+ returns U32
907+ arguments
908+ U32 a,
909+ RoundingMode mode
910+ description {
911+ Converts 32-bit unsigned integer to 32-bit floating point
912+ }
913+ body {
914+ # sign of integer, it is 1 when negative
915+ if (a == 0) {
916+ return a;
917+ }
918+ if (a[31] == 1) {
919+ return softfloat_roundPackToF32(0, 0x9D, a>>1 | (a & 1), mode);
920+ } else {
921+ return softfloat_normRoundPackToF32(0, 0x9C, a, mode);
922+ }
923+ }
You can’t perform that action at this time.
0 commit comments