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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [softfloat/] [softfloat.h] - Blame information for rev 308

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
=============================================================================*/
32
 
33
/*----------------------------------------------------------------------------
34
| The macro `FLOATX80' must be defined to enable the extended double-precision
35
| floating-point format `floatx80'.  If this macro is not defined, the
36
| `floatx80' type will not be defined, and none of the functions that either
37
| input or output the `floatx80' type will be defined.  The same applies to
38
| the `FLOAT128' macro and the quadruple-precision format `float128'.
39
*----------------------------------------------------------------------------*/
40
// OR1K's floating point currently only needs to simulate 32-bit floating point
41
// ops, so even the 64-bit stuff is overkill, but could be handy in future...
42
//#define FLOATX80
43
//#define FLOAT128
44
 
45
/*----------------------------------------------------------------------------
46
| Software IEC/IEEE floating-point types.
47
*----------------------------------------------------------------------------*/
48
typedef unsigned int float32;
49
typedef unsigned long long float64;
50
#ifdef FLOATX80
51
typedef struct {
52
    unsigned long long low;
53
    unsigned short high;
54
} floatx80;
55
#endif
56
#ifdef FLOAT128
57
typedef struct {
58
    unsigned long long low, high;
59
} float128;
60
#endif
61
 
62
/*----------------------------------------------------------------------------
63
| Software IEC/IEEE floating-point underflow tininess-detection mode.
64
*----------------------------------------------------------------------------*/
65
extern signed char float_detect_tininess;
66
enum {
67
    float_tininess_after_rounding  = 0,
68
    float_tininess_before_rounding = 1
69
};
70
 
71
/*----------------------------------------------------------------------------
72
| Software IEC/IEEE floating-point rounding mode.
73
*----------------------------------------------------------------------------*/
74
extern signed char float_rounding_mode;
75
enum {
76
    float_round_nearest_even = 0,
77
    float_round_down         = 1,
78
    float_round_up           = 2,
79
    float_round_to_zero      = 3
80
};
81
 
82
/*----------------------------------------------------------------------------
83
| Software IEC/IEEE floating-point exception flags.
84
*----------------------------------------------------------------------------*/
85
extern signed char float_exception_flags;
86
enum {
87
    float_flag_invalid   =  1,
88
    float_flag_divbyzero =  4,
89
    float_flag_overflow  =  8,
90
    float_flag_underflow = 16,
91
    float_flag_inexact   = 32
92
};
93
 
94
/*----------------------------------------------------------------------------
95
| Routine to raise any or all of the software IEC/IEEE floating-point
96
| exception flags.
97
*----------------------------------------------------------------------------*/
98
void float_raise( signed char );
99
 
100
/*----------------------------------------------------------------------------
101
| Software IEC/IEEE integer-to-floating-point conversion routines.
102
*----------------------------------------------------------------------------*/
103
float32 int32_to_float32( int );
104
float64 int32_to_float64( int );
105
#ifdef FLOATX80
106
floatx80 int32_to_floatx80( int );
107
#endif
108
#ifdef FLOAT128
109
float128 int32_to_float128( int );
110
#endif
111
float32 int64_to_float32( long long );
112
float64 int64_to_float64( long long );
113
#ifdef FLOATX80
114
floatx80 int64_to_floatx80( long long );
115
#endif
116
#ifdef FLOAT128
117
float128 int64_to_float128( long long );
118
#endif
119
 
120
/*----------------------------------------------------------------------------
121
| Software IEC/IEEE single-precision conversion routines.
122
*----------------------------------------------------------------------------*/
123
int float32_to_int32( float32 );
124
int float32_to_int32_round_to_zero( float32 );
125
long long float32_to_int64( float32 );
126
long long float32_to_int64_round_to_zero( float32 );
127
float64 float32_to_float64( float32 );
128
#ifdef FLOATX80
129
floatx80 float32_to_floatx80( float32 );
130
#endif
131
#ifdef FLOAT128
132
float128 float32_to_float128( float32 );
133
#endif
134
 
135
/*----------------------------------------------------------------------------
136
| Software IEC/IEEE single-precision operations.
137
*----------------------------------------------------------------------------*/
138
float32 float32_round_to_int( float32 );
139
float32 float32_add( float32, float32 );
140
float32 float32_sub( float32, float32 );
141
float32 float32_mul( float32, float32 );
142
float32 float32_div( float32, float32 );
143
float32 float32_rem( float32, float32 );
144
float32 float32_sqrt( float32 );
145
char float32_eq( float32, float32 );
146
char float32_le( float32, float32 );
147
char float32_lt( float32, float32 );
148
char float32_eq_signaling( float32, float32 );
149
char float32_le_quiet( float32, float32 );
150
char float32_lt_quiet( float32, float32 );
151
char float32_is_signaling_nan( float32 );
152
char float32_is_nan( float32 );
153
 
154
/*----------------------------------------------------------------------------
155
| Software IEC/IEEE double-precision conversion routines.
156
*----------------------------------------------------------------------------*/
157
int float64_to_int32( float64 );
158
int float64_to_int32_round_to_zero( float64 );
159
long long float64_to_int64( float64 );
160
long long float64_to_int64_round_to_zero( float64 );
161
float32 float64_to_float32( float64 );
162
#ifdef FLOATX80
163
floatx80 float64_to_floatx80( float64 );
164
#endif
165
#ifdef FLOAT128
166
float128 float64_to_float128( float64 );
167
#endif
168
 
169
/*----------------------------------------------------------------------------
170
| Software IEC/IEEE double-precision operations.
171
*----------------------------------------------------------------------------*/
172
float64 float64_round_to_int( float64 );
173
float64 float64_add( float64, float64 );
174
float64 float64_sub( float64, float64 );
175
float64 float64_mul( float64, float64 );
176
float64 float64_div( float64, float64 );
177
float64 float64_rem( float64, float64 );
178
float64 float64_sqrt( float64 );
179
char float64_eq( float64, float64 );
180
char float64_le( float64, float64 );
181
char float64_lt( float64, float64 );
182
char float64_eq_signaling( float64, float64 );
183
char float64_le_quiet( float64, float64 );
184
char float64_lt_quiet( float64, float64 );
185
char float64_is_signaling_nan( float64 );
186
 
187
#ifdef FLOATX80
188
 
189
/*----------------------------------------------------------------------------
190
| Software IEC/IEEE extended double-precision conversion routines.
191
*----------------------------------------------------------------------------*/
192
int floatx80_to_int32( floatx80 );
193
int floatx80_to_int32_round_to_zero( floatx80 );
194
long long floatx80_to_int64( floatx80 );
195
long long floatx80_to_int64_round_to_zero( floatx80 );
196
float32 floatx80_to_float32( floatx80 );
197
float64 floatx80_to_float64( floatx80 );
198
#ifdef FLOAT128
199
float128 floatx80_to_float128( floatx80 );
200
#endif
201
 
202
/*----------------------------------------------------------------------------
203
| Software IEC/IEEE extended double-precision rounding precision.  Valid
204
| values are 32, 64, and 80.
205
*----------------------------------------------------------------------------*/
206
extern signed char floatx80_rounding_precision;
207
 
208
/*----------------------------------------------------------------------------
209
| Software IEC/IEEE extended double-precision operations.
210
*----------------------------------------------------------------------------*/
211
floatx80 floatx80_round_to_int( floatx80 );
212
floatx80 floatx80_add( floatx80, floatx80 );
213
floatx80 floatx80_sub( floatx80, floatx80 );
214
floatx80 floatx80_mul( floatx80, floatx80 );
215
floatx80 floatx80_div( floatx80, floatx80 );
216
floatx80 floatx80_rem( floatx80, floatx80 );
217
floatx80 floatx80_sqrt( floatx80 );
218
char floatx80_eq( floatx80, floatx80 );
219
char floatx80_le( floatx80, floatx80 );
220
char floatx80_lt( floatx80, floatx80 );
221
char floatx80_eq_signaling( floatx80, floatx80 );
222
char floatx80_le_quiet( floatx80, floatx80 );
223
char floatx80_lt_quiet( floatx80, floatx80 );
224
char floatx80_is_signaling_nan( floatx80 );
225
 
226
#endif
227
 
228
#ifdef FLOAT128
229
 
230
/*----------------------------------------------------------------------------
231
| Software IEC/IEEE quadruple-precision conversion routines.
232
*----------------------------------------------------------------------------*/
233
int float128_to_int32( float128 );
234
int float128_to_int32_round_to_zero( float128 );
235
long long float128_to_int64( float128 );
236
long long float128_to_int64_round_to_zero( float128 );
237
float32 float128_to_float32( float128 );
238
float64 float128_to_float64( float128 );
239
#ifdef FLOATX80
240
floatx80 float128_to_floatx80( float128 );
241
#endif
242
 
243
/*----------------------------------------------------------------------------
244
| Software IEC/IEEE quadruple-precision operations.
245
*----------------------------------------------------------------------------*/
246
float128 float128_round_to_int( float128 );
247
float128 float128_add( float128, float128 );
248
float128 float128_sub( float128, float128 );
249
float128 float128_mul( float128, float128 );
250
float128 float128_div( float128, float128 );
251
float128 float128_rem( float128, float128 );
252
float128 float128_sqrt( float128 );
253
char float128_eq( float128, float128 );
254
char float128_le( float128, float128 );
255
char float128_lt( float128, float128 );
256
char float128_eq_signaling( float128, float128 );
257
char float128_le_quiet( float128, float128 );
258
char float128_lt_quiet( float128, float128 );
259
char float128_is_signaling_nan( float128 );
260
 
261
#endif
262
 

powered by: WebSVN 2.1.0

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