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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fp_decomp.v] - Blame information for rev 22

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

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

powered by: WebSVN 2.1.0

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