// CD4053B: triple 2-channel analog multiplexer/demultiplexer.
//
// Ports in pin order, named as in the datasheet.  The power pins, VEE (7),
// VSS (8) and VDD (16), are left out.
//
// Digital model of three analog switches, each with its own select: 0 joins
// the X channel to the common pin, 1 the Y channel.  INH = 1 opens all
// switches and the commons float.  Synthesizable while INH is 0.

module cd4053
(
    input  logic by,     // Pin 1
    input  logic bx,     // Pin 2
    input  logic cy,     // Pin 3
    output logic c_com,  // Pin 4:  C common in/out
    input  logic cx,     // Pin 5
    input  logic inh,    // Pin 6:  1 = all switches open
                         // Pin 7:  VEE
                         // Pin 8:  VSS
    input  logic c,      // Pin 9:  select of switch C
    input  logic b,      // Pin 10: select of switch B
    input  logic a,      // Pin 11: select of switch A
    input  logic ax,     // Pin 12
    input  logic ay,     // Pin 13
    output logic a_com,  // Pin 14: A common in/out
    output logic b_com   // Pin 15: B common in/out
                         // Pin 16: VDD
);

    assign a_com = inh ? 1'bz : (a ? ay : ax);
    assign b_com = inh ? 1'bz : (b ? by : bx);
    assign c_com = inh ? 1'bz : (c ? cy : cx);

endmodule
