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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [fpDecomp128Reg.sv] - Blame information for rev 90

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 90 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2006-2022  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
//      fpDecomp128Reg.v
9
//    - decompose floating point value with registered outputs
10
//    - parameterized width
11
//
12
//
13
// This source file is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License, or
16
// (at your option) any later version.
17
//
18
// This source file is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
// GNU General Public License for more details.
22
//
23
// You should have received a copy of the GNU General Public License
24
// along with this program.  If not, see .
25
//
26
// ============================================================================
27
 
28
import fp128Pkg::*;
29
 
30
module fpDecomp128(i, sgn, exp, man, fract, xz, mz, vz, inf, xinf, qnan, snan, nan);
31
input FP128 i;
32
output sgn;
33
output [fp128Pkg::EMSB:0] exp;
34
output [fp128Pkg::FMSB:0] man;
35
output [fp128Pkg::FMSB+1:0] fract;      // mantissa with hidden bit recovered
36
output xz;              // denormalized - exponent is zero
37
output mz;              // mantissa is zero
38
output vz;              // value is zero (both exponent and mantissa are zero)
39
output inf;             // all ones exponent, zero mantissa
40
output xinf;    // all ones exponent
41
output qnan;    // nan
42
output snan;    // signalling nan
43
output nan;
44
 
45
// Decompose input
46
assign sgn = i.sign;
47
assign exp = i.exp;
48
assign man = i.sig;
49
assign xz = !(|exp);    // denormalized - exponent is zero
50
assign mz = !(|man);    // mantissa is zero
51
assign vz = xz & mz;        // value is zero (both exponent and mantissa are zero)
52
assign inf = &exp & mz;  // all ones exponent, zero mantissa
53
assign xinf = &exp;
54
assign qnan = &exp &  man[fp128Pkg::FMSB];
55
assign snan = &exp & !man[fp128Pkg::FMSB] & !mz;
56
assign nan = &exp & !mz;
57
assign fract = {!xz,i.sig};
58
 
59
endmodule
60
 
61
 
62
module fpDecomp128Reg(clk, ce, i, o, sgn, exp, man, fract, xz, mz, vz, inf, xinf, qnan, snan, nan);
63
input clk;
64
input ce;
65
input FP128 i;
66
 
67
output FP128 o;
68
output reg sgn;
69
output reg [fp128Pkg::EMSB:0] exp;
70
output reg [fp128Pkg::FMSB:0] man;
71
output reg [fp128Pkg::FMSB+1:0] fract;  // mantissa with hidden bit recovered
72
output reg xz;          // denormalized - exponent is zero
73
output reg mz;          // mantissa is zero
74
output reg vz;          // value is zero (both exponent and mantissa are zero)
75
output reg inf;         // all ones exponent, zero mantissa
76
output reg xinf;        // all ones exponent
77
output reg qnan;        // nan
78
output reg snan;        // signalling nan
79
output reg nan;
80
 
81
// Decompose input
82
always_ff @(posedge clk)
83
        if (ce) begin
84
                o <= i;
85
                sgn = i.sign;
86
                exp = i.exp;
87
                man = i.sig;
88
                xz = !(|exp);   // denormalized - exponent is zero
89
                mz = !(|man);   // mantissa is zero
90
                vz = xz & mz;       // value is zero (both exponent and mantissa are zero)
91
                inf = &exp & mz; // all ones exponent, zero mantissa
92
                xinf = &exp;
93
                qnan = &exp &  man[fp128Pkg::FMSB];
94
                snan = &exp & !man[fp128Pkg::FMSB] & !mz;
95
                nan = &exp & !mz;
96
                fract = {|exp,i.sig};
97
        end
98
 
99
endmodule

powered by: WebSVN 2.1.0

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