mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
postprocessor shift amount simplification
This commit is contained in:
parent
3284dd2112
commit
e02c1008bc
@ -28,10 +28,8 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
module divshiftcalc import cvw::*; #(parameter cvw_t P) (
|
module divshiftcalc import cvw::*; #(parameter cvw_t P) (
|
||||||
input logic [P.DIVb:0] DivUm, // divsqrt significand
|
|
||||||
input logic [P.NE+1:0] DivUe, // divsqrt exponent
|
input logic [P.NE+1:0] DivUe, // divsqrt exponent
|
||||||
output logic [P.LOGNORMSHIFTSZ-1:0] DivShiftAmt, // divsqrt shift amount
|
output logic [P.LOGNORMSHIFTSZ-1:0] DivShiftAmt, // divsqrt shift amount
|
||||||
output logic [P.NORMSHIFTSZ-1:0] DivShiftIn, // divsqrt shift input
|
|
||||||
output logic DivResSubnorm, // is the divsqrt result subnormal
|
output logic DivResSubnorm, // is the divsqrt result subnormal
|
||||||
output logic DivSubnormShiftPos // is the subnormal shift amount positive
|
output logic DivSubnormShiftPos // is the subnormal shift amount positive
|
||||||
);
|
);
|
||||||
@ -68,6 +66,4 @@ module divshiftcalc import cvw::*; #(parameter cvw_t P) (
|
|||||||
assign DivSubnormShiftAmt = DivSubnormShiftPos ? DivSubnormShift[P.LOGNORMSHIFTSZ-1:0] : '0;
|
assign DivSubnormShiftAmt = DivSubnormShiftPos ? DivSubnormShift[P.LOGNORMSHIFTSZ-1:0] : '0;
|
||||||
assign DivShiftAmt = DivResSubnorm ? DivSubnormShiftAmt : NormShift;
|
assign DivShiftAmt = DivResSubnorm ? DivSubnormShiftAmt : NormShift;
|
||||||
|
|
||||||
// pre-shift the divider result for normalization
|
|
||||||
assign DivShiftIn = {{P.NF{1'b0}}, DivUm, {P.NORMSHIFTSZ-P.DIVb-1-P.NF{1'b0}}};
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -53,6 +53,7 @@ module fmashiftcalc import cvw::*; #(parameter cvw_t P) (
|
|||||||
//convert the sum's exponent into the proper precision
|
//convert the sum's exponent into the proper precision
|
||||||
if (P.FPSIZES == 1) begin
|
if (P.FPSIZES == 1) begin
|
||||||
assign NormSumExp = PreNormSumExp;
|
assign NormSumExp = PreNormSumExp;
|
||||||
|
assign BiasCorr = '0;
|
||||||
end else if (P.FPSIZES == 2) begin
|
end else if (P.FPSIZES == 2) begin
|
||||||
assign BiasCorr = Fmt ? (P.NE+2)'(0) : (P.NE+2)'(P.BIAS1-P.BIAS);
|
assign BiasCorr = Fmt ? (P.NE+2)'(0) : (P.NE+2)'(P.BIAS1-P.BIAS);
|
||||||
assign NormSumExp = PreNormSumExp+BiasCorr;
|
assign NormSumExp = PreNormSumExp+BiasCorr;
|
||||||
@ -129,6 +130,5 @@ module fmashiftcalc import cvw::*; #(parameter cvw_t P) (
|
|||||||
|
|
||||||
// set and calculate the shift input and amount
|
// set and calculate the shift input and amount
|
||||||
// - shift once if killing a product and the result is subnormal
|
// - shift once if killing a product and the result is subnormal
|
||||||
if (P.FPSIZES == 1) assign FmaShiftAmt = FmaPreResultSubnorm ? FmaSe[$clog2(P.FMALEN-1)-1:0]+($clog2(P.FMALEN-1))'(P.NF+3): FmaSCnt+1;
|
assign FmaShiftAmt = FmaPreResultSubnorm ? FmaSe[$clog2(P.FMALEN-1)-1:0]+($clog2(P.FMALEN-1))'(P.NF+3)+BiasCorr[$clog2(P.FMALEN-1)-1:0]: FmaSCnt+1;
|
||||||
else assign FmaShiftAmt = FmaPreResultSubnorm ? FmaSe[$clog2(P.FMALEN-1)-1:0]+($clog2(P.FMALEN-1))'(P.NF+3)+BiasCorr[$clog2(P.FMALEN-1)-1:0]: FmaSCnt+1;
|
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -91,7 +91,6 @@ module postprocess import cvw::*; #(parameter cvw_t P) (
|
|||||||
logic [$clog2(P.FMALEN+1)-1:0] FmaShiftAmt; // normalization shift amount for fma
|
logic [$clog2(P.FMALEN+1)-1:0] FmaShiftAmt; // normalization shift amount for fma
|
||||||
// division signals
|
// division signals
|
||||||
logic [P.LOGNORMSHIFTSZ-1:0] DivShiftAmt; // divsqrt shif amount
|
logic [P.LOGNORMSHIFTSZ-1:0] DivShiftAmt; // divsqrt shif amount
|
||||||
logic [P.NORMSHIFTSZ-1:0] DivShiftIn; // divsqrt shift input
|
|
||||||
logic [P.NE+1:0] Ue; // divsqrt corrected exponent after corretion shift
|
logic [P.NE+1:0] Ue; // divsqrt corrected exponent after corretion shift
|
||||||
logic DivByZero; // divide by zero flag
|
logic DivByZero; // divide by zero flag
|
||||||
logic DivResSubnorm; // is the divsqrt result subnormal
|
logic DivResSubnorm; // is the divsqrt result subnormal
|
||||||
@ -147,7 +146,7 @@ module postprocess import cvw::*; #(parameter cvw_t P) (
|
|||||||
fmashiftcalc #(P) fmashiftcalc(.FmaSCnt, .Fmt, .NormSumExp, .FmaSe, .FmaSm,
|
fmashiftcalc #(P) fmashiftcalc(.FmaSCnt, .Fmt, .NormSumExp, .FmaSe, .FmaSm,
|
||||||
.FmaSZero, .FmaPreResultSubnorm, .FmaShiftAmt);
|
.FmaSZero, .FmaPreResultSubnorm, .FmaShiftAmt);
|
||||||
|
|
||||||
divshiftcalc #(P) divshiftcalc(.DivUe, .DivUm, .DivResSubnorm, .DivSubnormShiftPos, .DivShiftAmt, .DivShiftIn);
|
divshiftcalc #(P) divshiftcalc(.DivUe, .DivResSubnorm, .DivSubnormShiftPos, .DivShiftAmt);
|
||||||
|
|
||||||
// select which unit's output to shift
|
// select which unit's output to shift
|
||||||
always_comb
|
always_comb
|
||||||
@ -162,7 +161,7 @@ module postprocess import cvw::*; #(parameter cvw_t P) (
|
|||||||
end
|
end
|
||||||
2'b01: begin //divsqrt
|
2'b01: begin //divsqrt
|
||||||
ShiftAmt = DivShiftAmt;
|
ShiftAmt = DivShiftAmt;
|
||||||
ShiftIn = DivShiftIn;
|
ShiftIn = {{P.NF{1'b0}}, DivUm, {P.NORMSHIFTSZ-P.DIVb-1-P.NF{1'b0}}};
|
||||||
end
|
end
|
||||||
default: begin
|
default: begin
|
||||||
ShiftAmt = {P.LOGNORMSHIFTSZ{1'bx}};
|
ShiftAmt = {P.LOGNORMSHIFTSZ{1'bx}};
|
||||||
|
Loading…
Reference in New Issue
Block a user