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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [fpLOOUnit.v] - Blame information for rev 23

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

Line No. Rev Author Line
1 9 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
//      fpLOOUnit.v
10
//              - single cycle latency floating point unit
11
//              - parameterized width
12
//              - IEEE 754 representation
13
//
14
//
15
// This source file is free software: you can redistribute it and/or modify 
16
// it under the terms of the GNU Lesser General Public License as published 
17
// by the Free Software Foundation, either version 3 of the License, or     
18
// (at your option) any later version.                                      
19
//                                                                          
20
// This source file is distributed in the hope that it will be useful,      
21
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
23
// GNU General Public License for more details.                             
24
//                                                                          
25
// You should have received a copy of the GNU General Public License        
26
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
27
//                                                                          
28
//      i2f - convert integer to floating point
29
//  f2i - convert floating point to integer
30
//
31
// ============================================================================
32
 
33
`define FLOAT   6'h36
34
`define FTOI    6'h02
35
`define ITOF    6'h03
36
 
37
module fpLOOUnit
38
#(parameter WID=32)
39
(
40
        input clk,
41
        input ce,
42
        input [31:0] ir,
43
        input [WID-1:0] a,
44
        output reg [WID-1:0] o,
45
        output done
46
);
47
localparam MSB = WID-1;
48
localparam EMSB = WID==128 ? 14 :
49
                  WID==96 ? 14 :
50
                  WID==80 ? 14 :
51
                  WID==64 ? 10 :
52
                                  WID==52 ? 10 :
53
                                  WID==48 ? 10 :
54
                                  WID==44 ? 10 :
55
                                  WID==42 ? 10 :
56
                                  WID==40 ?  9 :
57
                                  WID==32 ?  7 :
58
                                  WID==24 ?  6 : 4;
59
localparam FMSB = WID==128 ? 111 :
60
                  WID==96 ? 79 :
61
                  WID==80 ? 63 :
62
                  WID==64 ? 51 :
63
                                  WID==52 ? 39 :
64
                                  WID==48 ? 35 :
65
                                  WID==44 ? 31 :
66
                                  WID==42 ? 29 :
67
                                  WID==40 ? 28 :
68
                                  WID==32 ? 22 :
69
                                  WID==24 ? 15 : 9;
70
 
71
wire [WID-1:0] i2f_o;
72
wire [WID-1:0] f2i_o;
73
wire [5:0] op = ir[5:0];
74
wire [5:0] fn = ir[17:12];
75
wire [2:0] rm = ir[26:24];
76
wire [1:0] prec = ir[28:27];
77
 
78
delay1 u1 (.clk(clk), .ce(ce), .i(op==`FLOAT && (fn==`ITOF||fn==`FTOI)), .o(done) );
79
i2f #(WID)  ui2fs (.clk(clk), .ce(ce), .rm(rm), .i(a), .o(i2f_o) );
80
f2i #(WID)  uf2is (.clk(clk), .ce(ce), .i(a), .o(f2i_o) );
81
 
82
always @*
83
        case (op)
84
        `FLOAT:
85
       case(fn)
86
       `ITOF:   o <= i2f_o;
87
       `FTOI:   o <= f2i_o;
88
       default: o <= 0;
89
       endcase
90
    default:   o <= 0;
91
    endcase
92
 
93
endmodule

powered by: WebSVN 2.1.0

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