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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fpDecompose.v] - Blame information for rev 88

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

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

powered by: WebSVN 2.1.0

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