From 31215277ee53722a4899a5522f9ea7fa4585755a Mon Sep 17 00:00:00 2001 From: David Harris Date: Mon, 1 Aug 2022 12:34:00 -0700 Subject: [PATCH] more lza cleanup --- pipelined/src/fpu/fmalza.sv | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pipelined/src/fpu/fmalza.sv b/pipelined/src/fpu/fmalza.sv index b7b40091d..f70b1bc93 100644 --- a/pipelined/src/fpu/fmalza.sv +++ b/pipelined/src/fpu/fmalza.sv @@ -39,15 +39,17 @@ module fmalza( // [Schmookler & Nowka, Leading zero anticipation and detection, localparam WIDTH = 3*`NF+7; logic [WIDTH-1:0] B,F; - logic [WIDTH-1:0] P, G, K; + logic [WIDTH-1:0] P, G; + logic [WIDTH-2:0] K; logic [WIDTH-2:0] Pp1, Gm1, Km1; assign B = {{(`NF+3){1'b0}}, Pm}; // Zero extend product -// assign AA = A + Cin; + // next steps***replace P[WIDTH-1] with sub, then remove one bit from A + assign P = A^B; - assign G = A&B; - assign K= ~A&~B; + assign G = A[WIDTH-2:0]&B[WIDTH-2:0]; + assign K= ~A[WIDTH-2:0]&~B[WIDTH-2:0]; assign Pp1 = {A[WIDTH-1], P[WIDTH-2:1]}; assign Gm1 = {G[WIDTH-3:0], Cin}; @@ -58,7 +60,7 @@ module fmalza( // [Schmookler & Nowka, Leading zero anticipation and detection, //f[n] = ~P[n]&P[n-1] note: n is the MSB //f[i] = (P[i+1]&(G[i]&~K[i-1] | K[i]&~G[i-1])) | (~P[i+1]&(K[i]&~K[i-1] | G[i]&~G[i-1])) assign F[WIDTH-1] = ~P[WIDTH-1]&P[WIDTH-2]; - assign F[WIDTH-2:0] = (Pp1&(G[WIDTH-2:0]&~Km1 | K[WIDTH-2:0]&~Gm1)) | (~Pp1&(K[WIDTH-2:0]&~Km1 | G[WIDTH-2:0]&~Gm1)); + assign F[WIDTH-2:0] = (Pp1&(G&~Km1 | K&~Gm1)) | (~Pp1&(K&~Km1 | G&~Gm1)); lzc #(WIDTH) lzc (.num(F), .ZeroCnt(SCnt)); endmodule