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

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [rtl/] [fpUnit/] [fpdivr8.v] - Blame information for rev 51

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 51 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2006-2018  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch<remove>@finitron.ca
6
//       ||
7
//
8
//      fpdivr8.v
9
//      Radix8 doesn't work !!!!
10
//    Radix 2 floating point divider primitive
11
//
12
//
13
// This source file is free software: you can redistribute it and/or modify 
14
// it under the terms of the GNU Lesser General Public License as published 
15
// by the Free Software Foundation, either version 3 of the License, or     
16
// (at your option) any later version.                                      
17
//                                                                          
18
// This source file is distributed in the hope that it will be useful,      
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
21
// GNU General Public License for more details.                             
22
//                                                                          
23
// You should have received a copy of the GNU General Public License        
24
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
25
//                                                                          
26
// ============================================================================
27
 
28
module fpdivr8(clk, ld, a, b, q, r, done, lzcnt);
29
parameter WID = 112;
30
localparam DMSB = WID-1;
31
input clk;
32
input ld;
33
input [WID-1:0] a;
34
input [WID-1:0] b;
35
output reg [WID-1:0] q;
36
output [WID-1:0] r;
37
output reg done;
38
output reg [7:0] lzcnt;
39
 
40
 
41
reg [DMSB:0] rxx;
42
reg [8:0] cnt;                           // iteration count
43
reg [DMSB+1:0] ri = 0;
44
wire b0,b1,b2,b3;
45
wire [DMSB+1:0] r1,r2,r3;
46
reg gotnz;
47
 
48
wire [7:0] maxcnt;
49
wire [2:0] n1;
50
assign maxcnt = WID/3+1;
51
assign b0 = b < rxx;
52
assign r1 = b0 ? rxx - b : rxx;
53
assign b1 = b < {r1,q[WID-1]};
54
assign r2 = b1 ? {r1,q[WID-1]} - b : {r1,q[WID-1]};
55
assign b2 = b < {r2,q[WID-2]};
56
assign r3 = b2 ? {r2,q[WID-2]} - b : {r2,q[WID-2]};
57
 
58
always @(posedge clk)
59
    if (ld)
60
        rxx <= {WID{1'b0}};
61
    else if (!done)
62
        rxx <= {r3,q[WID-3]};
63
 
64
always @(posedge clk)
65
begin
66
        done <= 1'b0;
67
        if (ld) begin
68
                cnt <= maxcnt;
69
        end
70
        else if (cnt != 9'h1FE) begin
71
                cnt <= cnt - 1;
72
                if (cnt==9'h1FF)
73
                        done <= 1'b1;
74
        end
75
end
76
 
77
 
78
always @(posedge clk)
79
        if (ld) begin
80
                q <= a;
81
        end
82
        else if (!done) begin
83
                q[WID-1:3] <= q[WID-4:0];
84
                q[2] <= b0;
85
                q[1] <= b1;
86
                q[0] <= b2;
87
        end
88
    assign r = r3;
89
 
90
endmodule
91
 

powered by: WebSVN 2.1.0

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