3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-02-22 08:17:38 +00:00

Widen $polarity cell to multiple ports

This commit is contained in:
Emil J. Tywoniak 2026-01-12 13:21:13 +01:00
parent 7f19cf8849
commit 0c7afe8e31
8 changed files with 74 additions and 58 deletions

View file

@ -683,30 +683,33 @@ endmodule
(* techmap_celltype = "$priority" *)
module \$priority (A, Y);
parameter WIDTH = 0;
parameter P_WIDTH = 0;
parameter POLARITY = 0;
(* force_downto *)
input [WIDTH-1:0] A;
input [P_WIDTH*WIDTH-1:0] A;
(* force_downto *)
output [WIDTH-1:0] Y;
output [P_WIDTH*WIDTH-1:0] Y;
(* force_downto *)
wire [WIDTH-1:0] tmp;
wire [P_WIDTH*WIDTH-1:0] tmp;
(* force_downto *)
wire [WIDTH-1:0] A_active;
wire [WIDTH-1:0] Y_active;
wire [P_WIDTH*WIDTH-1:0] A_active;
wire [P_WIDTH*WIDTH-1:0] Y_active;
assign A_active = A ^ ~POLARITY;
assign Y = Y_active ^ ~POLARITY;
genvar i;
genvar i, offset;
generate
if (WIDTH > 0) begin
assign tmp[0] = A_active[0];
assign Y_active[0] = A_active[0];
end
for (i = 1; i < WIDTH; i = i + 1) begin
assign Y_active[i] = tmp[i-1] ? 1'b0 : A_active[i];
assign tmp[i] = tmp[i-1] | A_active[i];
for (offset = 0; offset < P_WIDTH*WIDTH; offset = offset + P_WIDTH) begin
if (P_WIDTH > 0) begin
assign tmp[offset] = A_active[offset];
assign Y_active[offset] = A_active[offset];
end
for (i = offset + 1; i < offset + P_WIDTH; i = i + 1) begin
assign Y_active[i] = tmp[i - 1] ? 1'b0 : A_active[i];
assign tmp[i] = tmp[i - 1] | A_active[i];
end
end
endgenerate