From 91597bba87da84e99c683edfbd30937db56720ed Mon Sep 17 00:00:00 2001 From: David Harris Date: Mon, 1 Aug 2022 15:47:03 -0700 Subject: [PATCH] lza cleanup --- pipelined/src/fpu/fmalza.sv | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pipelined/src/fpu/fmalza.sv b/pipelined/src/fpu/fmalza.sv index d70f0267c..d71b398e7 100644 --- a/pipelined/src/fpu/fmalza.sv +++ b/pipelined/src/fpu/fmalza.sv @@ -37,28 +37,28 @@ module fmalza( // [Schmookler & Nowka, Leading zero anticipation and detection, output logic [$clog2(3*`NF+7)-1:0] SCnt // normalization shift count for the positive result ); - localparam WIDTH = 3*`NF+7; + localparam WIDTH = 3*`NF+6; - logic [WIDTH-1:0] F; - logic [WIDTH-2:0] B, P, G, K; - logic [WIDTH-2:0] Pp1, Gm1, Km1; + logic [WIDTH:0] F; + logic [WIDTH-1:0] B, P, G, K; + logic [WIDTH-1:0] Pp1, Gm1, Km1; assign B = {{(`NF+2){1'b0}}, Pm}; // Zero extend product - assign P = A[WIDTH-2:0]^B; - assign G = A[WIDTH-2:0]&B; - assign K= ~A[WIDTH-2:0]&~B; + assign P = A^B; + assign G = A&B; + assign K= ~A&~B; - assign Pp1 = {sub, P[WIDTH-2:1]}; - assign Gm1 = {G[WIDTH-3:0], Cin}; - assign Km1 = {K[WIDTH-3:0], ~Cin}; + assign Pp1 = {sub, P[WIDTH-1:1]}; + assign Gm1 = {G[WIDTH-2:0], Cin}; + assign Km1 = {K[WIDTH-2:0], ~Cin}; // Apply function to determine Leading pattern // - note: the paper linked above uses the numbering system where 0 is the most significant bit //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] = ~sub&P[WIDTH-2]; - assign F[WIDTH-2:0] = (Pp1&(G&~Km1 | K&~Gm1)) | (~Pp1&(K&~Km1 | G&~Gm1)); + assign F[WIDTH] = ~sub&P[WIDTH-1]; + assign F[WIDTH-1:0] = (Pp1&(G&~Km1 | K&~Gm1)) | (~Pp1&(K&~Km1 | G&~Gm1)); - lzc #(WIDTH) lzc (.num(F), .ZeroCnt(SCnt)); + lzc #(WIDTH+1) lzc (.num(F), .ZeroCnt(SCnt)); endmodule