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

Subversion Repositories thor

[/] [thor/] [trunk/] [rtl/] [verilog/] [fpUnit/] [fpLOOUnit.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 robfinch
/* ===============================================================
2
        (C) 2006,2015  Robert Finch
3
        All rights reserved.
4
        rob@birdcomputer.ca
5
 
6
        fpLOOUnit.v
7
                - 'latency of one' floating point unit
8
                - instructions can execute using a single cycle
9
                - issue rate is one per clock cycle
10
                - latency is one clock cycle
11
                - parameterized width
12
                - IEEE 754 representation
13
 
14
        This source code is free for use and modification for
15
        non-commercial or evaluation purposes, provided this
16
        copyright statement and disclaimer remains present in
17
        the file.
18
 
19
        If the code is modified, please state the origin and
20
        note that the code has been modified.
21
 
22
        NO WARRANTY.
23
        THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF
24
        ANY KIND, WHETHER EXPRESS OR IMPLIED. The user must assume
25
        the entire risk of using the Work.
26
 
27
        IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
28
        ANY INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES
29
        WHATSOEVER RELATING TO THE USE OF THIS WORK, OR YOUR
30
        RELATIONSHIP WITH THE AUTHOR.
31
 
32
        IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU
33
        TO USE THE WORK IN APPLICATIONS OR SYSTEMS WHERE THE
34
        WORK'S FAILURE TO PERFORM CAN REASONABLY BE EXPECTED
35
        TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN LOSS
36
        OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK,
37
        AND YOU AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS
38
        FROM ANY CLAIMS OR LOSSES RELATING TO SUCH UNAUTHORIZED
39
        USE.
40
 
41
 
42
        i2f - convert integer to floating point
43
        f2i - convert floating point to integer
44
 
45
        Ref: Webpack 8.1i  Spartan3-4 xc3s1000 4ft256
46
        61 LUTS / 34 slices / 16 ns
47
=============================================================== */
48
`include "..\Thor_defines.v"
49
 
50
module fpLOOUnit
51
#(parameter WID=32)
52
(
53
        input clk,
54
        input ce,
55
        input [1:0] rm,
56
        input [7:0] op,
57
        input [5:0] fn,
58
        input [WID:1] a,
59
        output reg [WID:1] o,
60
        output done
61
);
62
localparam MSB = WID-1;
63
localparam EMSB = WID==80 ? 14 :
64
                  WID==64 ? 10 :
65
                                  WID==52 ? 10 :
66
                                  WID==48 ? 10 :
67
                                  WID==44 ? 10 :
68
                                  WID==42 ? 10 :
69
                                  WID==40 ?  9 :
70
                                  WID==32 ?  7 :
71
                                  WID==24 ?  6 : 4;
72
localparam FMSB = WID==80 ? 63 :
73
                  WID==64 ? 51 :
74
                                  WID==52 ? 39 :
75
                                  WID==48 ? 35 :
76
                                  WID==44 ? 31 :
77
                                  WID==42 ? 29 :
78
                                  WID==40 ? 28 :
79
                                  WID==32 ? 22 :
80
                                  WID==24 ? 15 : 9;
81
 
82
wire [64:1] i2f_o;
83
wire [64:1] f2i_o;
84
wire [32:1] i2fs_o;
85
wire [32:1] f2is_o;
86
 
87
delay1 u1 (.clk(clk), .ce(ce), .i(op==`ITOF||op==`FTOI), .o(done) );
88
i2f #(64)  i2f0 (.clk(clk), .ce(ce), .rm(rm), .i(a), .o(i2f_o) );
89
f2i #(64)  f2i0 (.clk(clk), .ce(ce), .i(a), .o(f2i_o) );
90
i2f #(32)  i2fs (.clk(clk), .ce(ce), .rm(rm), .i(a[32:1]), .o(i2fs_o) );
91
f2i #(32)  f2is (.clk(clk), .ce(ce), .i(a[32:1]), .o(f2is_o) );
92
 
93
always @(op,a,i2f_o,f2i_o)
94
        case (op)
95
        `DOUBLE_R:
96
            case(fn)
97
        `ITOF:  o <= i2f_o;
98
        `FTOI:  o <= f2i_o;
99
        default:        o <= 0;
100
        endcase
101
    `SINGLE_R:
102
            case(fn)
103
        `ITOFS:    o <= i2fs_o;
104
        `FTOIS:    o <= f2is_o;
105
        default:        o <= 0;
106
        endcase
107
        default:        o <= 0;
108
        endcase
109
 
110
endmodule

powered by: WebSVN 2.1.0

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