Skip to content

Commit e8db0dc

Browse files
committed
Q extension floating point support
Complete Q extension implementation including Zfa instructions Based on original work by 'LiuTaowen-Tony' in riscv#187
1 parent 8a2e0f5 commit e8db0dc

21 files changed

+2172
-93
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ else
1616
endif
1717

1818
SAIL_XLEN += riscv_xlen.sail
19-
SAIL_FLEN := riscv_flen_D.sail
19+
SAIL_FLEN := riscv_flen_Q.sail
2020
SAIL_VLEN := riscv_vlen.sail
2121

2222
# Instruction sources, depending on target
2323
SAIL_CHECK_SRCS = riscv_addr_checks_common.sail riscv_addr_checks.sail riscv_misa_ext.sail
2424
SAIL_DEFAULT_INST = riscv_insts_base.sail riscv_insts_zifencei.sail riscv_insts_aext.sail riscv_insts_zca.sail riscv_insts_mext.sail riscv_insts_zicsr.sail riscv_insts_hints.sail
2525
SAIL_DEFAULT_INST += riscv_insts_fext.sail riscv_insts_zcf.sail
2626
SAIL_DEFAULT_INST += riscv_insts_dext.sail riscv_insts_zcd.sail
27+
SAIL_DEFAULT_INST += riscv_insts_qext.sail
2728

2829
SAIL_DEFAULT_INST += riscv_insts_svinval.sail
2930

c_emulator/SoftFloat-3e/source/include/softfloat.h

+23-23
Original file line numberDiff line numberDiff line change
@@ -100,36 +100,36 @@ void softfloat_raiseFlags( uint_fast8_t );
100100
float16_t ui32_to_f16( uint32_t );
101101
float32_t ui32_to_f32( uint32_t );
102102
float64_t ui32_to_f64( uint32_t );
103+
float128_t ui32_to_f128( uint32_t );
103104
#ifdef SOFTFLOAT_FAST_INT64
104105
extFloat80_t ui32_to_extF80( uint32_t );
105-
float128_t ui32_to_f128( uint32_t );
106106
#endif
107107
void ui32_to_extF80M( uint32_t, extFloat80_t * );
108108
void ui32_to_f128M( uint32_t, float128_t * );
109109
float16_t ui64_to_f16( uint64_t );
110110
float32_t ui64_to_f32( uint64_t );
111111
float64_t ui64_to_f64( uint64_t );
112+
float128_t ui64_to_f128( uint64_t );
112113
#ifdef SOFTFLOAT_FAST_INT64
113114
extFloat80_t ui64_to_extF80( uint64_t );
114-
float128_t ui64_to_f128( uint64_t );
115115
#endif
116116
void ui64_to_extF80M( uint64_t, extFloat80_t * );
117117
void ui64_to_f128M( uint64_t, float128_t * );
118118
float16_t i32_to_f16( int32_t );
119119
float32_t i32_to_f32( int32_t );
120120
float64_t i32_to_f64( int32_t );
121+
float128_t i32_to_f128( int32_t );
121122
#ifdef SOFTFLOAT_FAST_INT64
122123
extFloat80_t i32_to_extF80( int32_t );
123-
float128_t i32_to_f128( int32_t );
124124
#endif
125125
void i32_to_extF80M( int32_t, extFloat80_t * );
126126
void i32_to_f128M( int32_t, float128_t * );
127127
float16_t i64_to_f16( int64_t );
128128
float32_t i64_to_f32( int64_t );
129129
float64_t i64_to_f64( int64_t );
130+
float128_t i64_to_f128( int64_t );
130131
#ifdef SOFTFLOAT_FAST_INT64
131132
extFloat80_t i64_to_extF80( int64_t );
132-
float128_t i64_to_f128( int64_t );
133133
#endif
134134
void i64_to_extF80M( int64_t, extFloat80_t * );
135135
void i64_to_f128M( int64_t, float128_t * );
@@ -147,9 +147,9 @@ int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
147147
int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
148148
float32_t f16_to_f32( float16_t );
149149
float64_t f16_to_f64( float16_t );
150+
float128_t f16_to_f128( float16_t );
150151
#ifdef SOFTFLOAT_FAST_INT64
151152
extFloat80_t f16_to_extF80( float16_t );
152-
float128_t f16_to_f128( float16_t );
153153
#endif
154154
void f16_to_extF80M( float16_t, extFloat80_t * );
155155
void f16_to_f128M( float16_t, float128_t * );
@@ -182,9 +182,9 @@ int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
182182
int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
183183
float16_t f32_to_f16( float32_t );
184184
float64_t f32_to_f64( float32_t );
185+
float128_t f32_to_f128( float32_t );
185186
#ifdef SOFTFLOAT_FAST_INT64
186187
extFloat80_t f32_to_extF80( float32_t );
187-
float128_t f32_to_f128( float32_t );
188188
#endif
189189
void f32_to_extF80M( float32_t, extFloat80_t * );
190190
void f32_to_f128M( float32_t, float128_t * );
@@ -217,9 +217,9 @@ int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
217217
int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
218218
float16_t f64_to_f16( float64_t );
219219
float32_t f64_to_f32( float64_t );
220+
float128_t f64_to_f128( float64_t );
220221
#ifdef SOFTFLOAT_FAST_INT64
221222
extFloat80_t f64_to_extF80( float64_t );
222-
float128_t f64_to_f128( float64_t );
223223
#endif
224224
void f64_to_extF80M( float64_t, extFloat80_t * );
225225
void f64_to_f128M( float64_t, float128_t * );
@@ -309,34 +309,34 @@ bool extF80M_isSignalingNaN( const extFloat80_t * );
309309
| 128-bit (quadruple-precision) floating-point operations.
310310
*----------------------------------------------------------------------------*/
311311
#ifdef SOFTFLOAT_FAST_INT64
312-
uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
313-
uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
314-
int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
315-
int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
312+
extFloat80_t f128_to_extF80( float128_t );
313+
#endif
316314
uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
317315
uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
318316
int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
319317
int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
320318
float16_t f128_to_f16( float128_t );
319+
float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
320+
float128_t f128_rem( float128_t, float128_t );
321+
bool f128_eq_signaling( float128_t, float128_t );
322+
bool f128_le_quiet( float128_t, float128_t );
323+
bool f128_lt_quiet( float128_t, float128_t );
324+
bool f128_isSignalingNaN( float128_t );
325+
bool f128_eq( float128_t, float128_t );
326+
bool f128_le( float128_t, float128_t );
327+
bool f128_lt( float128_t, float128_t );
328+
float128_t f128_sqrt( float128_t );
321329
float32_t f128_to_f32( float128_t );
322330
float64_t f128_to_f64( float128_t );
323-
extFloat80_t f128_to_extF80( float128_t );
324-
float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
331+
uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
332+
uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
333+
int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
334+
int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
325335
float128_t f128_add( float128_t, float128_t );
326336
float128_t f128_sub( float128_t, float128_t );
327337
float128_t f128_mul( float128_t, float128_t );
328338
float128_t f128_mulAdd( float128_t, float128_t, float128_t );
329339
float128_t f128_div( float128_t, float128_t );
330-
float128_t f128_rem( float128_t, float128_t );
331-
float128_t f128_sqrt( float128_t );
332-
bool f128_eq( float128_t, float128_t );
333-
bool f128_le( float128_t, float128_t );
334-
bool f128_lt( float128_t, float128_t );
335-
bool f128_eq_signaling( float128_t, float128_t );
336-
bool f128_le_quiet( float128_t, float128_t );
337-
bool f128_lt_quiet( float128_t, float128_t );
338-
bool f128_isSignalingNaN( float128_t );
339-
#endif
340340
uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
341341
uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
342342
int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );

c_emulator/riscv_sail.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern mach_bits zmstatus;
6464
extern mach_bits zmepc, zmtval;
6565
extern mach_bits zsepc, zstval;
6666

67-
extern mach_bits zfloat_result, zfloat_fflags;
67+
extern mach_bits zfloat_fflags, zfloat_result, zfloat_result_high;
6868

6969
struct zMcause {
7070
mach_bits zMcause_chunk_0;

0 commit comments

Comments
 (0)