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

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [rtl/] [verilog/] [fp/] [fpZLUnit.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 robfinch
/* ===============================================================
2
        (C) 2007  Robert T Finch
3
        All rights reserved.
4
        rob@birdcomputer.ca
5
 
6
        fpZLUnit.v
7
                - zero latency floating point unit
8
                - instructions can execute in a single cycle without
9
                  a clock
10
                - parameterized width
11
                - IEEE 754 representation
12
 
13
        This source code is free for use and modification for
14
        non-commercial or evaluation purposes, provided this
15
        copyright statement and disclaimer remains present in
16
        the file.
17
 
18
        If the code is modified, please state the origin and
19
        note that the code has been modified.
20
 
21
        NO WARRANTY.
22
        THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF
23
        ANY KIND, WHETHER EXPRESS OR IMPLIED. The user must assume
24
        the entire risk of using the Work.
25
 
26
        IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27
        ANY INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES
28
        WHATSOEVER RELATING TO THE USE OF THIS WORK, OR YOUR
29
        RELATIONSHIP WITH THE AUTHOR.
30
 
31
        IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU
32
        TO USE THE WORK IN APPLICATIONS OR SYSTEMS WHERE THE
33
        WORK'S FAILURE TO PERFORM CAN REASONABLY BE EXPECTED
34
        TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN LOSS
35
        OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK,
36
        AND YOU AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS
37
        FROM ANY CLAIMS OR LOSSES RELATING TO SUCH UNAUTHORIZED
38
        USE.
39
 
40
        fabs    - get absolute value of number
41
        fnabs   - get negative absolute value of number
42
        fneg    - negate number
43
        fmov    - copy input to output
44
        fsign   - get sign of number (set number to +1,0, or -1)
45
        fman    - get mantissa (set exponent to zero)
46
 
47
        fclt    - less than
48
        fcle    - less than or equal
49
        fcgt    - greater than
50
        fcge    - greater than or equal
51
        fceq    - equal
52
        fcne    - not equal
53
        fcor    - ordered
54
        fcun    - unordered
55
 
56
        Ref: Webpack 8.1i  Spartan3-4 xc3s1000 4ft256
57
        160 LUTS / 80 slices / 21 ns
58
=============================================================== */
59
`define FABS    6'd0
60
`define FNABS   6'd1
61
`define FNEG    6'd2
62
`define FMOV    6'd3
63
`define FSIGN   6'd4
64
`define FMAN    6'd5
65
 
66
module fpZLUnit
67
#(parameter WID=32)
68
(
69
        input [5:0] op,
70
        input [WID:1] a,
71
        input [WID:1] b,        // for fcmp
72
        output reg [WID:1] o,
73
        output nanx
74
);
75
localparam MSB = WID-1;
76
localparam EMSB = WID==80 ? 14 :
77
                  WID==64 ? 10 :
78
                                  WID==52 ? 10 :
79
                                  WID==48 ? 10 :
80
                                  WID==44 ? 10 :
81
                                  WID==42 ? 10 :
82
                                  WID==40 ?  9 :
83
                                  WID==32 ?  7 :
84
                                  WID==24 ?  6 : 4;
85
localparam FMSB = WID==80 ? 63 :
86
                  WID==64 ? 51 :
87
                                  WID==52 ? 39 :
88
                                  WID==48 ? 35 :
89
                                  WID==44 ? 31 :
90
                                  WID==42 ? 29 :
91
                                  WID==40 ? 28 :
92
                                  WID==32 ? 22 :
93
                                  WID==24 ? 15 : 9;
94
 
95
wire az = a[WID-1:1]==0;
96
wire cmp_o;
97
 
98
fp_cmp_unit #(WID) u1 (.op(op[2:0]), .a(a), .b(b), .o(cmp_o), .nanx(nanx) );
99
 
100
always @(op,a,cmp_o,az)
101
        case (op)
102
        `FABS:  o <= {1'b0,a[WID-1:1]};         // fabs
103
        `FNABS: o <= {1'b1,a[WID-1:1]};         // fnabs
104
        `FNEG:  o <= {~a[WID],a[WID-1:1]};      // fneg
105
        `FMOV:  o <= a;                                         // fmov
106
        `FSIGN: o <= az ? 0 : {a[WID],1'b0,{EMSB{1'b1}},{FMSB+1{1'b0}}}; // fsign
107
        `FMAN:  o <= {a[WID],1'b0,{EMSB{1'b1}},a[FMSB:1]};      // fman
108
        default:        o <= cmp_o;
109
        endcase
110
 
111
endmodule

powered by: WebSVN 2.1.0

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