mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
fdivsqrt parameter cleanup
This commit is contained in:
parent
4c106215f4
commit
953c53d065
@ -94,15 +94,14 @@ localparam FMT2 = ((F_SUPPORTED & (LEN1 != S_LEN)) ? 2'd0 : 2'd2);
|
|||||||
localparam BIAS2 = ((F_SUPPORTED & (LEN1 != S_LEN)) ? S_BIAS : H_BIAS);
|
localparam BIAS2 = ((F_SUPPORTED & (LEN1 != S_LEN)) ? S_BIAS : H_BIAS);
|
||||||
|
|
||||||
// division constants
|
// division constants
|
||||||
localparam DIVN = ((NF+2<XLEN) & IDIV_ON_FPU) ? XLEN : NF+2; // standard length of input
|
localparam DIVN = ((NF+2<XLEN) & IDIV_ON_FPU) ? XLEN : NF+2; // standard length of input: max(XLEN, NF+2)
|
||||||
localparam LOGR = $clog2(RADIX); // r = log(R)
|
localparam LOGR = $clog2(RADIX); // r = log(R)
|
||||||
localparam RK = LOGR*DIVCOPIES; // r*k used for intdiv preproc
|
localparam RK = LOGR*DIVCOPIES; // r*k bits per cycle generated
|
||||||
localparam LOGRK = $clog2(RK); // log2(r*k)
|
localparam LOGRK = $clog2(RK); // log2(r*k)
|
||||||
localparam FPDUR = (DIVN+1)/RK + 1 + (RADIX/4);
|
localparam FPDUR = (DIVN+1)/RK + 1 + (RADIX/4); //
|
||||||
localparam DURLEN = $clog2(FPDUR+1);
|
localparam DURLEN = $clog2(FPDUR+1);
|
||||||
localparam DIVb = FPDUR*RK - 1; // canonical fdiv size (b)
|
localparam DIVb = FPDUR*RK - 1; // canonical fdiv size (b)
|
||||||
localparam DIVBLEN = $clog2(DIVb+1)-1;
|
localparam DIVBLEN = $clog2(DIVb+2)-1;
|
||||||
localparam DIVa = DIVb+1-XLEN; // used for idiv on fpu: Shift residual right by b - (XLEN-1) to put remainder in lsbs of integer result
|
|
||||||
|
|
||||||
// largest length in IEU/FPU
|
// largest length in IEU/FPU
|
||||||
localparam CVTLEN = ((NF<XLEN) ? (XLEN) : (NF)); // max(XLEN, NF)
|
localparam CVTLEN = ((NF<XLEN) ? (XLEN) : (NF)); // max(XLEN, NF)
|
||||||
|
@ -184,6 +184,5 @@ localparam cvw_t P = '{
|
|||||||
FPDUR : FPDUR,
|
FPDUR : FPDUR,
|
||||||
DURLEN : DURLEN,
|
DURLEN : DURLEN,
|
||||||
DIVb : DIVb,
|
DIVb : DIVb,
|
||||||
DIVBLEN : DIVBLEN,
|
DIVBLEN : DIVBLEN
|
||||||
DIVa : DIVa
|
|
||||||
};
|
};
|
||||||
|
@ -277,7 +277,6 @@ typedef struct packed {
|
|||||||
int DURLEN ;
|
int DURLEN ;
|
||||||
int DIVb ;
|
int DIVb ;
|
||||||
int DIVBLEN ;
|
int DIVBLEN ;
|
||||||
int DIVa ;
|
|
||||||
|
|
||||||
} cvw_t;
|
} cvw_t;
|
||||||
|
|
||||||
|
@ -110,7 +110,8 @@ module fdivsqrtpostproc import cvw::*; #(parameter cvw_t P) (
|
|||||||
mux2 #(P.DIVb+4) quotresmux(UnsignedQuotM, -UnsignedQuotM, NegQuotM, NormQuotM);
|
mux2 #(P.DIVb+4) quotresmux(UnsignedQuotM, -UnsignedQuotM, NegQuotM, NormQuotM);
|
||||||
|
|
||||||
// Select quotient or remainder and do normalization shift
|
// Select quotient or remainder and do normalization shift
|
||||||
mux2 #(P.DIVBLEN+1) normshiftmux(((P.DIVBLEN+1)'(P.DIVb) - (nM * (P.DIVBLEN+1)'(P.LOGR))), (mM + (P.DIVBLEN+1)'(P.DIVa)), RemOpM, NormShiftM);
|
localparam DIVa = (P.DIVb+1-P.XLEN); // used for idiv on fpu: Shift residual right by b - (XLEN-1) to put remainder in lsbs of integer result
|
||||||
|
mux2 #(P.DIVBLEN+1) normshiftmux(((P.DIVBLEN+1)'(P.DIVb) - (nM * (P.DIVBLEN+1)'(P.LOGR))), (mM + (P.DIVBLEN+1)'(DIVa)), RemOpM, NormShiftM);
|
||||||
mux2 #(P.DIVb+4) presresultmux(NormQuotM, NormRemM, RemOpM, PreResultM);
|
mux2 #(P.DIVb+4) presresultmux(NormQuotM, NormRemM, RemOpM, PreResultM);
|
||||||
assign PreIntResultM = $signed(PreResultM >>> NormShiftM);
|
assign PreIntResultM = $signed(PreResultM >>> NormShiftM);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ module fdivsqrtpreproc import cvw::*; #(parameter cvw_t P) (
|
|||||||
output logic [P.XLEN-1:0] AM
|
output logic [P.XLEN-1:0] AM
|
||||||
);
|
);
|
||||||
|
|
||||||
logic [P.DIVb-1:0] Xfract, Dfract;
|
logic [P.DIVb:0] Xfract, Dfract;
|
||||||
logic [P.DIVb:0] PreSqrtX;
|
logic [P.DIVb:0] PreSqrtX;
|
||||||
logic [P.DIVb+3:0] DivX, DivXShifted, SqrtX, PreShiftX; // Variations of dividend, to be muxed
|
logic [P.DIVb+3:0] DivX, DivXShifted, SqrtX, PreShiftX; // Variations of dividend, to be muxed
|
||||||
logic [P.NE+1:0] QeE; // Quotient Exponent (FP only)
|
logic [P.NE+1:0] QeE; // Quotient Exponent (FP only)
|
||||||
@ -103,12 +103,12 @@ module fdivsqrtpreproc import cvw::*; #(parameter cvw_t P) (
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
// count leading zeros for Subnorm FP and to normalize integer inputs
|
// count leading zeros for Subnorm FP and to normalize integer inputs
|
||||||
lzc #(P.DIVb) lzcX (IFX[P.DIVb:1], ell);
|
lzc #(P.DIVb+1) lzcX (IFX, ell);
|
||||||
lzc #(P.DIVb) lzcY (IFD[P.DIVb:1], mE);
|
lzc #(P.DIVb+1) lzcY (IFD, mE);
|
||||||
|
|
||||||
// Normalization shift: shift off leading one
|
// Normalization shift: shift off leading one
|
||||||
assign Xfract = (IFX[P.DIVb:1] << ell) << 1;
|
assign Xfract = (IFX << ell);
|
||||||
assign Dfract = (IFD[P.DIVb:1] << mE) << 1;
|
assign Dfract = (IFD << mE);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
// Integer Right Shift to digit boundary
|
// Integer Right Shift to digit boundary
|
||||||
@ -158,10 +158,10 @@ module fdivsqrtpreproc import cvw::*; #(parameter cvw_t P) (
|
|||||||
// it comes out in the wash and gives the right answer. Investigate later if possible.
|
// it comes out in the wash and gives the right answer. Investigate later if possible.
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
assign DivX = {3'b000, ~NumerZeroE, Xfract};
|
assign DivX = {3'b000, Xfract};
|
||||||
|
|
||||||
// Sqrt is initialized on step one as R(X-1), so depends on Radix
|
// Sqrt is initialized on step one as R(X-1), so depends on Radix
|
||||||
mux2 #(P.DIVb+1) sqrtxmux({~XZeroE, Xfract}, {1'b0, ~XZeroE, Xfract[P.DIVb-1:1]}, (Xe[0] ^ ell[0]), PreSqrtX);
|
mux2 #(P.DIVb+1) sqrtxmux(Xfract, {1'b0, Xfract[P.DIVb:1]}, (Xe[0] ^ ell[0]), PreSqrtX);
|
||||||
if (P.RADIX == 2) assign SqrtX = {3'b111, PreSqrtX};
|
if (P.RADIX == 2) assign SqrtX = {3'b111, PreSqrtX};
|
||||||
else assign SqrtX = {2'b11, PreSqrtX, 1'b0};
|
else assign SqrtX = {2'b11, PreSqrtX, 1'b0};
|
||||||
mux2 #(P.DIVb+4) prexmux(DivX, SqrtX, SqrtE, PreShiftX);
|
mux2 #(P.DIVb+4) prexmux(DivX, SqrtX, SqrtE, PreShiftX);
|
||||||
@ -176,8 +176,8 @@ module fdivsqrtpreproc import cvw::*; #(parameter cvw_t P) (
|
|||||||
assign X = PreShiftX;
|
assign X = PreShiftX;
|
||||||
end
|
end
|
||||||
|
|
||||||
// Divisior register
|
// Divisior register
|
||||||
flopen #(P.DIVb+4) dreg(clk, IFDivStartE, {4'b0001, Dfract}, D);
|
flopen #(P.DIVb+4) dreg(clk, IFDivStartE, {3'b000, Dfract}, D);
|
||||||
|
|
||||||
// Floating-point exponent
|
// Floating-point exponent
|
||||||
fdivsqrtexpcalc #(P) expcalc(.Fmt(FmtE), .Xe, .Ye, .Sqrt(SqrtE), .XZero(XZeroE), .ell, .m(mE), .Qe(QeE));
|
fdivsqrtexpcalc #(P) expcalc(.Fmt(FmtE), .Xe, .Ye, .Sqrt(SqrtE), .XZero(XZeroE), .ell, .m(mE), .Qe(QeE));
|
||||||
|
Loading…
Reference in New Issue
Block a user