Moving postprocessing into postproc block

This commit is contained in:
David Harris 2022-09-07 06:42:37 -07:00
parent f40c6b0ec4
commit 825d3169d9
3 changed files with 40 additions and 49 deletions

View File

@ -66,12 +66,20 @@ module fdivsqrt(
logic [`DURLEN-1:0] Dur; logic [`DURLEN-1:0] Dur;
logic NegSticky; logic NegSticky;
logic [`DIVCOPIES-1:0] qn; logic [`DIVCOPIES-1:0] qn;
logic WZero;
fdivsqrtpreproc fdivsqrtpreproc(.clk, .DivStart(DivStartE), .Xm(XmE), .QeM, .Xe(XeE), .Fmt(FmtE), .Ye(YeE), .Sqrt(SqrtE), .Dur, .Ym(YmE), .XZero(XZeroE), .X, .Dpreproc); fdivsqrtpreproc fdivsqrtpreproc(
.clk, .DivStart(DivStartE), .Xm(XmE), .QeM, .Xe(XeE), .Fmt(FmtE), .Ye(YeE),
fdivsqrtfsm fdivsqrtfsm(.reset, .qn, .LastSM, .LastC, .FirstSM, .FirstC, .D, .XsE, .SqrtE, .SqrtM, .NextWSN, .NextWCN, .WS, .WC, .Dur, .DivBusy, .clk, .DivStart(DivStartE),.StallE, .StallM, .DivDone, .XZeroE, .YZeroE, .DivSE(DivSM), .XNaNE, .YNaNE, .Sqrt(SqrtE), .Dur, .Ym(YmE), .XZero(XZeroE), .X, .Dpreproc);
.StickyWSA, .XInfE, .YInfE, .NegSticky(NegSticky), .EarlyTermShiftE(EarlyTermShiftM)); fdivsqrtfsm fdivsqrtfsm(
fdivsqrtiter fdivsqrtiter(.clk, .qn, .D, .LastSM, .LastC, .FirstSM, .FirstC, .SqrtE, .SqrtM, .X,.Dpreproc, .NegSticky, .FirstWS(WS), .FirstWC(WC), .NextWSN, .NextWCN, .DivStart(DivStartE), .Xe(XeE), .Ye(YeE), .XZeroE, .YZeroE, .reset, .qn, .LastSM, .LastC, .FirstSM, .FirstC, .D, .XsE, .SqrtE, .SqrtM, .NextWSN, .NextWCN,
.WS, .WC, .Dur, .DivBusy, .clk, .DivStart(DivStartE),.StallE, .StallM, .DivDone, .XZeroE, .YZeroE,
.XNaNE, .YNaNE,
.StickyWSA, .XInfE, .YInfE, .EarlyTermShiftE(EarlyTermShiftM), .WZero);
fdivsqrtiter fdivsqrtiter(
.clk, .qn, .D, .LastSM, .LastC, .FirstSM, .FirstC, .SqrtE, .SqrtM,
.X,.Dpreproc, .NegSticky, .FirstWS(WS), .FirstWC(WC), .NextWSN, .NextWCN,
.DivStart(DivStartE), .Xe(XeE), .Ye(YeE), .XZeroE, .YZeroE,
.StickyWSA, .DivBusy, .Qm(QmM)); .StickyWSA, .DivBusy, .Qm(QmM));
// fdivsqrtpostproc fdivsqrtpostproc(); fdivsqrtpostproc fdivsqrtpostproc(.WS, .WC, .D, .FirstSM, .FirstC, .qn, .SqrtM, .WZero, .DivSM, .NegSticky);
endmodule endmodule

View File

@ -51,10 +51,11 @@ module fdivsqrtfsm(
input logic [`DIVb-1:0] LastC, input logic [`DIVb-1:0] LastC,
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 WZero,
output logic [`DURLEN-1:0] EarlyTermShiftE, output logic [`DURLEN-1:0] EarlyTermShiftE,
output logic DivSE, // output logic DivSE,
output logic DivDone, output logic DivDone,
output logic NegSticky, // output logic NegSticky,
output logic DivBusy output logic DivBusy
); );
@ -64,25 +65,6 @@ module fdivsqrtfsm(
logic [`DURLEN-1:0] step; logic [`DURLEN-1:0] step;
logic SpecialCase; logic SpecialCase;
logic WZero;
logic [`DIVb+3:0] W;
// check for early termination on an exact result. If the result is not exact, the sticky should be set
if (`RADIX == 2) begin
logic [`DIVb+3:0] FZero;
logic [`DIVb+2:0] FirstK;
assign FirstK = ({3'b111, FirstC<<1} & ~({3'b111, FirstC<<1} << 1));
assign FZero = SqrtM ? {FirstSM[`DIVb], FirstSM, 2'b0} | {FirstK,1'b0} : {3'b1,D,{`DIVb-`DIVN+2{1'b0}}};
assign WZero = ((WS^WC)=={WS[`DIVb+2:0]|WC[`DIVb+2:0], 1'b0})|(((WS+WC+FZero)==0)&qn[`DIVCOPIES-1]);
end else begin
assign WZero = ((WS^WC)=={WS[`DIVb+2:0]|WC[`DIVb+2:0], 1'b0});
end
assign DivSE = ~WZero;
// Determine if sticky bit is negative
assign W = WC+WS;
assign NegSticky = W[`DIVb+3];
assign EarlyTermShiftE = step; assign EarlyTermShiftE = step;
// terminate immediately on special cases // terminate immediately on special cases

View File

@ -31,32 +31,33 @@
`include "wally-config.vh" `include "wally-config.vh"
module fdivsqrtpostproc( module fdivsqrtpostproc(
input logic clk, input logic [`DIVb+3:0] WS, WC,
input logic reset,
input logic DivStart,
input logic [`DIVb+3:0] NextWSN, NextWCN, WS, WC,
/* input logic XInfE, YInfE,
input logic XZeroE, YZeroE,
input logic XNaNE, YNaNE,
input logic XsE,
input logic SqrtE,
input logic SqrtM,
input logic StallE,
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 [`DIVb:0] LastSM,
input logic [`DIVb:0] FirstSM, input logic [`DIVb:0] FirstSM,
input logic [`DIVb-1:0] LastC,
input logic [`DIVb-1:0] FirstC, input logic [`DIVb-1:0] FirstC,
input logic [`DIVCOPIES-1:0] qn, input logic [`DIVCOPIES-1:0] qn,
// output logic [`DURLEN-1:0] EarlyTermShiftE, input logic SqrtM,
output logic DivSE, output logic WZero,
// output logic DivDone, output logic DivSM,
output logic NegSticky, output logic NegSticky
output logic DivBusy
); );
logic [`DIVb+3:0] W;
// check for early termination on an exact result. If the result is not exact, the sticky should be set
if (`RADIX == 2) begin
logic [`DIVb+3:0] FZero;
logic [`DIVb+2:0] FirstK;
assign FirstK = ({3'b111, FirstC<<1} & ~({3'b111, FirstC<<1} << 1));
assign FZero = SqrtM ? {FirstSM[`DIVb], FirstSM, 2'b0} | {FirstK,1'b0} : {3'b1,D,{`DIVb-`DIVN+2{1'b0}}};
assign WZero = ((WS^WC)=={WS[`DIVb+2:0]|WC[`DIVb+2:0], 1'b0})|(((WS+WC+FZero)==0)&qn[`DIVCOPIES-1]);
end else begin
assign WZero = ((WS^WC)=={WS[`DIVb+2:0]|WC[`DIVb+2:0], 1'b0});
end
assign DivSM = ~WZero;
// Determine if sticky bit is negative
assign W = WC+WS;
assign NegSticky = W[`DIVb+3];
endmodule endmodule