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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [fpdivr16.v] - Diff between revs 29 and 30

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 29 Rev 30
Line 23... Line 23...
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
//                                                                          
//                                                                          
// ============================================================================
// ============================================================================
 
 
module fpdivr16(clk, ld, a, b, q, r, done, lzcnt);
module fpdivr16(clk, ld, a, b, q, r, done, lzcnt);
parameter FPWID1 = 112;
parameter WID1 = 112;
localparam REM = FPWID1 % 4;
localparam REM = WID1 % 4;
localparam FPWID = ((FPWID1*4)+3)/4;
localparam WID = ((WID1*4)+3)/4;
localparam DMSB = FPWID-1;
localparam DMSB = WID-1;
input clk;
input clk;
input ld;
input ld;
input [FPWID-1:0] a;
input [WID-1:0] a;
input [FPWID-1:0] b;
input [WID-1:0] b;
output reg [FPWID*2-1:0] q = 1'd0;
output reg [WID*2-1:0] q = 1'd0;
output reg [FPWID-1:0] r = 1'd0;
output reg [WID-1:0] r = 1'd0;
output reg done = 1'd0;
output reg done = 1'd0;
output reg [7:0] lzcnt = 1'd0;
output reg [7:0] lzcnt = 1'd0;
 
 
initial begin
initial begin
        if (FPWID % 4) begin
        if (WID % 4) begin
                $display("fpdvir16: FPWIDth must be a multiple of four.");
                $display("fpdvir16: Width must be a multiple of four.");
                $finish;
                $finish;
        end
        end
end
end
 
 
wire [7:0] maxcnt;
wire [7:0] maxcnt;
Line 52... Line 52...
reg [DMSB+1:0] ri = 1'd0;
reg [DMSB+1:0] ri = 1'd0;
reg b0 = 1'd0,b1 = 1'd0,b2 = 1'd0,b3 = 1'd0;
reg b0 = 1'd0,b1 = 1'd0,b2 = 1'd0,b3 = 1'd0;
reg [DMSB+1:0] r1 = 1'd0,r2 = 1'd0,r3 = 1'd0,r4 = 1'd0;
reg [DMSB+1:0] r1 = 1'd0,r2 = 1'd0,r3 = 1'd0,r4 = 1'd0;
reg gotnz = 0;
reg gotnz = 0;
 
 
assign maxcnt = FPWID*2/4-1;
assign maxcnt = WID*2/4-1;
always @*
always @*
        b0 = b <= {rxx,q[FPWID*2-1]};
        b0 = b <= {rxx,q[WID*2-1]};
always @*
always @*
        r1 = b0 ? {rxx,q[FPWID*2-1]} - b : {rxx,q[FPWID*2-1]};
        r1 = b0 ? {rxx,q[WID*2-1]} - b : {rxx,q[WID*2-1]};
always @*
always @*
        b1 = b <= {r1,q[FPWID*2-2]};
        b1 = b <= {r1,q[WID*2-2]};
always @*
always @*
        r2 = b1 ? {r1,q[FPWID*2-2]} - b : {r1,q[FPWID*2-2]};
        r2 = b1 ? {r1,q[WID*2-2]} - b : {r1,q[WID*2-2]};
always @*
always @*
        b2 = b <= {r2,q[FPWID*2-3]};
        b2 = b <= {r2,q[WID*2-3]};
always @*
always @*
        r3 = b2 ? {r2,q[FPWID*2-3]} - b : {r2,q[FPWID*2-3]};
        r3 = b2 ? {r2,q[WID*2-3]} - b : {r2,q[WID*2-3]};
always @*
always @*
        b3 = b <= {r3,q[FPWID*2-4]};
        b3 = b <= {r3,q[WID*2-4]};
always @*
always @*
        r4 = b3 ? {r3,q[FPWID*2-4]} - b : {r3,q[FPWID*2-4]};
        r4 = b3 ? {r3,q[WID*2-4]} - b : {r3,q[WID*2-4]};
 
 
reg [2:0] state = 0;
reg [2:0] state = 0;
 
 
always @(posedge clk)
always @(posedge clk)
begin
begin
done <= 1'b0;
done <= 1'b0;
case(state)
case(state)
3'd0:
3'd0:   ;
        if (ld) begin
 
                lzcnt <= 0;
 
                gotnz <= 0;
 
                cnt <= maxcnt;
 
                q <= {(a << REM),{FPWID{1'b0}}};
 
        rxx <= {FPWID{1'b0}};
 
                state <= 1;
 
        end
 
3'd1:
3'd1:
        if (!cnt[8]) begin
        if (!cnt[8]) begin
                q[FPWID*2-1:4] <= q[FPWID*2-5:0];
                q[WID*2-1:4] <= q[WID*2-5:0];
                q[3] <= b0;
                q[3] <= b0;
                q[2] <= b1;
                q[2] <= b1;
                q[1] <= b2;
                q[1] <= b2;
                q[0] <= b3;
                q[0] <= b3;
                if (!gotnz)
                if (!gotnz)
Line 116... Line 108...
        done <= 1'b1;
        done <= 1'b1;
        state <= 1'd0;
        state <= 1'd0;
    end
    end
default:        state <= 1'd0;
default:        state <= 1'd0;
endcase
endcase
 
if (ld) begin
 
        lzcnt <= 0;
 
        gotnz <= 1'b0;
 
        cnt <= {1'b0,maxcnt};
 
        q <= {(a << REM),{WID{1'b0}}};
 
      rxx <= {WID{1'b0}};
 
        state <= 3'd1;
 
end
end
end
 
 
endmodule
endmodule
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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