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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [DFPPack.sv] - Blame information for rev 80

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
//      DPDPack.sv
9
//
10
// BSD 3-Clause License
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are met:
13
//
14
// 1. Redistributions of source code must retain the above copyright notice, this
15
//    list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright notice,
18
//    this list of conditions and the following disclaimer in the documentation
19
//    and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the copyright holder nor the names of its
22
//    contributors may be used to endorse or promote products derived from
23
//    this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
//
36
// ============================================================================
37
 
38
import DFPPkg::*;
39
 
40
module DFPPack128(i, o);
41
input DFP128U i;
42
output DFP128 o;
43
 
44
wire [109:0] enc_sig;
45
DPDEncodeN #(.N(11)) u1 (i.sig[131:0], enc_sig);
46
 
47 75 robfinch
always_comb
48 57 robfinch
begin
49
        // sign
50
        o.sign <= i.sign;
51
        // combo
52
        if (i.qnan|i.snan)
53
                o.combo <= 5'b11111;
54
        else if (i.infinity)
55
                o.combo <= 5'b11110;
56
        else
57
                o.combo <= i.sig[135:132] > 4'h7 ? {2'b11,i.exp[13:12],i.sig[132]} : {i.exp[13:12],i.sig[134:132]};
58
        // exponent continuation
59
        if (i.qnan)
60
                o.expc <= {1'b0,i.exp[10:0]};
61
        else if (i.snan)
62
                o.expc <= {1'b1,i.exp[10:0]};
63
        else
64
                o.expc <= i.exp[11:0];
65
        // significand continuation
66
        o.sigc <= enc_sig;
67
end
68
 
69
endmodule
70
 
71 75 robfinch
module DFPPack96(i, o);
72
input DFP96U i;
73
output DFP96 o;
74
 
75
wire [79:0] enc_sig;
76
DPDEncodeN #(.N(8)) u1 (i.sig[95:0], enc_sig);
77
 
78
always_comb
79
begin
80
        // sign
81
        o.sign <= i.sign;
82
        // combo
83
        if (i.qnan|i.snan)
84
                o.combo <= 5'b11111;
85
        else if (i.infinity)
86
                o.combo <= 5'b11110;
87
        else
88
                o.combo <= i.sig[99:96] > 4'h7 ? {2'b11,i.exp[11:10],i.sig[96]} : {i.exp[11:10],i.sig[98:96]};
89
        // exponent continuation
90
        if (i.qnan)
91
                o.expc <= {1'b0,i.exp[8:0]};
92
        else if (i.snan)
93
                o.expc <= {1'b1,i.exp[8:0]};
94
        else
95
                o.expc <= i.exp[9:0];
96
        // significand continuation
97
        o.sigc <= enc_sig;
98
end
99
 
100
endmodule
101 57 robfinch
module DFPPack64(i, o);
102
input DFP64U i;
103
output DFP64 o;
104
 
105
wire [49:0] enc_sig;
106
DPDEncodeN #(.N(5)) u1 (i.sig[59:0], enc_sig);
107
 
108 75 robfinch
always_comb
109 57 robfinch
begin
110
        // sign
111
        o.sign <= i.sign;
112
        // combo
113
        if (i.qnan|i.snan)
114
                o.combo <= 5'b11111;
115
        else if (i.infinity)
116
                o.combo <= 5'b11110;
117
        else
118
                o.combo <= i.sig[63:60] > 4'h7 ? {2'b11,i.exp[9:8],i.sig[60]} : {i.exp[9:8],i.sig[62:60]};
119
        // exponent continuation
120
        if (i.qnan)
121
                o.expc <= {1'b0,i.exp[6:0]};
122
        else if (i.snan)
123
                o.expc <= {1'b1,i.exp[6:0]};
124
        else
125
                o.expc <= i.exp[7:0];
126
        // significand continuation
127
        o.sigc <= enc_sig;
128
end
129
 
130
endmodule

powered by: WebSVN 2.1.0

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