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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [F80ToF32.v] - Blame information for rev 84

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

Line No. Rev Author Line
1 29 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2006-2019  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//
9
//
10
// This source file is free software: you can redistribute it and/or modify 
11
// it under the terms of the GNU Lesser General Public License as published 
12
// by the Free Software Foundation, either version 3 of the License, or     
13
// (at your option) any later version.                                      
14
//                                                                          
15
// This source file is distributed in the hope that it will be useful,      
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
18
// GNU General Public License for more details.                             
19
//                                                                          
20
// You should have received a copy of the GNU General Public License        
21
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
22
//                                                                          
23
// ============================================================================
24
 
25
`include "fpConfig.sv"
26
 
27
module F80ToF32(a, o);
28
input [79:0] a;
29
output [31:0] o;
30
 
31
reg signo;
32
reg [7:0] expo;
33
reg [22:0] mano;
34
 
35
assign o = {signo,expo,mano};
36
 
37
wire signi;
38
wire [14:0] expi;
39
wire [63:0] mani;
40
wire xinf;      // exponent infinite
41
wire vz;        // value zero
42
wire xz;        // exponent zero
43
 
44
fpDecomp #(80) u1 (.i(a), .sgn(signi), .exp(expi), .man(mani), .xinf(xinf), .xz(xz), .vz(vz) );
45
 
46
always @*
47
begin
48
  // sign out always just = sign in
49
  signo = signi;
50
 
51
  // special check for zero
52
  if (vz) begin
53
    expo <= 0;
54
    mano <= 0;
55
  end
56
  // convert infinity / nan
57
  // infinity in = infinity out
58
  else if (xinf) begin
59
    expo <= 8'h7f;
60
    mano <= mani[63:41];
61
  end
62
  // convert denormal
63
  // a denormal was really a number with an exponent of -126
64
  // this value is easily represented in the double format
65
  // it may be possible to normalize the value if it isn't
66
  // zero
67
  else if (xz) begin
68
    expo <= 8'h00;
69
    mano <= 23'h0;
70
  end
71
  // convert typical number
72
  // adjust exponent, copy mantissa
73
  else begin
74
        if (expi < 15'h3fff - 8'h7f) begin
75
                expo <= 8'h00;  // zero
76
                mano <= 23'h0;
77
        end
78
        else if (expi > 15'h3fff + 8'h7f) begin
79
                expo <= 8'hFF;  // Infinity
80
                mano <= 23'h0;
81
        end
82
        else begin
83
        expo <= expi - 15'h3fff + 8'h7f;
84
        mano <= mani[63:41];
85
    end
86
  end
87
end
88
 
89
endmodule

powered by: WebSVN 2.1.0

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