started simplifying integer division special cases

This commit is contained in:
David Harris 2022-12-30 07:34:26 -08:00
parent 6ae25537ea
commit 1006305d75

View File

@ -111,6 +111,43 @@ module fdivsqrtpostproc(
mux2 #(`DIVb+4) normremdmux(W, W+DM, NegStickyM, NormRemDM); mux2 #(`DIVb+4) normremdmux(W, W+DM, NegStickyM, NormRemDM);
mux2 #(`DIVb+4) normremsmux(NormRemDM, -NormRemDM, AsM, NormRemM); mux2 #(`DIVb+4) normremsmux(NormRemDM, -NormRemDM, AsM, NormRemM);
// special case logic
always_comb
if (ALTBM) begin
if (RemOpM) PreFPIntDivResultM = {{(`DIVb-`XLEN+4){1'b0}}, AM};
else PreFPIntDivResultM = '0;
// IntQuotM = '0;
// IntRemM = {{(`DIVb-`XLEN+4){1'b0}}, AM};
end else begin
logic [`DIVb+3:0] PreIntQuotM;
if (WZeroM) begin
if (weq0M) begin
PreIntQuotM = {3'b000, FirstU};
IntRemM = '0;
end else begin
PreIntQuotM = {3'b000, FirstUM};
IntRemM = '0;
end
end else begin
PreIntQuotM = {3'b000, PreQmM};
IntRemM = NormRemM;
end
// flip sign if necessary
if (NegQuotM) IntQuotM = -PreIntQuotM;
else IntQuotM = PreIntQuotM;
if (RemOpM) begin
NormShiftM = ALTBM ? '0 : (mM + (`DIVBLEN+1)'(`DIVa)); // no postshift if forwarding input A to remainder
PreResultM = IntRemM;
end else begin
NormShiftM = ((`DIVBLEN+1)'(`DIVb) - (nM * (`DIVBLEN+1)'(`LOGR)));
PreResultM = IntQuotM;
end
PreFPIntDivResultM = $signed(PreResultM >>> NormShiftM);
end
assign SpecialFPIntDivResultM = BZeroM ? (RemOpM ? AM : {(`XLEN){1'b1}}) : PreFPIntDivResultM[`XLEN-1:0]; // special cases
/*
// Integer division: Special cases // Integer division: Special cases
always_comb always_comb
if (ALTBM) begin if (ALTBM) begin
@ -149,6 +186,7 @@ module fdivsqrtpostproc(
assign PreFPIntDivResultM = $signed(PreResultM >>> NormShiftM); assign PreFPIntDivResultM = $signed(PreResultM >>> NormShiftM);
assign SpecialFPIntDivResultM = BZeroM ? (RemOpM ? AM : {(`XLEN){1'b1}}) : PreFPIntDivResultM[`XLEN-1:0]; // special cases assign SpecialFPIntDivResultM = BZeroM ? (RemOpM ? AM : {(`XLEN){1'b1}}) : PreFPIntDivResultM[`XLEN-1:0]; // special cases
*/
// sign extend result for W64 // sign extend result for W64
if (`XLEN==64) if (`XLEN==64)