mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
clean up divshiftcalc
This commit is contained in:
parent
f5083803c2
commit
d3b2a192eb
@ -8,11 +8,10 @@ module divshiftcalc(
|
|||||||
output logic [`LOGNORMSHIFTSZ-1:0] DivShiftAmt,
|
output logic [`LOGNORMSHIFTSZ-1:0] DivShiftAmt,
|
||||||
output logic [`NORMSHIFTSZ-1:0] DivShiftIn,
|
output logic [`NORMSHIFTSZ-1:0] DivShiftIn,
|
||||||
output logic DivResDenorm,
|
output logic DivResDenorm,
|
||||||
output logic [`NE+1:0] DivDenormShift
|
output logic DivDenormShiftPos
|
||||||
);
|
);
|
||||||
logic [`LOGNORMSHIFTSZ-1:0] NormShift, DivDenormShiftAmt;
|
logic [`LOGNORMSHIFTSZ-1:0] NormShift, DivDenormShiftAmt;
|
||||||
//logic [`NE+1:0] DivDenormShift;
|
logic [`NE+1:0] DivDenormShift;
|
||||||
logic DivDenormShiftPos;
|
|
||||||
|
|
||||||
logic [`DURLEN-1:0] DivEarlyTermShift = 0;
|
logic [`DURLEN-1:0] DivEarlyTermShift = 0;
|
||||||
|
|
||||||
@ -38,9 +37,10 @@ module divshiftcalc(
|
|||||||
// inital Left shift amount = NF
|
// inital Left shift amount = NF
|
||||||
// shift one more if the it's a minimally redundent radix 4 - one entire cycle needed for integer bit
|
// shift one more if the it's a minimally redundent radix 4 - one entire cycle needed for integer bit
|
||||||
assign NormShift = (`LOGNORMSHIFTSZ)'(`NF);
|
assign NormShift = (`LOGNORMSHIFTSZ)'(`NF);
|
||||||
|
|
||||||
// if the shift amount is negitive then don't shift (keep sticky bit)
|
// if the shift amount is negitive then don't shift (keep sticky bit)
|
||||||
// need to multiply the early termination shift by LOGR*DIVCOPIES = left shift of log2(LOGR*DIVCOPIES)
|
// need to multiply the early termination shift by LOGR*DIVCOPIES = left shift of log2(LOGR*DIVCOPIES)
|
||||||
assign DivDenormShiftAmt = DivDenormShift[`LOGNORMSHIFTSZ-1:0]&{`LOGNORMSHIFTSZ{DivDenormShiftPos}};
|
assign DivDenormShiftAmt = DivDenormShiftPos ? DivDenormShift[`LOGNORMSHIFTSZ-1:0] : '0;
|
||||||
assign DivShiftAmt = DivResDenorm ? DivDenormShiftAmt : NormShift;
|
assign DivShiftAmt = DivResDenorm ? DivDenormShiftAmt : NormShift;
|
||||||
|
|
||||||
assign DivShiftIn = {{`NF{1'b0}}, DivQm, {`NORMSHIFTSZ-`DIVb+1+(`RADIX/4)-`NF{1'b0}}};
|
assign DivShiftIn = {{`NF{1'b0}}, DivQm, {`NORMSHIFTSZ-`DIVb+1+(`RADIX/4)-`NF{1'b0}}};
|
||||||
|
@ -103,7 +103,7 @@ module postprocess (
|
|||||||
logic [`NE+1:0] Qe;
|
logic [`NE+1:0] Qe;
|
||||||
logic DivByZero;
|
logic DivByZero;
|
||||||
logic DivResDenorm;
|
logic DivResDenorm;
|
||||||
logic [`NE+1:0] DivDenormShift;
|
logic DivDenormShiftPos;
|
||||||
// conversion signals
|
// conversion signals
|
||||||
logic [`CVTLEN+`NF:0] CvtShiftIn; // number to be shifted
|
logic [`CVTLEN+`NF:0] CvtShiftIn; // number to be shifted
|
||||||
logic [1:0] CvtNegResMsbs;
|
logic [1:0] CvtNegResMsbs;
|
||||||
@ -151,7 +151,7 @@ module postprocess (
|
|||||||
.XZero, .IntToFp, .OutFmt, .CvtResUf, .CvtShiftIn);
|
.XZero, .IntToFp, .OutFmt, .CvtResUf, .CvtShiftIn);
|
||||||
fmashiftcalc fmashiftcalc(.FmaSm, .Ze, .FmaPe, .FmaSCnt, .Fmt, .FmaKillProd, .NormSumExp, .FmaSe,
|
fmashiftcalc fmashiftcalc(.FmaSm, .Ze, .FmaPe, .FmaSCnt, .Fmt, .FmaKillProd, .NormSumExp, .FmaSe,
|
||||||
.FmaSZero, .FmaPreResultDenorm, .FmaShiftAmt, .FmaShiftIn);
|
.FmaSZero, .FmaPreResultDenorm, .FmaShiftAmt, .FmaShiftIn);
|
||||||
divshiftcalc divshiftcalc(.Fmt, .Sqrt, .DivQe, .DivQm, .DivResDenorm, .DivDenormShift, .DivShiftAmt, .DivShiftIn);
|
divshiftcalc divshiftcalc(.Fmt, .Sqrt, .DivQe, .DivQm, .DivResDenorm, .DivDenormShiftPos, .DivShiftAmt, .DivShiftIn);
|
||||||
|
|
||||||
always_comb
|
always_comb
|
||||||
case(PostProcSel)
|
case(PostProcSel)
|
||||||
@ -181,7 +181,7 @@ module postprocess (
|
|||||||
normshift normshift (.ShiftIn, .ShiftAmt, .Shifted);
|
normshift normshift (.ShiftIn, .ShiftAmt, .Shifted);
|
||||||
|
|
||||||
shiftcorrection shiftcorrection(.FmaOp, .FmaPreResultDenorm, .NormSumExp,
|
shiftcorrection shiftcorrection(.FmaOp, .FmaPreResultDenorm, .NormSumExp,
|
||||||
.DivResDenorm, .DivDenormShift, .DivOp, .DivQe,
|
.DivResDenorm, .DivDenormShiftPos, .DivOp, .DivQe,
|
||||||
.Qe, .FmaSZero, .Shifted, .FmaMe, .Mf);
|
.Qe, .FmaSZero, .Shifted, .FmaMe, .Mf);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -34,7 +34,7 @@ module shiftcorrection(
|
|||||||
input logic DivOp,
|
input logic DivOp,
|
||||||
input logic DivResDenorm,
|
input logic DivResDenorm,
|
||||||
input logic [`NE+1:0] DivQe,
|
input logic [`NE+1:0] DivQe,
|
||||||
input logic [`NE+1:0] DivDenormShift,
|
input logic DivDenormShiftPos,
|
||||||
input logic [`NE+1:0] NormSumExp, // exponent of the normalized sum not taking into account denormal or zero results
|
input logic [`NE+1:0] NormSumExp, // exponent of the normalized sum not taking into account denormal or zero results
|
||||||
input logic FmaPreResultDenorm, // is the result denormalized - calculated before LZA corection
|
input logic FmaPreResultDenorm, // is the result denormalized - calculated before LZA corection
|
||||||
input logic FmaSZero,
|
input logic FmaSZero,
|
||||||
@ -66,5 +66,5 @@ module shiftcorrection(
|
|||||||
|
|
||||||
// the quotent is in the range [.5,2) if there is no early termination
|
// the quotent is in the range [.5,2) if there is no early termination
|
||||||
// if the quotent < 1 and not denormal then subtract 1 to account for the normalization shift
|
// if the quotent < 1 and not denormal then subtract 1 to account for the normalization shift
|
||||||
assign Qe = ((DivResDenorm)&~DivDenormShift[`NE+1]) ? (`NE+2)'(0) : DivQe - {(`NE+1)'(0), ~LZAPlus1};
|
assign Qe = (DivResDenorm & DivDenormShiftPos) ? '0 : DivQe - {(`NE+1)'(0), ~LZAPlus1};
|
||||||
endmodule
|
endmodule
|
Loading…
Reference in New Issue
Block a user