// Exercise M1: a half adder from an XOR gate and an AND gate.
//
// Generic version that matches schematic 1, not tied to any chip: it adds
// two bits.  The sum bit is 1 when exactly one input is 1, the carry when
// both are.  Synthesizable.

module half_adder
(
    input  logic a,
    input  logic b,

    output logic c,  // Carry: weight 2
    output logic s   // Sum:   weight 1
);

    assign s = a ^ b;
    assign c = a & b;

endmodule
