From b7e2f349661c0f5a3d474e1dd88eccdcd100264a Mon Sep 17 00:00:00 2001 From: David Harris Date: Wed, 12 Jun 2024 03:59:55 -0700 Subject: [PATCH] shiftcorrection cleanup --- src/fpu/postproc/postprocess.sv | 4 ++-- src/fpu/postproc/shiftcorrection.sv | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fpu/postproc/postprocess.sv b/src/fpu/postproc/postprocess.sv index 2db03cb16..1ce993c33 100644 --- a/src/fpu/postproc/postprocess.sv +++ b/src/fpu/postproc/postprocess.sv @@ -157,11 +157,11 @@ module postprocess import cvw::*; #(parameter cvw_t P) ( end 2'b00: begin // cvt ShiftAmt = {{P.LOGNORMSHIFTSZ-$clog2(P.CVTLEN+1){1'b0}}, CvtShiftAmt}; - ShiftIn = {CvtShiftIn, {P.NORMSHIFTSZ-P.CVTLEN-P.NF-1{1'b0}}}; + ShiftIn = {CvtShiftIn, {P.NORMSHIFTSZ-(P.CVTLEN+P.NF+1){1'b0}}}; end 2'b01: begin //divsqrt ShiftAmt = DivShiftAmt; - ShiftIn = {{P.NF{1'b0}}, DivUm, {P.NORMSHIFTSZ-P.DIVb-1-P.NF{1'b0}}}; + ShiftIn = {{P.NF{1'b0}}, DivUm, {P.NORMSHIFTSZ-(P.DIVb+1+P.NF){1'b0}}}; end default: begin ShiftAmt = {P.LOGNORMSHIFTSZ{1'bx}}; diff --git a/src/fpu/postproc/shiftcorrection.sv b/src/fpu/postproc/shiftcorrection.sv index ad811a747..0f366a4b4 100644 --- a/src/fpu/postproc/shiftcorrection.sv +++ b/src/fpu/postproc/shiftcorrection.sv @@ -69,12 +69,14 @@ module shiftcorrection import cvw::*; #(parameter cvw_t P) ( assign RightShift = FmaOp ? LZAPlus1 : LeftShiftQm; // one bit right shift for FMA or division - mux2 #(P.NORMSHIFTSZ) corrmux({Shifted[P.NORMSHIFTSZ-3:0], 2'b00}, {Shifted[P.NORMSHIFTSZ-2:1], 2'b00}, RightShift, CorrShifted); +// mux2 #(P.NORMSHIFTSZ) corrmux({Shifted[P.NORMSHIFTSZ-3:0], 2'b00}, {Shifted[P.NORMSHIFTSZ-2:1], 2'b00}, RightShift, CorrShifted); // if the result of the divider was calculated to be subnormal, then the result was correctly normalized, so select the top shifted bits always_comb - if (FmaOp | (DivOp & ~DivResSubnorm)) Mf = CorrShifted; - else Mf = Shifted[P.NORMSHIFTSZ-1:0]; + if (FmaOp | (DivOp & ~DivResSubnorm)) // one bit shift for FMA or division + if (RightShift) Mf = {Shifted[P.NORMSHIFTSZ-2:1], 2'b00}; + else Mf = {Shifted[P.NORMSHIFTSZ-3:0], 2'b00}; + else Mf = Shifted[P.NORMSHIFTSZ-1:0]; // convert and subnormal division result // Determine sum's exponent // main exponent issues: