// Exercise B3c: the dual 4-input gate chips 4002 (NOR), 4012 (NAND),
// 4072 (OR) and 4082 (AND), one gate of each.
//
// Generic version that matches schematic 1: four gates on the same four
// inputs, not tied to any chip.  Synthesizable.

module gates_4_input
(
    input  logic a,
    input  logic b,
    input  logic c,
    input  logic d,

    output logic y_nor,   // 1 only when all four inputs are 0
    output logic y_nand,  // 0 only when all four inputs are 1
    output logic y_or,    // 0 only when all four inputs are 0
    output logic y_and    // 1 only when all four inputs are 1
);

    // The reduction operators & and | combine all bits of a vector:
    // & { a, b, c, d } is a & b & c & d

    assign y_nor  = ~| { a, b, c, d };
    assign y_nand = ~& { a, b, c, d };
    assign y_or   =   | { a, b, c, d };
    assign y_and  =   & { a, b, c, d };

endmodule
