forked from Github_Repos/cvw
radix 4 division denormal result handeling
This commit is contained in:
parent
2929422614
commit
a65c0eb679
@ -4,12 +4,20 @@ module divshiftcalc(
|
|||||||
input logic [`DIVLEN+2:0] Quot,
|
input logic [`DIVLEN+2:0] Quot,
|
||||||
input logic [`NE+1:0] DivCalcExpM,
|
input logic [`NE+1:0] DivCalcExpM,
|
||||||
output logic [$clog2(`NORMSHIFTSZ)-1:0] DivShiftAmt,
|
output logic [$clog2(`NORMSHIFTSZ)-1:0] DivShiftAmt,
|
||||||
|
output logic [`NORMSHIFTSZ-1:0] DivShiftIn,
|
||||||
output logic [`NE+1:0] CorrDivExp
|
output logic [`NE+1:0] CorrDivExp
|
||||||
);
|
);
|
||||||
|
logic ResDenorm;
|
||||||
|
logic [`NE+1:0] DenormShift;
|
||||||
|
logic [`NE+1:0] NormShift;
|
||||||
|
assign ResDenorm = DivCalcExpM[`NE+1];
|
||||||
|
assign DenormShift = (`NE+2)'(`NF-1)+DivCalcExpM;
|
||||||
|
assign NormShift = {(`NE+1)'(0), ~Quot[`DIVLEN+2]} + (`NE+2)'(`NF);
|
||||||
|
assign DivShiftAmt = ResDenorm ? DenormShift[$clog2(`NORMSHIFTSZ)-1:0] : NormShift[$clog2(`NORMSHIFTSZ)-1:0];
|
||||||
|
|
||||||
assign DivShiftAmt = {{$clog2(`NORMSHIFTSZ)-1{1'b0}}, ~Quot[`DIVLEN+2]};
|
assign DivShiftIn = {(`NF)'(0), Quot[`DIVLEN+1:0], {`NORMSHIFTSZ-`DIVLEN-2-`NF{1'b0}}};
|
||||||
// the quotent is in the range [.5,2)
|
// the quotent is in the range [.5,2)
|
||||||
// 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 CorrDivExp = DivCalcExpM - {(`NE)'(0), ~Quot[`DIVLEN+2]};
|
assign CorrDivExp = (ResDenorm&~DenormShift[`NE+1]) ? (`NE+2)'(0) : DivCalcExpM - {(`NE+1)'(0), ~Quot[`DIVLEN+2]};
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -88,6 +88,7 @@ module postprocess(
|
|||||||
logic [$clog2(`NORMSHIFTSZ)-1:0] ShiftAmt; // normalization shift count
|
logic [$clog2(`NORMSHIFTSZ)-1:0] ShiftAmt; // normalization shift count
|
||||||
logic [$clog2(`NORMSHIFTSZ)-1:0] DivShiftAmt;
|
logic [$clog2(`NORMSHIFTSZ)-1:0] DivShiftAmt;
|
||||||
logic [`NORMSHIFTSZ-1:0] ShiftIn; // is the sum zero
|
logic [`NORMSHIFTSZ-1:0] ShiftIn; // is the sum zero
|
||||||
|
logic [`NORMSHIFTSZ-1:0] DivShiftIn;
|
||||||
logic [`NORMSHIFTSZ-1:0] Shifted; // the shifted result
|
logic [`NORMSHIFTSZ-1:0] Shifted; // the shifted result
|
||||||
logic Plus1; // add one to the final result?
|
logic Plus1; // add one to the final result?
|
||||||
logic IntInvalid, Overflow, Underflow, Invalid; // flags
|
logic IntInvalid, Overflow, Underflow, Invalid; // flags
|
||||||
@ -142,7 +143,7 @@ module postprocess(
|
|||||||
.XZeroM, .IntToFp, .OutFmt, .CvtResUf, .CvtShiftIn);
|
.XZeroM, .IntToFp, .OutFmt, .CvtResUf, .CvtShiftIn);
|
||||||
fmashiftcalc fmashiftcalc(.SumM, .ZExpM, .ProdExpM, .FmaNormCntM, .FmtM, .KillProdM, .ConvNormSumExp,
|
fmashiftcalc fmashiftcalc(.SumM, .ZExpM, .ProdExpM, .FmaNormCntM, .FmtM, .KillProdM, .ConvNormSumExp,
|
||||||
.ZDenormM, .SumZero, .PreResultDenorm, .FmaShiftAmt, .FmaShiftIn);
|
.ZDenormM, .SumZero, .PreResultDenorm, .FmaShiftAmt, .FmaShiftIn);
|
||||||
divshiftcalc divshiftcalc(.Quot, .DivCalcExpM, .CorrDivExp, .DivShiftAmt);
|
divshiftcalc divshiftcalc(.Quot, .DivCalcExpM, .CorrDivExp, .DivShiftAmt, .DivShiftIn);
|
||||||
|
|
||||||
always_comb
|
always_comb
|
||||||
case(PostProcSelM)
|
case(PostProcSelM)
|
||||||
@ -156,7 +157,7 @@ module postprocess(
|
|||||||
end
|
end
|
||||||
2'b01: begin //div ***prob can take out
|
2'b01: begin //div ***prob can take out
|
||||||
ShiftAmt = DivShiftAmt;
|
ShiftAmt = DivShiftAmt;
|
||||||
ShiftIn = {Quot[`DIVLEN+1:0], {`NORMSHIFTSZ-`DIVLEN-2{1'b0}}};
|
ShiftIn = DivShiftIn;
|
||||||
end
|
end
|
||||||
default: begin
|
default: begin
|
||||||
ShiftAmt = {$clog2(`NORMSHIFTSZ){1'bx}};
|
ShiftAmt = {$clog2(`NORMSHIFTSZ){1'bx}};
|
||||||
|
@ -372,6 +372,6 @@ module expcalc(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// correct exponent for denormal shifts
|
// correct exponent for denormal shifts
|
||||||
assign DivCalcExp = (XExpE - XZeroCnt - YExpE + YZeroCnt + (`NE)'(`BIAS))&{`NE+1{~XZeroE}};
|
assign DivCalcExp = (XExpE - XZeroCnt - YExpE + YZeroCnt + (`NE)'(`BIAS))&{`NE+2{~XZeroE}};
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user