mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Continued simplifying fdivsqrt postprocessing
This commit is contained in:
parent
9e7926e8d7
commit
b0ff3a0952
@ -59,9 +59,7 @@ module fdivsqrt(
|
|||||||
logic [`DIVb:0] X;
|
logic [`DIVb:0] X;
|
||||||
logic [`DIVN-2:0] D; // U0.N-1
|
logic [`DIVN-2:0] D; // U0.N-1
|
||||||
logic [`DIVN-2:0] Dpreproc;
|
logic [`DIVN-2:0] Dpreproc;
|
||||||
logic [`DIVb:0] LastSM;
|
logic [`DIVb:0] FirstS, FirstSM, FirstQ, FirstQM;
|
||||||
logic [`DIVb-1:0] LastC;
|
|
||||||
logic [`DIVb:0] FirstSM;
|
|
||||||
logic [`DIVb-1:0] FirstC;
|
logic [`DIVb-1:0] FirstC;
|
||||||
logic [`DURLEN-1:0] Dur;
|
logic [`DURLEN-1:0] Dur;
|
||||||
logic NegSticky;
|
logic NegSticky;
|
||||||
@ -72,14 +70,14 @@ module fdivsqrt(
|
|||||||
.clk, .DivStart(DivStartE), .Xm(XmE), .QeM, .Xe(XeE), .Fmt(FmtE), .Ye(YeE),
|
.clk, .DivStart(DivStartE), .Xm(XmE), .QeM, .Xe(XeE), .Fmt(FmtE), .Ye(YeE),
|
||||||
.Sqrt(SqrtE), .Dur, .Ym(YmE), .XZero(XZeroE), .X, .Dpreproc);
|
.Sqrt(SqrtE), .Dur, .Ym(YmE), .XZero(XZeroE), .X, .Dpreproc);
|
||||||
fdivsqrtfsm fdivsqrtfsm(
|
fdivsqrtfsm fdivsqrtfsm(
|
||||||
.reset, .qn, .LastSM, .LastC, .FirstSM, .FirstC, .D, .XsE, .SqrtE, .SqrtM, .NextWSN, .NextWCN,
|
.reset, .qn, .D, .XsE, .SqrtE, .SqrtM, .NextWSN, .NextWCN,
|
||||||
.WS, .WC, .Dur, .DivBusy, .clk, .DivStart(DivStartE),.StallE, .StallM, .DivDone, .XZeroE, .YZeroE,
|
.WS, .WC, .Dur, .DivBusy, .clk, .DivStart(DivStartE),.StallE, .StallM, .DivDone, .XZeroE, .YZeroE,
|
||||||
.XNaNE, .YNaNE,
|
.XNaNE, .YNaNE,
|
||||||
.StickyWSA, .XInfE, .YInfE, .EarlyTermShiftE(EarlyTermShiftM), .WZero);
|
.XInfE, .YInfE, .EarlyTermShiftE(EarlyTermShiftM), .WZero);
|
||||||
fdivsqrtiter fdivsqrtiter(
|
fdivsqrtiter fdivsqrtiter(
|
||||||
.clk, .qn, .D, .LastSM, .LastC, .FirstSM, .FirstC, .SqrtE, .SqrtM,
|
.clk, .qn, .D, .FirstS, .FirstSM, .FirstQ, .FirstQM, .FirstC, .SqrtE, .SqrtM,
|
||||||
.X,.Dpreproc, .NegSticky, .FirstWS(WS), .FirstWC(WC), .NextWSN, .NextWCN,
|
.X,.Dpreproc, .FirstWS(WS), .FirstWC(WC), .NextWSN, .NextWCN,
|
||||||
.DivStart(DivStartE), .Xe(XeE), .Ye(YeE), .XZeroE, .YZeroE,
|
.DivStart(DivStartE), .Xe(XeE), .Ye(YeE), .XZeroE, .YZeroE,
|
||||||
.StickyWSA, .DivBusy, .Qm(QmM));
|
.DivBusy);
|
||||||
fdivsqrtpostproc fdivsqrtpostproc(.WS, .WC, .D, .FirstSM, .FirstC, .qn, .SqrtM, .WZero, .DivSM, .NegSticky);
|
fdivsqrtpostproc fdivsqrtpostproc(.WS, .WC, .D, .FirstS, .FirstSM, .FirstQ, .FirstQM, .FirstC, .qn, .SqrtM, .QmM, .WZero, .DivSM);
|
||||||
endmodule
|
endmodule
|
@ -44,12 +44,7 @@ module fdivsqrtfsm(
|
|||||||
input logic StallE,
|
input logic StallE,
|
||||||
input logic StallM,
|
input logic StallM,
|
||||||
input logic [`DIVN-2:0] D, // U0.N-1
|
input logic [`DIVN-2:0] D, // U0.N-1
|
||||||
input logic [`DIVb+3:0] StickyWSA,
|
|
||||||
input logic [`DURLEN-1:0] Dur,
|
input logic [`DURLEN-1:0] Dur,
|
||||||
input logic [`DIVb:0] LastSM,
|
|
||||||
input logic [`DIVb:0] FirstSM,
|
|
||||||
input logic [`DIVb-1:0] LastC,
|
|
||||||
input logic [`DIVb-1:0] FirstC,
|
|
||||||
input logic [`DIVCOPIES-1:0] qn,
|
input logic [`DIVCOPIES-1:0] qn,
|
||||||
input logic WZero,
|
input logic WZero,
|
||||||
output logic [`DURLEN-1:0] EarlyTermShiftE,
|
output logic [`DURLEN-1:0] EarlyTermShiftE,
|
||||||
|
@ -40,14 +40,10 @@ module fdivsqrtiter(
|
|||||||
input logic SqrtM,
|
input logic SqrtM,
|
||||||
input logic [`DIVb:0] X,
|
input logic [`DIVb:0] X,
|
||||||
input logic [`DIVN-2:0] Dpreproc,
|
input logic [`DIVN-2:0] Dpreproc,
|
||||||
input logic NegSticky,
|
|
||||||
output logic [`DIVb-(`RADIX/4):0] Qm,
|
|
||||||
output logic [`DIVN-2:0] D, // U0.N-1
|
output logic [`DIVN-2:0] D, // U0.N-1
|
||||||
output logic [`DIVb+3:0] NextWSN, NextWCN,
|
output logic [`DIVb+3:0] NextWSN, NextWCN,
|
||||||
output logic [`DIVb+3:0] StickyWSA,
|
output logic [`DIVb:0] FirstS, FirstSM,
|
||||||
output logic [`DIVb:0] LastSM,
|
output logic [`DIVb:0] FirstQ, FirstQM,
|
||||||
output logic [`DIVb-1:0] LastC,
|
|
||||||
output logic [`DIVb:0] FirstSM,
|
|
||||||
output logic [`DIVb-1:0] FirstC,
|
output logic [`DIVb-1:0] FirstC,
|
||||||
output logic [`DIVCOPIES-1:0] qn,
|
output logic [`DIVCOPIES-1:0] qn,
|
||||||
output logic [`DIVb+3:0] FirstWS, FirstWC
|
output logic [`DIVb+3:0] FirstWS, FirstWC
|
||||||
@ -164,27 +160,14 @@ module fdivsqrtiter(
|
|||||||
flopenr #(`DIVb+1) SMreg(clk, DivStart, DivBusy, SMNext[`DIVCOPIES-1], SM[0]);
|
flopenr #(`DIVb+1) SMreg(clk, DivStart, DivBusy, SMNext[`DIVCOPIES-1], SM[0]);
|
||||||
mux2 #(`DIVb+1) Smux(SNext[`DIVCOPIES-1], {1'b1, {(`DIVb){1'b0}}}, DivStart, SMux);
|
mux2 #(`DIVb+1) Smux(SNext[`DIVCOPIES-1], {1'b1, {(`DIVb){1'b0}}}, DivStart, SMux);
|
||||||
flopen #(`DIVb+1) Sreg(clk, DivStart|DivBusy, SMux, S[0]);
|
flopen #(`DIVb+1) Sreg(clk, DivStart|DivBusy, SMux, S[0]);
|
||||||
// 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
|
|
||||||
always_comb
|
|
||||||
if(SqrtM) // sqrt ouputs in the range (1, .5]
|
|
||||||
if(NegSticky) Qm = {SM[0][`DIVb-1-(`RADIX/4):0], 1'b0};
|
|
||||||
else Qm = {S[0][`DIVb-1-(`RADIX/4):0], 1'b0};
|
|
||||||
else
|
|
||||||
if(NegSticky) Qm = QM[0][`DIVb-(`RADIX/4):0];
|
|
||||||
else Qm = Q[0][`DIVb-(`RADIX/4):0];
|
|
||||||
|
|
||||||
assign FirstWS = WS[0];
|
assign FirstWS = WS[0];
|
||||||
assign FirstWC = WC[0];
|
assign FirstWC = WC[0];
|
||||||
|
|
||||||
assign LastSM = SM[`DIVCOPIES-1];
|
assign FirstS = S[0];
|
||||||
assign LastC = C[`DIVCOPIES-1];
|
|
||||||
assign FirstSM = SM[0];
|
assign FirstSM = SM[0];
|
||||||
|
assign FirstQ = Q[0];
|
||||||
|
assign FirstQM = QM[0];
|
||||||
assign FirstC = C[0];
|
assign FirstC = C[0];
|
||||||
|
|
||||||
if(`RADIX==2)
|
|
||||||
if (`DIVCOPIES == 1)
|
|
||||||
assign StickyWSA = {WSA[0][`DIVb+2:0], 1'b0};
|
|
||||||
else
|
|
||||||
assign StickyWSA = {WSA[1][`DIVb+2:0], 1'b0};
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
@ -33,16 +33,17 @@
|
|||||||
module fdivsqrtpostproc(
|
module fdivsqrtpostproc(
|
||||||
input logic [`DIVb+3:0] WS, WC,
|
input logic [`DIVb+3:0] WS, WC,
|
||||||
input logic [`DIVN-2:0] D, // U0.N-1
|
input logic [`DIVN-2:0] D, // U0.N-1
|
||||||
input logic [`DIVb:0] FirstSM,
|
input logic [`DIVb:0] FirstS, FirstSM, FirstQ, FirstQM,
|
||||||
input logic [`DIVb-1:0] FirstC,
|
input logic [`DIVb-1:0] FirstC,
|
||||||
input logic [`DIVCOPIES-1:0] qn,
|
input logic [`DIVCOPIES-1:0] qn,
|
||||||
input logic SqrtM,
|
input logic SqrtM,
|
||||||
|
output logic [`DIVb-(`RADIX/4):0] QmM,
|
||||||
output logic WZero,
|
output logic WZero,
|
||||||
output logic DivSM,
|
output logic DivSM
|
||||||
output logic NegSticky
|
|
||||||
);
|
);
|
||||||
|
|
||||||
logic [`DIVb+3:0] W;
|
logic [`DIVb+3:0] W;
|
||||||
|
logic NegSticky;
|
||||||
|
|
||||||
// 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
|
||||||
if (`RADIX == 2) begin
|
if (`RADIX == 2) begin
|
||||||
@ -60,4 +61,13 @@ module fdivsqrtpostproc(
|
|||||||
assign W = WC+WS;
|
assign W = WC+WS;
|
||||||
assign NegSticky = W[`DIVb+3];
|
assign NegSticky = W[`DIVb+3];
|
||||||
|
|
||||||
|
// 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
|
||||||
|
always_comb
|
||||||
|
if(SqrtM) // sqrt ouputs in the range (1, .5]
|
||||||
|
if(NegSticky) QmM = {FirstSM[`DIVb-1-(`RADIX/4):0], 1'b0};
|
||||||
|
else QmM = {FirstS[`DIVb-1-(`RADIX/4):0], 1'b0};
|
||||||
|
else
|
||||||
|
if(NegSticky) QmM = FirstQM[`DIVb-(`RADIX/4):0];
|
||||||
|
else QmM = FirstQ[`DIVb-(`RADIX/4):0];
|
||||||
|
|
||||||
endmodule
|
endmodule
|
Loading…
Reference in New Issue
Block a user