// Xor.hdl

// (a AND NOT b) OR (NOT a AND b)

// interface
CHIP Xor {
    IN a, b;
    OUT out;

    // implementation
    PARTS:
    
    // Not
    Not(
        in = a,
        out = nota
    );
    Not(
        in = b,
        out = notb
    );

    // And
    And(
        a = a,
        b = notb,
        out = aAndNotb
    );
    And(
        a = nota, 
        b = b,
        out = notaAndb
    );

    // Or
    Or(
        a = aAndNotb,
        b = notaAndb,
        out = out
    );
}