Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gowin: add mux techmap and whitebox #4004

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions techlibs/gowin/cells_map.v
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,38 @@ module \$lut (A, Y);
end
endgenerate
endmodule

module \$_MUX4_ (A, B, C, D, S, T, Y);
input A, B, C, D, S, T;
output Y;

wire AB;
wire CD;

LUT3 #(.INIT(8'b11011000)) ab(.F(AB), .I0(S), .I1(B), .I2(A));
LUT3 #(.INIT(8'b11011000)) cd(.F(CD), .I0(S), .I1(D), .I2(C));
MUX2_LUT5 y(.O(Y), .I0(AB), .I1(CD), .S0(T));
endmodule

module \$_MUX8_ (A, B, C, D, E, F, G, H, S, T, U, Y);
input A, B, C, D, E, F, G, H, S, T, U;
output Y;

wire AB;
wire CD;
wire EF;
wire GH;

wire ABCD;
wire EFGH;

LUT3 #(.INIT(8'b11011000)) ab(.F(AB), .I0(S), .I1(B), .I2(A));
LUT3 #(.INIT(8'b11011000)) cd(.F(CD), .I0(S), .I1(D), .I2(C));
LUT3 #(.INIT(8'b11011000)) ef(.F(EF), .I0(S), .I1(F), .I2(E));
LUT3 #(.INIT(8'b11011000)) gh(.F(GH), .I0(S), .I1(H), .I2(G));

MUX2_LUT5 abcd(.O(ABCD), .I0(AB), .I1(CD), .S0(T));
MUX2_LUT5 efgh(.O(EFGH), .I0(EF), .I1(GH), .S0(T));

MUX2_LUT6 y(.O(Y), .I0(ABCD), .I1(EFGH), .S0(U));
endmodule
39 changes: 39 additions & 0 deletions techlibs/gowin/cells_sim.v
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,45 @@ module MUX2 (O, I0, I1, S0);
assign O = S0 ? I1 : I0;
endmodule

(* abc9_box, lib_whitebox *)
module \$_MUX4_ (A, B, C, D, S, T, Y);
input A, B, C, D, S, T;
output Y;
specify
(A => Y) = (808, 1116);
(B => Y) = (995, 1371);
(C => Y) = (808, 1116);
(D => Y) = (995, 1371);
(S => Y) = (1184, 1638);
(T => Y) = (486, 680);
endspecify
assign Y = T ? (S ? D : C) :
(S ? B : A);
endmodule

(* abc9_box, lib_whitebox *)
module \$_MUX8_ (A, B, C, D, E, F, G, H, S, T, U, Y);
input A, B, C, D, E, F, G, H, S, T, U;
output Y;
specify
(A => Y) = (808 + 136, 1116 + 255);
(B => Y) = (995 + 136, 1371 + 255);
(C => Y) = (808 + 136, 1116 + 255);
(D => Y) = (995 + 136, 1371 + 255);
(E => Y) = (808 + 136, 1116 + 255);
(F => Y) = (995 + 136, 1371 + 255);
(G => Y) = (808 + 136, 1116 + 255);
(H => Y) = (995 + 136, 1371 + 255);
(S => Y) = (1184 + 136, 1638 + 255);
(T => Y) = (486 + 136, 680 + 255);
(U => Y) = (478, 723);
endspecify
assign Y = U ? T ? (S ? H : G) :
(S ? F : E) :
T ? (S ? D : C) :
(S ? B : A);
endmodule

module MUX2_LUT5 (O, I0, I1, S0);
input I0,I1;
input S0;
Expand Down
Loading