// Exercise BB4a: an 8-channel multiplexer, like the 4051.
//
// Generic version that matches schematic 1, not tied to any chip: the
// output is the channel whose number is on the select inputs.  The 4051 is
// an analog switch; this design only passes logic levels.  With inh = 1
// the output is not driven (high impedance, 1'bz), as the common pin of
// the 4051 floats.  Synthesizable; in an FPGA keep inh at 0.

module mux_8
(
    input  logic [7:0] ch,   // ch [0] is CH0
    input  logic [2:0] sel,  // C B A: sel [2] is C, weight 4
    input  logic       inh,  // 1 = all switches open

    output logic       com
);

    assign com = inh ? 1'bz : ch [sel];

endmodule
