| Line 1... | Line 1... | 
      
        | `timescale 1ns / 1ps
 | `timescale 1ns / 1ps
 | 
      
        | // ============================================================================
 | // ============================================================================
 | 
      
        | //        __
 | //        __
 | 
      
        | //   \\__/ o\    (C) 2006-2018  Robert Finch, Waterloo
 | //   \\__/ o\    (C) 2006-2019  Robert Finch, Waterloo
 | 
      
        | //    \  __ /    All rights reserved.
 | //    \  __ /    All rights reserved.
 | 
      
        | //     \/_//     robfinch<remove>@finitron.ca
 | //     \/_//     robfinch<remove>@finitron.ca
 | 
      
        | //       ||
 | //       ||
 | 
      
        | //
 | //
 | 
      
        | //      fpDiv.v
 | //      fpDiv.v
 | 
      
        | Line 32... | Line 32... | 
      
        | //+-inf * 0     = QNaN
 | //+-inf * 0     = QNaN
 | 
      
        | //+-0 / +-0      = QNaN
 | //+-0 / +-0      = QNaN
 | 
      
        | // ============================================================================
 | // ============================================================================
 | 
      
        |  
 |  
 | 
      
        | `include "fp_defines.v"
 | `include "fp_defines.v"
 | 
      
        | `define GOLDSCHMIDT     1'b1
 | //`define GOLDSCHMIDT   1'b1
 | 
      
        |  
 |  
 | 
      
        | module fpDiv(rst, clk, ce, ld, op, a, b, o, done, sign_exe, overflow, underflow);
 | module fpDiv(rst, clk, clk4x, ce, ld, op, a, b, o, done, sign_exe, overflow, underflow);
 | 
      
        |  
 |  
 | 
      
        | parameter WID = 128;
 | parameter WID = 128;
 | 
      
        | localparam MSB = WID-1;
 | `include "fpSize.sv"
 | 
      
        | localparam EMSB = WID==128 ? 14 :
 |   | 
      
        |                   WID==96 ? 14 :
 |   | 
      
        |                   WID==80 ? 14 :
 |   | 
      
        |                   WID==64 ? 10 :
 |   | 
      
        |                                   WID==52 ? 10 :
 |   | 
      
        |                                   WID==48 ? 11 :
 |   | 
      
        |                                   WID==44 ? 10 :
 |   | 
      
        |                                   WID==42 ? 10 :
 |   | 
      
        |                                   WID==40 ?  9 :
 |   | 
      
        |                                   WID==32 ?  7 :
 |   | 
      
        |                                   WID==24 ?  6 : 4;
 |   | 
      
        | localparam FMSB = WID==128 ? 111 :
 |   | 
      
        |                   WID==96 ? 79 :
 |   | 
      
        |                   WID==80 ? 63 :
 |   | 
      
        |                   WID==64 ? 51 :
 |   | 
      
        |                                   WID==52 ? 39 :
 |   | 
      
        |                                   WID==48 ? 34 :
 |   | 
      
        |                                   WID==44 ? 31 :
 |   | 
      
        |                                   WID==42 ? 29 :
 |   | 
      
        |                                   WID==40 ? 28 :
 |   | 
      
        |                                   WID==32 ? 22 :
 |   | 
      
        |                                   WID==24 ? 15 : 9;
 |   | 
      
        | // FADD is a constant that makes the divider width a multiple of four and includes eight extra bits.                    
 | // FADD is a constant that makes the divider width a multiple of four and includes eight extra bits.                    
 | 
      
        | localparam FADD = WID==128 ? 9 :
 | localparam FADD = WID==128 ? 9 :
 | 
      
        |                                   WID==96 ? 9 :
 |                                   WID==96 ? 9 :
 | 
      
        |   |                                   WID==84 ? 9 :
 | 
      
        |                                   WID==80 ? 9 :
 |                                   WID==80 ? 9 :
 | 
      
        |                                   WID==64 ? 13 :
 |                                   WID==64 ? 13 :
 | 
      
        |                                   WID==52 ? 9 :
 |                                   WID==52 ? 9 :
 | 
      
        |                                   WID==48 ? 10 :
 |                                   WID==48 ? 10 :
 | 
      
        |                                   WID==44 ? 9 :
 |                                   WID==44 ? 9 :
 | 
      
        |                                   WID==42 ? 11 :
 |                                   WID==42 ? 11 :
 | 
      
        |                                   WID==40 ? 8 :
 |                                   WID==40 ? 8 :
 | 
      
        |                                   WID==32 ? 10 :
 |                                   WID==32 ? 10 :
 | 
      
        |                                   WID==24 ? 9 : 11;
 |                                   WID==24 ? 9 : 11;
 | 
      
        |  
 |  
 | 
      
        | localparam FX = (FMSB+2)*2-1;   // the MSB of the expanded fraction
 |   | 
      
        | localparam EX = FX + 1 + EMSB + 1 + 1 - 1;
 |   | 
      
        | input rst;
 | input rst;
 | 
      
        | input clk;
 | input clk;
 | 
      
        |   | input clk4x;
 | 
      
        | input ce;
 | input ce;
 | 
      
        | input ld;
 | input ld;
 | 
      
        | input op;
 | input op;
 | 
      
        | input [MSB:0] a, b;
 | input [MSB:0] a, b;
 | 
      
        | output [EX:0] o;
 | output [EX:0] o;
 | 
      
        | Line 153... | Line 131... | 
      
        |  
 |  
 | 
      
        | // Perform divide
 | // Perform divide
 | 
      
        | // Divider width must be a multiple of four
 | // Divider width must be a multiple of four
 | 
      
        | `ifndef GOLDSCHMIDT
 | `ifndef GOLDSCHMIDT
 | 
      
        | fpdivr16 #(FMSB+FADD) u2 (.clk(clk), .ld(ld), .a({3'b0,fracta,8'b0}), .b({3'b0,fractb,8'b0}), .q(divo), .r(), .done(done1), .lzcnt(lzcnt));
 | fpdivr16 #(FMSB+FADD) u2 (.clk(clk), .ld(ld), .a({3'b0,fracta,8'b0}), .b({3'b0,fractb,8'b0}), .q(divo), .r(), .done(done1), .lzcnt(lzcnt));
 | 
      
        |   | //fpdivr2 #(FMSB+FADD) u2 (.clk4x(clk4x), .ld(ld), .a({3'b0,fracta,8'b0}), .b({3'b0,fractb,8'b0}), .q(divo), .r(), .done(done1), .lzcnt(lzcnt));
 | 
      
        | wire [(FMSB+FADD)*2-1:0] divo1 = divo[(FMSB+FADD)*2-1:0] << (lzcnt-2);
 | wire [(FMSB+FADD)*2-1:0] divo1 = divo[(FMSB+FADD)*2-1:0] << (lzcnt-2);
 | 
      
        | `else
 | `else
 | 
      
        | DivGoldschmidt #(.WID(FMSB+6),.WHOLE(1),.POINTS(FMSB+5))
 | DivGoldschmidt #(.WID(FMSB+6),.WHOLE(1),.POINTS(FMSB+5))
 | 
      
        |         u2 (.rst(rst), .clk(clk), .ld(ld), .a({fracta,4'b0}), .b({fractb,4'b0}), .q(divo), .done(done1), .lzcnt(lzcnt));
 |         u2 (.rst(rst), .clk(clk), .ld(ld), .a({fracta,4'b0}), .b({fractb,4'b0}), .q(divo), .done(done1), .lzcnt(lzcnt));
 | 
      
        | wire [(FMSB+6)*2+1:0] divo1 =
 | wire [(FMSB+6)*2+1:0] divo1 =
 | 
      
        | Line 215... | Line 194... | 
      
        |                 end
 |                 end
 | 
      
        |         end
 |         end
 | 
      
        |  
 |  
 | 
      
        | endmodule
 | endmodule
 | 
      
        |  
 |  
 | 
      
        | module fpDivnr(rst, clk, ce, ld, op, a, b, o, rm, done, sign_exe, inf, overflow, underflow);
 | module fpDivnr(rst, clk, clk4x, ce, ld, op, a, b, o, rm, done, sign_exe, inf, overflow, underflow);
 | 
      
        | parameter WID=32;
 | parameter WID=32;
 | 
      
        | localparam MSB = WID-1;
 | `include "fpSize.sv"
 | 
      
        | localparam EMSB = WID==128 ? 14 :
 |   | 
      
        |                   WID==96 ? 14 :
 |   | 
      
        |                   WID==80 ? 14 :
 |   | 
      
        |                   WID==64 ? 10 :
 |   | 
      
        |                                   WID==52 ? 10 :
 |   | 
      
        |                                   WID==48 ? 11 :
 |   | 
      
        |                                   WID==44 ? 10 :
 |   | 
      
        |                                   WID==42 ? 10 :
 |   | 
      
        |                                   WID==40 ?  9 :
 |   | 
      
        |                                   WID==32 ?  7 :
 |   | 
      
        |                                   WID==24 ?  6 : 4;
 |   | 
      
        | localparam FMSB = WID==128 ? 111 :
 |   | 
      
        |                   WID==96 ? 79 :
 |   | 
      
        |                   WID==80 ? 63 :
 |   | 
      
        |                   WID==64 ? 51 :
 |   | 
      
        |                                   WID==52 ? 39 :
 |   | 
      
        |                                   WID==48 ? 34 :
 |   | 
      
        |                                   WID==44 ? 31 :
 |   | 
      
        |                                   WID==42 ? 29 :
 |   | 
      
        |                                   WID==40 ? 28 :
 |   | 
      
        |                                   WID==32 ? 22 :
 |   | 
      
        |                                   WID==24 ? 15 : 9;
 |   | 
      
        |  
 |  
 | 
      
        | localparam FX = (FMSB+2)*2-1;   // the MSB of the expanded fraction
 |   | 
      
        | localparam EX = FX + 1 + EMSB + 1 + 1 - 1;
 |   | 
      
        | input rst;
 | input rst;
 | 
      
        | input clk;
 | input clk;
 | 
      
        |   | input clk4x;
 | 
      
        | input ce;
 | input ce;
 | 
      
        | input ld;
 | input ld;
 | 
      
        | input op;
 | input op;
 | 
      
        | input  [MSB:0] a, b;
 | input  [MSB:0] a, b;
 | 
      
        | output [MSB:0] o;
 | output [MSB:0] o;
 | 
      
        | Line 262... | Line 218... | 
      
        | wire [EX:0] o1;
 | wire [EX:0] o1;
 | 
      
        | wire sign_exe1, inf1, overflow1, underflow1;
 | wire sign_exe1, inf1, overflow1, underflow1;
 | 
      
        | wire [MSB+3:0] fpn0;
 | wire [MSB+3:0] fpn0;
 | 
      
        | wire done1;
 | wire done1;
 | 
      
        |  
 |  
 | 
      
        | fpDiv       #(WID) u1 (rst, clk, ce, ld, op, a, b, o1, done1, sign_exe1, overflow1, underflow1);
 | fpDiv       #(WID) u1 (rst, clk, clk4x, ce, ld, op, a, b, o1, done1, sign_exe1, overflow1, underflow1);
 | 
      
        | fpNormalize #(WID) u2(.clk(clk), .ce(ce), .under(underflow1), .i(o1), .o(fpn0) );
 | fpNormalize #(WID) u2(.clk(clk), .ce(ce), .under(underflow1), .i(o1), .o(fpn0) );
 | 
      
        | fpRoundReg  #(WID) u3(.clk(clk), .ce(ce), .rm(rm), .i(fpn0), .o(o) );
 | fpRoundReg  #(WID) u3(.clk(clk), .ce(ce), .rm(rm), .i(fpn0), .o(o) );
 | 
      
        | delay2      #(1)   u4(.clk(clk), .ce(ce), .i(sign_exe1), .o(sign_exe));
 | delay2      #(1)   u4(.clk(clk), .ce(ce), .i(sign_exe1), .o(sign_exe));
 | 
      
        | delay2      #(1)   u5(.clk(clk), .ce(ce), .i(inf1), .o(inf));
 | delay2      #(1)   u5(.clk(clk), .ce(ce), .i(inf1), .o(inf));
 | 
      
        | delay2      #(1)   u6(.clk(clk), .ce(ce), .i(overflow1), .o(overflow));
 | delay2      #(1)   u6(.clk(clk), .ce(ce), .i(overflow1), .o(overflow));
 |