// Exercise BB4c: three 2-channel multiplexers, like the 4053.
//
// Generic version that matches schematic 1, not tied to any chip.  Each of
// the three switches A, B, C has its own select input: 0 passes its X
// channel, 1 its Y channel.  With inh = 1 the outputs are not driven (high
// impedance).  Synthesizable; in an FPGA keep inh at 0.

module mux_2_triple
(
    input  logic [2:0] x_ch,   // x_ch [0] is AX, x_ch [1] BX, x_ch [2] CX
    input  logic [2:0] y_ch,   // y_ch [0] is AY, ...
    input  logic [2:0] sel,    // sel [0] is the select A of switch A, ...
    input  logic       inh,    // 1 = all switches open

    output logic [2:0] com     // com [0] is A COM, ...
);

    for (genvar i = 0; i < 3; i ++)
    begin : switch_i
        assign com [i] = inh ? 1'bz : sel [i] ? y_ch [i] : x_ch [i];
    end

endmodule
