mirror of https://github.com/YosysHQ/yosys.git
Fix for non-pow2 width muxes
This commit is contained in:
parent
75b96b1aff
commit
ac1e13819e
|
@ -157,6 +157,15 @@ module \$shiftx (A, B, Y);
|
|||
parameter [B_WIDTH-1:0] _TECHMAP_CONSTMSK_B_ = 0;
|
||||
parameter [B_WIDTH-1:0] _TECHMAP_CONSTVAL_B_ = 0;
|
||||
|
||||
function integer first_B_nonzero;
|
||||
integer i;
|
||||
begin
|
||||
for (i = B_WIDTH-1; i >= 0; i--)
|
||||
if (_TECHMAP_CONSTMSK_B_[i] == 1'b0 || _TECHMAP_CONSTVAL_B_ != 1'b0)
|
||||
first_B_nonzero = i;
|
||||
end
|
||||
endfunction
|
||||
|
||||
generate
|
||||
genvar i, j;
|
||||
if (B_SIGNED) begin
|
||||
|
@ -167,12 +176,12 @@ module \$shiftx (A, B, Y);
|
|||
wire _TECHMAP_FAIL_ = 1;
|
||||
end
|
||||
else if (Y_WIDTH > 1) begin
|
||||
wire [$clog2(A_WIDTH/Y_WIDTH)-1:0] B_bitty = B/Y_WIDTH;
|
||||
localparam inc = first_B_nonzero();
|
||||
for (i = 0; i < Y_WIDTH; i++) begin
|
||||
wire [A_WIDTH/Y_WIDTH-1:0] A_i;
|
||||
for (j = 0; j < A_WIDTH/Y_WIDTH; j++)
|
||||
assign A_i[j] = A[j*Y_WIDTH+i];
|
||||
\$shiftx #(.A_SIGNED(A_SIGNED), .B_SIGNED(B_SIGNED), .A_WIDTH(A_WIDTH/Y_WIDTH), .B_WIDTH($clog2(A_WIDTH/Y_WIDTH)), .Y_WIDTH(1)) bitblast (.A(A_i), .B(B_bitty), .Y(Y[i]));
|
||||
for (j = 0; j*(1<<inc)+i < A_WIDTH; j++)
|
||||
assign A_i[j] = A[j*(1<<inc)+i];
|
||||
\$shiftx #(.A_SIGNED(A_SIGNED), .B_SIGNED(B_SIGNED), .A_WIDTH(A_WIDTH/Y_WIDTH), .B_WIDTH(B_WIDTH-inc), .Y_WIDTH(1'b1)) bitblast (.A(A_i), .B(B[B_WIDTH-1:inc]), .Y(Y[i]));
|
||||
end
|
||||
end
|
||||
else if (B_WIDTH < 3) begin
|
||||
|
|
Loading…
Reference in New Issue