else if (A_WIDTH > `DSP_A_MAXWIDTH) begin\r
localparam n = (A_WIDTH+`DSP_A_MAXWIDTH-sign_headroom-1) / (`DSP_A_MAXWIDTH-sign_headroom);\r
localparam partial_Y_WIDTH = `MIN(Y_WIDTH, B_WIDTH+`DSP_A_MAXWIDTH);\r
+ localparam last_Y_WIDTH = `MIN(partial_Y_WIDTH, B_WIDTH+A_WIDTH-(n-1)*(`DSP_A_MAXWIDTH-sign_headroom));\r
if (A_SIGNED && B_SIGNED) begin\r
- wire signed [partial_Y_WIDTH-1:0] partial [n-1:0];\r
+ wire signed [partial_Y_WIDTH-1:0] partial [n-2:0];\r
+ wire signed [last_Y_WIDTH-1:0] last_partial;\r
wire signed [Y_WIDTH-1:0] partial_sum [n-1:0];\r
end\r
else begin\r
wire [partial_Y_WIDTH-1:0] partial [n-1:0];\r
+ wire [last_Y_WIDTH-1:0] last_partial;\r
wire [Y_WIDTH-1:0] partial_sum [n-1:0];\r
end\r
\r
.B_SIGNED(B_SIGNED),\r
.A_WIDTH(A_WIDTH-(n-1)*(`DSP_A_MAXWIDTH-sign_headroom)),\r
.B_WIDTH(B_WIDTH),\r
- .Y_WIDTH(partial_Y_WIDTH)\r
+ .Y_WIDTH(last_Y_WIDTH)\r
) mul_slice_last (\r
.A(A[A_WIDTH-1 : (n-1)*(`DSP_A_MAXWIDTH-sign_headroom)]),\r
.B(B),\r
- .Y(partial[n-1])\r
+ .Y(last_partial)\r
);\r
- assign partial_sum[n-1] = (partial[n-1] << (n-1)*(`DSP_A_MAXWIDTH-sign_headroom)) + partial_sum[n-2];\r
+ assign partial_sum[n-1] = (last_partial << (n-1)*(`DSP_A_MAXWIDTH-sign_headroom)) + partial_sum[n-2];\r
assign Y = partial_sum[n-1];\r
end\r
else if (B_WIDTH > `DSP_B_MAXWIDTH) begin\r
localparam n = (B_WIDTH+`DSP_B_MAXWIDTH-sign_headroom-1) / (`DSP_B_MAXWIDTH-sign_headroom);\r
localparam partial_Y_WIDTH = `MIN(Y_WIDTH, A_WIDTH+`DSP_B_MAXWIDTH);\r
+ localparam last_Y_WIDTH = `MIN(partial_Y_WIDTH, A_WIDTH+B_WIDTH-(n-1)*(`DSP_B_MAXWIDTH-sign_headroom));\r
if (A_SIGNED && B_SIGNED) begin\r
- wire signed [partial_Y_WIDTH-1:0] partial [n-1:0];\r
+ wire signed [partial_Y_WIDTH-1:0] partial [n-2:0];\r
+ wire signed [last_Y_WIDTH-1:0] last_partial;\r
wire signed [Y_WIDTH-1:0] partial_sum [n-1:0];\r
end\r
else begin\r
wire [partial_Y_WIDTH-1:0] partial [n-1:0];\r
+ wire [last_Y_WIDTH-1:0] last_partial;\r
wire [Y_WIDTH-1:0] partial_sum [n-1:0];\r
end\r
\r
) mul_last (\r
.A(A),\r
.B(B[B_WIDTH-1 : (n-1)*(`DSP_B_MAXWIDTH-sign_headroom)]),\r
- .Y(partial[n-1])\r
+ .Y(last_partial)\r
);\r
- assign partial_sum[n-1] = (partial[n-1] << (n-1)*(`DSP_B_MAXWIDTH-sign_headroom)) + partial_sum[n-2];\r
+ assign partial_sum[n-1] = (last_partial << (n-1)*(`DSP_B_MAXWIDTH-sign_headroom)) + partial_sum[n-2];\r
assign Y = partial_sum[n-1];\r
end\r
else begin \r