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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [DFPPkg.sv] - Blame information for rev 75

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

Line No. Rev Author Line
1 57 robfinch
// ============================================================================
2
//        __
3 75 robfinch
//   \\__/ o\    (C) 2020-2022  Robert Finch, Waterloo
4 57 robfinch
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      DFPPkg.sv
9
//    - decimal floating point package
10
//
11
//
12
// This source file is free software: you can redistribute it and/or modify
13
// it under the terms of the GNU Lesser General Public License as published
14
// by the Free Software Foundation, either version 3 of the License, or
15
// (at your option) any later version.
16
//
17
// This source file is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
// GNU General Public License for more details.
21
//
22
// You should have received a copy of the GNU General Public License
23
// along with this program.  If not, see .
24
//
25
//      This unit takes a floating point number in an intermediate
26
// format and normalizes it. No normalization occurs
27
// for NaN's or infinities. The unit has a two cycle latency.
28
//
29
// The mantissa is assumed to start with two whole bits on
30
// the left. The remaining bits are fractional.
31
//
32
// The width of the incoming format is reduced via a generation
33
// of sticky bit in place of the low order fractional bits.
34
//
35
// On an underflowed input, the incoming exponent is assumed
36
// to be negative. A right shift is needed.
37
// ============================================================================
38
 
39
package DFPPkg;
40
 
41
`define SUPPORT_DENORMALS       1'b1
42
 
43 75 robfinch
`define QINFDIV         4'd2
44
`define QZEROZERO       4'd3
45
 
46 57 robfinch
typedef struct packed
47
{
48
        logic sign;
49
        logic [4:0] combo;
50
        logic [14:0] expc;      // exponent continuation field
51
        logic [139:0] sigc;     // significand continuation field
52
} DFP160;
53
 
54
// Packed 128 bit (storage) format
55
typedef struct packed
56
{
57
        logic sign;
58
        logic [4:0] combo;
59
        logic [11:0] expc;      // exponent continuation field
60
        logic [109:0] sigc;     // significand continuation field
61
} DFP128;
62
 
63 75 robfinch
// Packed 128 bit (storage) format
64
typedef struct packed
65
{
66
        logic sign;
67
        logic [4:0] combo;
68
        logic [9:0] expc;       // exponent continuation field
69
        logic [79:0] sigc;      // significand continuation field
70
} DFP96;
71
 
72
typedef logic [11:0] DFP96EXP;
73
typedef logic [99:0] DFP96SIG;
74
 
75 57 robfinch
typedef logic [13:0] DFP128EXP;
76
typedef logic [135:0] DFP128SIG;
77
 
78 75 robfinch
// Unpacked 96 bit format
79
typedef struct packed
80
{
81
        logic nan;
82
        logic qnan;
83
        logic snan;
84
        logic infinity;
85
        logic sign;
86
        logic [11:0] exp;
87
        logic [99:0] sig;       // significand 25 digits
88
} DFP96U;
89
 
90 57 robfinch
// Unpacked 128 bit format
91
typedef struct packed
92
{
93
        logic nan;
94
        logic qnan;
95
        logic snan;
96
        logic infinity;
97
        logic sign;
98
        logic [13:0] exp;
99
        logic [135:0] sig;      // significand 34 digits
100
} DFP128U;
101
 
102
// Normalizer output to rounding, one extra digit
103
typedef struct packed
104
{
105
        logic nan;
106
        logic qnan;
107
        logic snan;
108
        logic infinity;
109
        logic sign;
110 75 robfinch
        logic [11:0] exp;
111
        logic [103:0] sig;      // significand 26 digits
112
} DFP96UN;
113
 
114
// Normalizer output to rounding, one extra digit
115
typedef struct packed
116
{
117
        logic nan;
118
        logic qnan;
119
        logic snan;
120
        logic infinity;
121
        logic sign;
122 57 robfinch
        logic [13:0] exp;
123
        logic [139:0] sig;      // significand 35 digits
124
} DFP128UN;
125
 
126 75 robfinch
// 96-bit Double width significand, normalizer input
127
typedef struct packed
128
{
129
        logic nan;
130
        logic qnan;
131
        logic snan;
132
        logic infinity;
133
        logic sign;
134
        logic [11:0] exp;
135
        logic [207:0] sig;      // significand 50+ 1 lead, 1-trail digit
136
} DFP96UD;
137
 
138 57 robfinch
// 128-bit Double width significand, normalizer input
139
typedef struct packed
140
{
141
        logic nan;
142
        logic qnan;
143
        logic snan;
144
        logic infinity;
145
        logic sign;
146
        logic [13:0] exp;
147
        logic [279:0] sig;      // significand 68+ 1 lead, 1-trail digit
148
} DFP128UD;
149
 
150
typedef logic [9:0] DFP64EXP;
151
typedef logic [63:0] DFP64SIG;
152
 
153
typedef struct packed
154
{
155
        logic sign;
156
        logic [4:0] combo;
157
        logic [7:0] expc;               // exponent continuation field
158
        logic [49:0] sigc;      // significand continuation field
159
} DFP64;
160
 
161
typedef struct packed
162
{
163
        logic nan;
164
        logic qnan;
165
        logic snan;
166
        logic infinity;
167
        logic sign;
168
        logic [9:0] exp;
169
        logic [63:0] sig;               // significand 16 digits
170
} DFP64U;
171
 
172
typedef struct packed
173
{
174
        logic nan;
175
        logic qnan;
176
        logic snan;
177
        logic infinity;
178
        logic sign;
179
        logic [9:0] exp;
180
        logic [67:0] sig;               // significand 17 digits
181
} DFP64UN;
182
 
183
typedef struct packed
184
{
185
        logic nan;
186
        logic qnan;
187
        logic snan;
188
        logic infinity;
189
        logic sign;
190
        logic [9:0] exp;
191
        logic [127:0] sig;              // significand 32 digits
192
} DFP64UD;
193
 
194
endpackage

powered by: WebSVN 2.1.0

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