// CD4019B: quad AND/OR select gate.
//
// Ports in pin order, named as in the datasheet.  The power pins, VSS (8)
// and VDD (16), are left out.  Synthesizable.
//
// Each output is Dn = An & Ka | Bn & Kb: Ka passes the A word, Kb the B word,
// both pass A OR B, neither gives 0.

module cd4019
(
    input  logic b4,  // Pin 1
    input  logic a3,  // Pin 2
    input  logic b3,  // Pin 3
    input  logic a2,  // Pin 4
    input  logic b2,  // Pin 5
    input  logic a1,  // Pin 6
    input  logic b1,  // Pin 7
                      // Pin 8:  VSS
    input  logic ka,  // Pin 9
    output logic d1,  // Pin 10
    output logic d2,  // Pin 11
    output logic d3,  // Pin 12
    output logic d4,  // Pin 13
    input  logic kb,  // Pin 14
    input  logic a4   // Pin 15
                      // Pin 16: VDD
);

    assign d1 = a1 & ka | b1 & kb;
    assign d2 = a2 & ka | b2 & kb;
    assign d3 = a3 & ka | b3 & kb;
    assign d4 = a4 & ka | b4 & kb;

endmodule
