forked from Github_Repos/cvw
Merge branch 'main' of github.com:davidharrishmc/riscv-wally into main
This commit is contained in:
commit
3fbacc2339
@ -45,12 +45,13 @@ module fdivsqrtpostproc(
|
|||||||
output logic DivSM
|
output logic DivSM
|
||||||
);
|
);
|
||||||
|
|
||||||
logic [`DIVb+3:0] W, Sum;
|
logic [`DIVb+3:0] W, Sum, RemD;
|
||||||
logic [`DIVb:0] PreQmM;
|
logic [`DIVb:0] PreQmM;
|
||||||
logic NegSticky, PostInc;
|
logic NegSticky, PostInc;
|
||||||
logic weq0;
|
logic weq0;
|
||||||
logic [`DIVBLEN:0] NormShift;
|
logic [`DIVBLEN:0] NormShift;
|
||||||
logic [`DIVb:0] IntQuot, IntRem, NormQuot, NormRem;
|
logic [`DIVb:0] IntQuot, NormQuot;
|
||||||
|
logic [`DIVb+3:0] IntRem, NormRem;
|
||||||
logic [`DIVb:0] PreResult, Result;
|
logic [`DIVb:0] PreResult, Result;
|
||||||
|
|
||||||
// check for early termination on an exact result. If the result is not exact, the sticky should be set
|
// check for early termination on an exact result. If the result is not exact, the sticky should be set
|
||||||
@ -76,66 +77,66 @@ module fdivsqrtpostproc(
|
|||||||
assign Sum = WC + WS;
|
assign Sum = WC + WS;
|
||||||
assign W = $signed(Sum) >>> `LOGR;
|
assign W = $signed(Sum) >>> `LOGR;
|
||||||
assign NegSticky = W[`DIVb+3];
|
assign NegSticky = W[`DIVb+3];
|
||||||
assign RemD = {4'b0000, D, {(`DIVb-`DIVN){1'b0}}};
|
assign RemD = {4'b0000, D, {(`DIVb-`DIVN+1){1'b0}}};
|
||||||
|
|
||||||
always_comb
|
always_comb
|
||||||
if (~As)
|
if (~As)
|
||||||
if (NegSticky) begin
|
if (NegSticky) begin
|
||||||
assign NormQuot = FirstUM;
|
NormQuot = FirstUM;
|
||||||
assign NormRem = W + RemD;
|
NormRem = W + RemD;
|
||||||
assign PostInc = 0;
|
PostInc = 0;
|
||||||
end else begin
|
end else begin
|
||||||
assign NormQuot = FirstU;
|
NormQuot = FirstU;
|
||||||
assign NormRem = W;
|
NormRem = W;
|
||||||
assign PostInc = 0;
|
PostInc = 0;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (NegSticky | weq0) begin
|
if (NegSticky | weq0) begin
|
||||||
assign NormQuot = FirstU;
|
NormQuot = FirstU;
|
||||||
assign NormRem = W;
|
NormRem = W;
|
||||||
assign PostInc = 0;
|
PostInc = 0;
|
||||||
end else begin
|
end else begin
|
||||||
assign NormQuot = FirstU;
|
NormQuot = FirstU;
|
||||||
assign NormRem = W - RemD;
|
NormRem = W - RemD;
|
||||||
assign PostInc = 1;
|
PostInc = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
always_comb
|
always_comb
|
||||||
if(ALTB) begin
|
if(ALTB) begin
|
||||||
assign IntQuot = '0;
|
IntQuot = '0;
|
||||||
assign IntRem = ForwardedSrcAE;
|
IntRem = ForwardedSrcAE;
|
||||||
end else if (BZero) begin
|
end else if (BZero) begin
|
||||||
assign IntQuot = '1;
|
IntQuot = '1;
|
||||||
assign IntRem = ForwardedSrcAE;
|
IntRem = ForwardedSrcAE;
|
||||||
end else if (EarlyTerm) begin
|
end else if (EarlyTerm) begin
|
||||||
if (weq0) begin
|
if (weq0) begin
|
||||||
assign IntQuot = FirstU;
|
IntQuot = FirstU;
|
||||||
assign IntRem = '0;
|
IntRem = '0;
|
||||||
end else begin
|
end else begin
|
||||||
assign IntQuot = FirstUM;
|
IntQuot = FirstUM;
|
||||||
assign IntRem = '0;
|
IntRem = '0;
|
||||||
end
|
end
|
||||||
end else begin
|
end else begin
|
||||||
assign IntQuot = NormQuot;
|
IntQuot = NormQuot;
|
||||||
assign IntRem = NormRem;
|
IntRem = NormRem;
|
||||||
end
|
end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
always_comb
|
always_comb
|
||||||
if (RemOp) begin
|
if (RemOp) begin
|
||||||
assign NormShift = m + (`DIVBLEN)'(`DIVa);
|
NormShift = m + (`DIVBLEN)'(`DIVa);
|
||||||
assign PreResult = IntRem;
|
PreResult = IntRem;
|
||||||
end else begin
|
end else begin
|
||||||
assign NormShift = DIVb - (j << `LOGR);
|
NormShift = DIVb - (j << `LOGR);
|
||||||
assign PreResult = IntQuot;
|
PreResult = IntQuot;
|
||||||
end
|
end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// division takes the result from the next cycle, which is shifted to the left one more time so the square root also needs to be shifted
|
// division takes the result from the next cycle, which is shifted to the left one more time so the square root also needs to be shifted
|
||||||
|
|
||||||
assign Result = ($signed(PreResult) >>> NormShift) + (PostInc & ~RemOp);
|
// assign Result = ($signed(PreResult) >>> NormShift) + (PostInc & ~RemOp);
|
||||||
|
|
||||||
assign PreQmM = NegSticky ? FirstUM : FirstU; // Select U or U-1 depending on negative sticky bit
|
assign PreQmM = NegSticky ? FirstUM : FirstU; // Select U or U-1 depending on negative sticky bit
|
||||||
assign QmM = SqrtM ? (PreQmM << 1) : PreQmM;
|
assign QmM = SqrtM ? (PreQmM << 1) : PreQmM;
|
||||||
|
Loading…
Reference in New Issue
Block a user