yosys4gal/cells_sim.v

79 lines
1.3 KiB
Coq
Raw Permalink Normal View History

2024-04-04 06:33:47 +00:00
module GAL_SOP (A, Y);
2024-04-04 17:02:51 +00:00
parameter WIDTH = 0;
parameter DEPTH = 0;
parameter TABLE = 0;
input [WIDTH-1:0] A;
output reg Y;
integer i, j;
reg match;
always @* begin
Y = 0;
for (i = 0; i < DEPTH; i=i+1) begin
match = 1;
for (j = 0; j < WIDTH; j=j+1) begin
if (TABLE[2*WIDTH*i + 2*j + 0] && A[j]) match = 0;
if (TABLE[2*WIDTH*i + 2*j + 1] && !A[j]) match = 0;
end
if (match) Y = 1;
2024-04-04 06:33:47 +00:00
end
end
endmodule
2024-04-05 01:39:30 +00:00
module GAL_1SOP (A, Y);
parameter WIDTH = 0;
parameter DEPTH = 0;
parameter TABLE = 0;
input [WIDTH-1:0] A;
output reg Y;
integer i, j;
reg match;
always @* begin
Y = 0;
for (i = 0; i < DEPTH; i=i+1) begin
match = 1;
for (j = 0; j < WIDTH; j=j+1) begin
if (TABLE[2*WIDTH*i + 2*j + 0] && A[j]) match = 0;
if (TABLE[2*WIDTH*i + 2*j + 1] && !A[j]) match = 0;
end
if (match) Y = 1;
end
end
endmodule
2024-04-04 06:33:47 +00:00
module GAL_INPUT (A, Y);
2024-04-04 17:02:51 +00:00
input A;
output Y;
2024-04-04 06:33:47 +00:00
2024-04-04 17:02:51 +00:00
assign Y = A;
2024-04-04 06:33:47 +00:00
endmodule
2024-04-04 17:02:51 +00:00
module GAL_OLMC (C, E, A, Y);
parameter REGISTERED = 0;
parameter INVERTED = 0;
2024-04-04 06:33:47 +00:00
2024-04-04 17:02:51 +00:00
input C, E, A;
inout Y;
2024-04-04 06:33:47 +00:00
2024-04-04 17:02:51 +00:00
reg internal;
2024-04-04 06:33:47 +00:00
2024-04-04 17:02:51 +00:00
assign Y = E ? internal : 1'bZ;
2024-04-04 06:33:47 +00:00
2024-04-04 17:02:51 +00:00
generate
if (REGISTERED == 1) begin
always @ (posedge C) begin
internal <= (INVERTED == 0) ? A : !A;
end
end else begin
always @ (*) begin
internal <= (INVERTED == 0) ? A : !A;
end
end
endgenerate
2024-04-04 06:33:47 +00:00
endmodule