OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [testsuite/] [test-code-or1k/] [testfloat/] [softfloat.h] - Blame information for rev 808

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 234 jeremybenn
 
2
/*============================================================================
3
 
4
This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
5
Package, Release 2b.
6
 
7
Written by John R. Hauser.  This work was made possible in part by the
8
International Computer Science Institute, located at Suite 600, 1947 Center
9
Street, Berkeley, California 94704.  Funding was partially provided by the
10
National Science Foundation under grant MIP-9311980.  The original version
11
of this code was written as part of a project to build a fixed-point vector
12
processor in collaboration with the University of California at Berkeley,
13
overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14
is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15
arithmetic/SoftFloat.html'.
16
 
17
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18
been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19
RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20
AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21
COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22
EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23
INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
24
OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
 
26
Derivative works are acceptable, even for commercial purposes, so long as
27
(1) the source code for the derivative work includes prominent notice that
28
the work is derivative, and (2) the source code includes prominent notice with
29
these four paragraphs for those parts of this code that are retained.
30
 
31
Modified for use with or1ksim's testsuite.
32
 
33
Contributor Julius Baxter <julius.baxter@orsoc.se>
34
 
35
=============================================================================*/
36
 
37
/*----------------------------------------------------------------------------
38
| The macro `FLOATX80' must be defined to enable the extended double-precision
39
| floating-point format `floatx80'.  If this macro is not defined, the
40
| `floatx80' type will not be defined, and none of the functions that either
41
| input or output the `floatx80' type will be defined.  The same applies to
42
| the `FLOAT128' macro and the quadruple-precision format `float128'.
43
*----------------------------------------------------------------------------*/
44
                                //#define FLOATX80
45
                                //#define FLOAT128
46
 
47
/*----------------------------------------------------------------------------
48
| Software IEC/IEEE floating-point types.
49
*----------------------------------------------------------------------------*/
50
typedef unsigned int float32;
51
typedef unsigned long long float64;
52
#ifdef FLOATX80
53
typedef struct {
54
    unsigned long long low;
55
    unsigned short high;
56
} floatx80;
57
#endif
58
#ifdef FLOAT128
59
typedef struct {
60
    unsigned long long low, high;
61
} float128;
62
#endif
63
 
64
/*----------------------------------------------------------------------------
65
| Software IEC/IEEE floating-point underflow tininess-detection mode.
66
*----------------------------------------------------------------------------*/
67
extern signed char float_detect_tininess;
68
enum {
69
    float_tininess_after_rounding  = 0,
70
    float_tininess_before_rounding = 1
71
};
72
 
73
/*----------------------------------------------------------------------------
74
| Software IEC/IEEE floating-point rounding mode.
75
*----------------------------------------------------------------------------*/
76
extern signed char float_rounding_mode;
77
enum {
78
    float_round_nearest_even = 0,
79
    float_round_down         = 1,
80
    float_round_up           = 2,
81
    float_round_to_zero      = 3
82
};
83
 
84
/*----------------------------------------------------------------------------
85
| Software IEC/IEEE floating-point exception flags.
86
*----------------------------------------------------------------------------*/
87
extern signed char float_exception_flags;
88
enum {
89
    float_flag_invalid   =  1,
90
    float_flag_divbyzero =  4,
91
    float_flag_overflow  =  8,
92
    float_flag_underflow = 16,
93
    float_flag_inexact   = 32
94
};
95
 
96
/*----------------------------------------------------------------------------
97
| Routine to raise any or all of the software IEC/IEEE floating-point
98
| exception flags.
99
*----------------------------------------------------------------------------*/
100
void float_raise( signed char );
101
 
102
/*----------------------------------------------------------------------------
103
| Software IEC/IEEE integer-to-floating-point conversion routines.
104
*----------------------------------------------------------------------------*/
105
float32 int32_to_float32( int );
106
float64 int32_to_float64( int );
107
#ifdef FLOATX80
108
floatx80 int32_to_floatx80( int );
109
#endif
110
#ifdef FLOAT128
111
float128 int32_to_float128( int );
112
#endif
113
float32 int64_to_float32( long long );
114
float64 int64_to_float64( long long );
115
#ifdef FLOATX80
116
floatx80 int64_to_floatx80( long long );
117
#endif
118
#ifdef FLOAT128
119
float128 int64_to_float128( long long );
120
#endif
121
 
122
/*----------------------------------------------------------------------------
123
| Software IEC/IEEE single-precision conversion routines.
124
*----------------------------------------------------------------------------*/
125
int float32_to_int32( float32 );
126
int float32_to_int32_round_to_zero( float32 );
127
long long float32_to_int64( float32 );
128
long long float32_to_int64_round_to_zero( float32 );
129
float64 float32_to_float64( float32 );
130
#ifdef FLOATX80
131
floatx80 float32_to_floatx80( float32 );
132
#endif
133
#ifdef FLOAT128
134
float128 float32_to_float128( float32 );
135
#endif
136
 
137
/*----------------------------------------------------------------------------
138
| Software IEC/IEEE single-precision operations.
139
*----------------------------------------------------------------------------*/
140
float32 float32_round_to_int( float32 );
141
float32 float32_add( float32, float32 );
142
float32 float32_sub( float32, float32 );
143
float32 float32_mul( float32, float32 );
144
float32 float32_div( float32, float32 );
145
float32 float32_rem( float32, float32 );
146
float32 float32_sqrt( float32 );
147
char float32_eq( float32, float32 );
148
char float32_le( float32, float32 );
149
char float32_lt( float32, float32 );
150
char float32_eq_signaling( float32, float32 );
151
char float32_le_quiet( float32, float32 );
152
char float32_lt_quiet( float32, float32 );
153
char float32_is_signaling_nan( float32 );
154
 
155
/*----------------------------------------------------------------------------
156
| Software IEC/IEEE double-precision conversion routines.
157
*----------------------------------------------------------------------------*/
158
int float64_to_int32( float64 );
159
int float64_to_int32_round_to_zero( float64 );
160
long long float64_to_int64( float64 );
161
long long float64_to_int64_round_to_zero( float64 );
162
float32 float64_to_float32( float64 );
163
#ifdef FLOATX80
164
floatx80 float64_to_floatx80( float64 );
165
#endif
166
#ifdef FLOAT128
167
float128 float64_to_float128( float64 );
168
#endif
169
 
170
/*----------------------------------------------------------------------------
171
| Software IEC/IEEE double-precision operations.
172
*----------------------------------------------------------------------------*/
173
float64 float64_round_to_int( float64 );
174
float64 float64_add( float64, float64 );
175
float64 float64_sub( float64, float64 );
176
float64 float64_mul( float64, float64 );
177
float64 float64_div( float64, float64 );
178
float64 float64_rem( float64, float64 );
179
float64 float64_sqrt( float64 );
180
char float64_eq( float64, float64 );
181
char float64_le( float64, float64 );
182
char float64_lt( float64, float64 );
183
char float64_eq_signaling( float64, float64 );
184
char float64_le_quiet( float64, float64 );
185
char float64_lt_quiet( float64, float64 );
186
char float64_is_signaling_nan( float64 );
187
 
188
#ifdef FLOATX80
189
 
190
/*----------------------------------------------------------------------------
191
| Software IEC/IEEE extended double-precision conversion routines.
192
*----------------------------------------------------------------------------*/
193
int floatx80_to_int32( floatx80 );
194
int floatx80_to_int32_round_to_zero( floatx80 );
195
long long floatx80_to_int64( floatx80 );
196
long long floatx80_to_int64_round_to_zero( floatx80 );
197
float32 floatx80_to_float32( floatx80 );
198
float64 floatx80_to_float64( floatx80 );
199
#ifdef FLOAT128
200
float128 floatx80_to_float128( floatx80 );
201
#endif
202
 
203
/*----------------------------------------------------------------------------
204
| Software IEC/IEEE extended double-precision rounding precision.  Valid
205
| values are 32, 64, and 80.
206
*----------------------------------------------------------------------------*/
207
extern signed char floatx80_rounding_precision;
208
 
209
/*----------------------------------------------------------------------------
210
| Software IEC/IEEE extended double-precision operations.
211
*----------------------------------------------------------------------------*/
212
floatx80 floatx80_round_to_int( floatx80 );
213
floatx80 floatx80_add( floatx80, floatx80 );
214
floatx80 floatx80_sub( floatx80, floatx80 );
215
floatx80 floatx80_mul( floatx80, floatx80 );
216
floatx80 floatx80_div( floatx80, floatx80 );
217
floatx80 floatx80_rem( floatx80, floatx80 );
218
floatx80 floatx80_sqrt( floatx80 );
219
char floatx80_eq( floatx80, floatx80 );
220
char floatx80_le( floatx80, floatx80 );
221
char floatx80_lt( floatx80, floatx80 );
222
char floatx80_eq_signaling( floatx80, floatx80 );
223
char floatx80_le_quiet( floatx80, floatx80 );
224
char floatx80_lt_quiet( floatx80, floatx80 );
225
char floatx80_is_signaling_nan( floatx80 );
226
 
227
#endif
228
 
229
#ifdef FLOAT128
230
 
231
/*----------------------------------------------------------------------------
232
| Software IEC/IEEE quadruple-precision conversion routines.
233
*----------------------------------------------------------------------------*/
234
int float128_to_int32( float128 );
235
int float128_to_int32_round_to_zero( float128 );
236
long long float128_to_int64( float128 );
237
long long float128_to_int64_round_to_zero( float128 );
238
float32 float128_to_float32( float128 );
239
float64 float128_to_float64( float128 );
240
#ifdef FLOATX80
241
floatx80 float128_to_floatx80( float128 );
242
#endif
243
 
244
/*----------------------------------------------------------------------------
245
| Software IEC/IEEE quadruple-precision operations.
246
*----------------------------------------------------------------------------*/
247
float128 float128_round_to_int( float128 );
248
float128 float128_add( float128, float128 );
249
float128 float128_sub( float128, float128 );
250
float128 float128_mul( float128, float128 );
251
float128 float128_div( float128, float128 );
252
float128 float128_rem( float128, float128 );
253
float128 float128_sqrt( float128 );
254
char float128_eq( float128, float128 );
255
char float128_le( float128, float128 );
256
char float128_lt( float128, float128 );
257
char float128_eq_signaling( float128, float128 );
258
char float128_le_quiet( float128, float128 );
259
char float128_lt_quiet( float128, float128 );
260
char float128_is_signaling_nan( float128 );
261
 
262
#endif
263
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.