mirror of https://github.com/YosysHQ/yosys.git
Fix B_WIDTH > DSP_B_MAXWIDTH case
This commit is contained in:
parent
c54a39069d
commit
7e86c8bcfb
|
@ -67,22 +67,6 @@ module \$mul (A, B, Y);
|
||||||
.B(A),
|
.B(A),
|
||||||
.Y(Y)
|
.Y(Y)
|
||||||
);
|
);
|
||||||
else if (A_SIGNED && (A_WIDTH > `DSP_A_MAXWIDTH || B_WIDTH > `DSP_B_MAXWIDTH)) begin
|
|
||||||
wire _;
|
|
||||||
\$__mul #(
|
|
||||||
.A_SIGNED(A_SIGNED),
|
|
||||||
.B_SIGNED(B_SIGNED),
|
|
||||||
.A_WIDTH(A_WIDTH),
|
|
||||||
.B_WIDTH(B_WIDTH),
|
|
||||||
.Y_WIDTH(Y_WIDTH)
|
|
||||||
) _TECHMAP_REPLACE_ (
|
|
||||||
.A(A),
|
|
||||||
.B(B),
|
|
||||||
.Y({_,Y[Y_WIDTH-2:0]})
|
|
||||||
);
|
|
||||||
// For non-zero results, recompute sign bit
|
|
||||||
assign Y[Y_WIDTH-1] = (|Y[Y_WIDTH-2:0]) & (A[A_WIDTH-1] ^ B[B_WIDTH-1]);
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
\$__mul #(
|
\$__mul #(
|
||||||
.A_SIGNED(A_SIGNED),
|
.A_SIGNED(A_SIGNED),
|
||||||
|
@ -171,14 +155,15 @@ module \$__mul (A, B, Y);
|
||||||
assign partial_sum[i] = (partial[i] << i*(`DSP_A_MAXWIDTH-sign_headroom)) + partial_sum[i-1];
|
assign partial_sum[i] = (partial[i] << i*(`DSP_A_MAXWIDTH-sign_headroom)) + partial_sum[i-1];
|
||||||
end
|
end
|
||||||
|
|
||||||
|
localparam last_A_WIDTH = A_WIDTH-(n-1)*(`DSP_A_MAXWIDTH-sign_headroom);
|
||||||
\$__mul #(
|
\$__mul #(
|
||||||
.A_SIGNED(A_SIGNED),
|
.A_SIGNED(A_SIGNED),
|
||||||
.B_SIGNED(B_SIGNED),
|
.B_SIGNED(B_SIGNED),
|
||||||
.A_WIDTH(A_WIDTH-(n-1)*(`DSP_A_MAXWIDTH-sign_headroom)),
|
.A_WIDTH(last_A_WIDTH),
|
||||||
.B_WIDTH(B_WIDTH),
|
.B_WIDTH(B_WIDTH),
|
||||||
.Y_WIDTH(last_Y_WIDTH)
|
.Y_WIDTH(last_Y_WIDTH)
|
||||||
) mul_slice_last (
|
) mul_slice_last (
|
||||||
.A(A[A_WIDTH-1 : (n-1)*(`DSP_A_MAXWIDTH-sign_headroom)]),
|
.A(A[A_WIDTH-1 -: last_A_WIDTH]),
|
||||||
.B(B),
|
.B(B),
|
||||||
.Y(last_partial)
|
.Y(last_partial)
|
||||||
);
|
);
|
||||||
|
@ -232,20 +217,17 @@ module \$__mul (A, B, Y);
|
||||||
end
|
end
|
||||||
|
|
||||||
localparam last_B_WIDTH = B_WIDTH-(n-1)*(`DSP_B_MAXWIDTH-sign_headroom);
|
localparam last_B_WIDTH = B_WIDTH-(n-1)*(`DSP_B_MAXWIDTH-sign_headroom);
|
||||||
if (A_SIGNED && B_SIGNED && last_B_WIDTH == 1)
|
\$__mul #(
|
||||||
assign last_partial = 0;
|
.A_SIGNED(A_SIGNED),
|
||||||
else
|
.B_SIGNED(B_SIGNED),
|
||||||
\$__mul #(
|
.A_WIDTH(A_WIDTH),
|
||||||
.A_SIGNED(A_SIGNED),
|
.B_WIDTH(last_B_WIDTH),
|
||||||
.B_SIGNED(B_SIGNED),
|
.Y_WIDTH(last_Y_WIDTH)
|
||||||
.A_WIDTH(A_WIDTH),
|
) mul_last (
|
||||||
.B_WIDTH(last_B_WIDTH),
|
.A(A),
|
||||||
.Y_WIDTH(last_Y_WIDTH)
|
.B(B[B_WIDTH-1 -: last_B_WIDTH]),
|
||||||
) mul_last (
|
.Y(last_partial)
|
||||||
.A(A),
|
);
|
||||||
.B(B[B_WIDTH-1 -: last_B_WIDTH]),
|
|
||||||
.Y(last_partial)
|
|
||||||
);
|
|
||||||
assign partial_sum[n-1] = (last_partial << (n-1)*(`DSP_B_MAXWIDTH-sign_headroom)) + partial_sum[n-2];
|
assign partial_sum[n-1] = (last_partial << (n-1)*(`DSP_B_MAXWIDTH-sign_headroom)) + partial_sum[n-2];
|
||||||
assign Y = partial_sum[n-1];
|
assign Y = partial_sum[n-1];
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue