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

Subversion Repositories thor

[/] [thor/] [trunk/] [rtl/] [verilog/] [fpUnit/] [fp_decomp.v] - Blame information for rev 41

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

Line No. Rev Author Line
1 6 robfinch
/* ============================================================================
2
        (C) 2006, 2007  Robert T Finch
3
        All rights reserved.
4
        rob@birdcomputer.ca
5
 
6
        fp_decomp.v
7
                - decompose floating point value
8
                - parameterized width
9
 
10
 
11
        Verilog 1995
12
 
13
        This source code is free for use and modification for non-commercial or
14
        evaluation purposes, provided this copyright statement and disclaimer
15
        remains present in the file.
16
 
17
        If the code is modified, please state the origin and note that the code
18
        has been modified.
19
 
20
        NO WARRANTY.
21
        THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER
22
        EXPRESS OR IMPLIED. The user must assume the entire risk of using the
23
        Work.
24
 
25
        IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
26
        INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO
27
        THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR.
28
 
29
        IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK
30
        IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN
31
        REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN
32
        LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU
33
        AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR
34
        LOSSES RELATING TO SUCH UNAUTHORIZED USE.
35
 
36
 
37
        Ref: Webpack 8.1i Spartan3-4 xc3s1000 4ft256
38
        10 slices / 20 LUTs / 12 ns  (32 bits)
39
 
40
============================================================================ */
41
 
42
module fp_decomp(i, sgn, exp, man, fract, xz, mz, vz, inf, xinf, qnan, snan, nan);
43
 
44
parameter WID=32;
45
 
46
localparam MSB  = WID-1;
47
localparam EMSB = WID==80 ? 14 :
48
                  WID==64 ? 10 :
49
                                  WID==52 ? 10 :
50
                                  WID==48 ? 10 :
51
                                  WID==44 ? 10 :
52
                                  WID==42 ? 10 :
53
                                  WID==40 ?  9 :
54
                                  WID==32 ?  7 :
55
                                  WID==24 ?  6 : 4;
56
localparam FMSB = WID==80 ? 63 :
57
                  WID==64 ? 51 :
58
                                  WID==52 ? 39 :
59
                                  WID==48 ? 35 :
60
                                  WID==44 ? 31 :
61
                                  WID==42 ? 29 :
62
                                  WID==40 ? 28 :
63
                                  WID==32 ? 22 :
64
                                  WID==24 ? 15 : 9;
65
 
66
input [MSB:0] i;
67
 
68
output sgn;
69
output [EMSB:0] exp;
70
output [FMSB:0] man;
71
output [FMSB+1:0] fract; // mantissa with hidden bit recovered
72
output xz;              // denormalized - exponent is zero
73
output mz;              // mantissa is zero
74
output vz;              // value is zero (both exponent and mantissa are zero)
75
output inf;             // all ones exponent, zero mantissa
76
output xinf;    // all ones exponent
77
output qnan;    // nan
78
output snan;    // signalling nan
79
output nan;
80
 
81
// Decompose input
82
assign sgn = i[MSB];
83
assign exp = i[MSB-1:FMSB+1];
84
assign man = i[FMSB:0];
85
assign xz = !(|exp);    // denormalized - exponent is zero
86
assign mz = !(|man);    // mantissa is zero
87
assign vz = xz & mz;    // value is zero (both exponent and mantissa are zero)
88
assign inf = &exp & mz; // all ones exponent, zero mantissa
89
assign xinf = &exp;
90
assign qnan = &exp &  man[FMSB];
91
assign snan = &exp & !man[FMSB] & !mz;
92
assign nan = &exp & !mz;
93
assign fract = {!xz,i[FMSB:0]};
94
 
95
endmodule
96
 
97
 

powered by: WebSVN 2.1.0

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