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

Subversion Repositories ft816float

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

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

Line No. Rev Author Line
1 57 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2020-2021  Robert Finch, Waterloo
4
//    \  __ /    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
typedef struct packed
44
{
45
        logic sign;
46
        logic [4:0] combo;
47
        logic [14:0] expc;      // exponent continuation field
48
        logic [139:0] sigc;     // significand continuation field
49
} DFP160;
50
 
51
// Packed 128 bit (storage) format
52
typedef struct packed
53
{
54
        logic sign;
55
        logic [4:0] combo;
56
        logic [11:0] expc;      // exponent continuation field
57
        logic [109:0] sigc;     // significand continuation field
58
} DFP128;
59
 
60
typedef logic [13:0] DFP128EXP;
61
typedef logic [135:0] DFP128SIG;
62
 
63
// Unpacked 128 bit format
64
typedef struct packed
65
{
66
        logic nan;
67
        logic qnan;
68
        logic snan;
69
        logic infinity;
70
        logic sign;
71
        logic [13:0] exp;
72
        logic [135:0] sig;      // significand 34 digits
73
} DFP128U;
74
 
75
// Normalizer output to rounding, one extra digit
76
typedef struct packed
77
{
78
        logic nan;
79
        logic qnan;
80
        logic snan;
81
        logic infinity;
82
        logic sign;
83
        logic [13:0] exp;
84
        logic [139:0] sig;      // significand 35 digits
85
} DFP128UN;
86
 
87
// 128-bit Double width significand, normalizer input
88
typedef struct packed
89
{
90
        logic nan;
91
        logic qnan;
92
        logic snan;
93
        logic infinity;
94
        logic sign;
95
        logic [13:0] exp;
96
        logic [279:0] sig;      // significand 68+ 1 lead, 1-trail digit
97
} DFP128UD;
98
 
99
typedef logic [9:0] DFP64EXP;
100
typedef logic [63:0] DFP64SIG;
101
 
102
typedef struct packed
103
{
104
        logic sign;
105
        logic [4:0] combo;
106
        logic [7:0] expc;               // exponent continuation field
107
        logic [49:0] sigc;      // significand continuation field
108
} DFP64;
109
 
110
typedef struct packed
111
{
112
        logic nan;
113
        logic qnan;
114
        logic snan;
115
        logic infinity;
116
        logic sign;
117
        logic [9:0] exp;
118
        logic [63:0] sig;               // significand 16 digits
119
} DFP64U;
120
 
121
typedef struct packed
122
{
123
        logic nan;
124
        logic qnan;
125
        logic snan;
126
        logic infinity;
127
        logic sign;
128
        logic [9:0] exp;
129
        logic [67:0] sig;               // significand 17 digits
130
} DFP64UN;
131
 
132
typedef struct packed
133
{
134
        logic nan;
135
        logic qnan;
136
        logic snan;
137
        logic infinity;
138
        logic sign;
139
        logic [9:0] exp;
140
        logic [127:0] sig;              // significand 32 digits
141
} DFP64UD;
142
 
143
endpackage

powered by: WebSVN 2.1.0

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