Skip to content

Commit

Permalink
Fixing non power of 2 mux generation (FPGA-Research#242)
Browse files Browse the repository at this point in the history
* mux fix

* formatting and rename my_mux2 to cus_mux21_buf

* rename and update for vhdl

* more rename

---------

Co-authored-by: King Lok Chung <[email protected]>
  • Loading branch information
KelvinChung2000 and King Lok Chung committed Jan 6, 2025
1 parent bb7ba65 commit 484d718
Show file tree
Hide file tree
Showing 9 changed files with 660 additions and 661 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ module cus_mux41_buf (A0, A1, A2, A3, S0, S0N, S1, S1N, X);
assign X = S1 ? B1 : B0;
endmodule

module my_mux2 (A0, A1, S, X);
module cus_mux21 (A0, A1, S, X);
input A0;
input A1;
input S;
Expand All @@ -203,7 +203,7 @@ module my_mux2 (A0, A1, S, X);
break_comb_loop break_comb_loop_inst1(.A (A1), .X (AIN[1]));

assign X = S ? AIN[1] : AIN[0];
endmodule
endmodule

module cus_mux81 (A0, A1, A2, A3, A4, A5, A6, A7, S0, S0N, S1, S1N, S2, S2N, X);
input A0;
Expand Down Expand Up @@ -249,7 +249,7 @@ module cus_mux81 (A0, A1, A2, A3, A4, A5, A6, A7, S0, S0N, S1, S1N, S2, S2N, X);
.X (cus_mux41_out1)
);

my_mux2 my_mux2_inst(
cus_mux21 cus_mux21_inst(
.A0(cus_mux41_out0),
.A1(cus_mux41_out1),
.S (S2),
Expand Down Expand Up @@ -301,7 +301,7 @@ module cus_mux81_buf (A0, A1, A2, A3, A4, A5, A6, A7, S0, S0N, S1, S1N, S2, S2N,
.X (cus_mux41_buf_out1)
);

my_mux2 my_mux2_inst(
cus_mux21 cus_mux21_inst(
.A0(cus_mux41_buf_out0),
.A1(cus_mux41_buf_out1),
.S (S2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module LUT4c_frame_config_dffesr #(parameter NoConfigBits = 19)(
//CONFout <= c_I0mux;

//assign I0mux = c_I0mux ? Ci : I0;
my_mux2 my_mux2_I0mux(
cus_mux21 cus_mux21_I0mux(
.A0(I[0]),
.A1(Ci),
.S(c_I0mux),
Expand Down Expand Up @@ -126,7 +126,7 @@ module LUT4c_frame_config_dffesr #(parameter NoConfigBits = 19)(
);

//assign O = c_out_mux ? LUT_flop : LUT_out;
my_mux2 my_mux2_O(
cus_mux21 cus_mux21_O(
.A0(LUT_out),
.A1(LUT_flop),
.S(c_out_mux),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module MUX8LUT_frame_config_mux #(parameter NoConfigBits = 2)(
input B,
input C,
input D,
input E,
input E,
input F,
input G,
input H,
Expand All @@ -48,88 +48,88 @@ module MUX8LUT_frame_config_mux #(parameter NoConfigBits = 2)(

// see figure (column-wise left-to-right)
//assign AB = S[0] ? B : A;
my_mux2 my_mux2_AB(
cus_mux21 cus_mux21_AB(
.A0(A),
.A1(B),
.S(S[0]),
.X(AB)
);
//assign CD = sCD ? D : C;
my_mux2 my_mux2_CD(
cus_mux21 cus_mux21_CD(
.A0(C),
.A1(D),
.S(sCD),
.X(CD)
);
//assign EF = sEF ? F : E;
my_mux2 my_mux2_EF(
cus_mux21 cus_mux21_EF(
.A0(E),
.A1(F),
.S(sEF),
.X(EF)
);
//assign GH = sGH ? H : G;
my_mux2 my_mux2_GH(
cus_mux21 cus_mux21_GH(
.A0(G),
.A1(H),
.S(sGH),
.X(GH)
);

//assign sCD = c0 ? S[0] : S[1];
my_mux2 my_mux2_sCD(
cus_mux21 cus_mux21_sCD(
.A0(S[1]),
.A1(S[0]),
.S(c0),
.X(sCD)
);
//assign sEF = c1 ? S[0] : S[2];
my_mux2 my_mux2_sEF(
cus_mux21 cus_mux21_sEF(
.A0(S[2]),
.A1(S[0]),
.S(c1),
.X(sEF)
);
//assign sGH = c0 ? sEF : sEH;
my_mux2 my_mux2_sGH(
cus_mux21 cus_mux21_sGH(
.A0(sEH),
.A1(sEF),
.S(c0),
.X(sGH)
);
//assign sEH = c1 ? S[1] : S[3];
my_mux2 my_mux2_sEH(
cus_mux21 cus_mux21_sEH(
.A0(S[3]),
.A1(S[1]),
.S(c1),
.X(sEH)
);

//assign AD = S[1] ? CD : AB;
my_mux2 my_mux2_AD(
cus_mux21 cus_mux21_AD(
.A0(AB),
.A1(CD),
.S(S[1]),
.X(AD)
);
//assign EH = sEH ? GH : EF;
my_mux2 my_mux2_EH(
cus_mux21 cus_mux21_EH(
.A0(EF),
.A1(GH),
.S(sEH),
.X(EH)
);

//assign AH = S[3] ? EH : AD;
my_mux2 my_mux2_AH(
cus_mux21 cus_mux21_AH(
.A0(AD),
.A1(EH),
.S(S[3]),
.X(AH)
);

//assign EH_GH = c0 ? EH : GH;
my_mux2 my_mux2_EH_GH(
cus_mux21 cus_mux21_EH_GH(
.A0(GH),
.A1(EH),
.S(c0),
Expand All @@ -138,14 +138,14 @@ module MUX8LUT_frame_config_mux #(parameter NoConfigBits = 2)(

assign M_AB = AB;
//assign M_AD = c0 ? AD : CD;
my_mux2 my_mux2_M_AD(
cus_mux21 cus_mux21_M_AD(
.A0(CD),
.A1(AD),
.S(c0),
.X(M_AD)
);
//assign M_AH = c1 ? AH : EH_GH;
my_mux2 my_mux2_M_AH(
cus_mux21 cus_mux21_M_AH(
.A0(EH_GH),
.A1(AH),
.S(c1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,28 @@ module InPass4_frame_config_mux #(parameter NoConfigBits = 4)(
//assign O[2] = ConfigBits[2] ? Q[2] : I[2];
//assign O[3] = ConfigBits[3] ? Q[3] : I[3];

my_mux2 my_mux2_inst0(
cus_mux21 cus_mux21_inst0(
.A0(I[0]),
.A1(Q[0]),
.S(ConfigBits[0]),
.X(O[0])
);

my_mux2 my_mux2_inst1(
cus_mux21 cus_mux21_inst1(
.A0(I[1]),
.A1(Q[1]),
.S(ConfigBits[1]),
.X(O[1])
);

my_mux2 my_mux2_inst2(
cus_mux21 cus_mux21_inst2(
.A0(I[2]),
.A1(Q[2]),
.S(ConfigBits[2]),
.X(O[2])
);

my_mux2 my_mux2_inst3(
cus_mux21 cus_mux21_inst3(
.A0(I[3]),
.A1(Q[3]),
.S(ConfigBits[3]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,28 @@ module OutPass4_frame_config_mux #(parameter NoConfigBits = 4)(
//assign O2 = ConfigBits[2] ? Q2 : I2;
//assign O3 = ConfigBits[3] ? Q3 : I3;

my_mux2 my_mux2_inst0(
cus_mux21 cus_mux21_inst0(
.A0(I[0]),
.A1(Q[0]),
.S(ConfigBits[0]),
.X(O[0])
);

my_mux2 my_mux2_inst1(
cus_mux21 cus_mux21_inst1(
.A0(I[1]),
.A1(Q[1]),
.S(ConfigBits[1]),
.X(O[1])
);

my_mux2 my_mux2_inst2(
cus_mux21 cus_mux21_inst2(
.A0(I[2]),
.A1(Q[2]),
.S(ConfigBits[2]),
.X(O[2])
);

my_mux2 my_mux2_inst3(
cus_mux21 cus_mux21_inst3(
.A0(I[3]),
.A1(Q[3]),
.S(ConfigBits[3]),
Expand Down
Loading

0 comments on commit 484d718

Please sign in to comment.