3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-24 01:25:33 +00:00

RIP $safe_pmux

This commit is contained in:
Clifford Wolf 2014-08-14 11:39:46 +02:00
parent 28cf48e31f
commit 13f2f36884
16 changed files with 21 additions and 98 deletions

View file

@ -938,39 +938,16 @@ input [S_WIDTH-1:0] S;
output reg [WIDTH-1:0] Y;
integer i;
reg found_active_sel_bit;
always @* begin
Y = A;
for (i = 0; i < S_WIDTH; i = i+1)
if (S[i])
Y = B >> (WIDTH*i);
end
endmodule
// --------------------------------------------------------
module \$safe_pmux (A, B, S, Y);
parameter WIDTH = 0;
parameter S_WIDTH = 0;
input [WIDTH-1:0] A;
input [WIDTH*S_WIDTH-1:0] B;
input [S_WIDTH-1:0] S;
output reg [WIDTH-1:0] Y;
integer i, j;
always @* begin
j = 0;
found_active_sel_bit = 0;
for (i = 0; i < S_WIDTH; i = i+1)
if (S[i]) begin
Y = B >> (WIDTH*i);
j = j + 1;
Y = found_active_sel_bit ? 'bx : B >> (WIDTH*i);
found_active_sel_bit = 1;
end
if (j != 1)
Y = A;
end
endmodule

View file

@ -794,40 +794,3 @@ module \$pmux (A, B, S, Y);
assign Y = |S ? Y_B : A;
endmodule
module \$safe_pmux (A, B, S, Y);
parameter WIDTH = 1;
parameter S_WIDTH = 1;
input [WIDTH-1:0] A;
input [WIDTH*S_WIDTH-1:0] B;
input [S_WIDTH-1:0] S;
output [WIDTH-1:0] Y;
wire [S_WIDTH-1:0] status_found_first;
wire [S_WIDTH-1:0] status_found_second;
genvar i;
generate
for (i = 0; i < S_WIDTH; i = i + 1) begin:GEN1
wire pre_first;
if (i > 0) begin:GEN2
assign pre_first = status_found_first[i-1];
end:GEN2 else begin:GEN3
assign pre_first = 0;
end:GEN3
assign status_found_first[i] = pre_first | S[i];
assign status_found_second[i] = pre_first & S[i];
end:GEN1
endgenerate
\$pmux #(
.WIDTH(WIDTH),
.S_WIDTH(S_WIDTH)
) pmux_cell (
.A(A),
.B(B),
.S(S & {S_WIDTH{~|status_found_second}}),
.Y(Y)
);
endmodule