Xor.hdl

// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Xor.hdl

/**
 * Exclusive-or gate:
 * out = not (a == b)
 */

CHIP Xor {
        IN a, b;
        OUT out;

PARTS:
        Or(a=a,b=b,out=aorb);
        Not(in=a, out=nota);
        Not(in=b, out=notb);
        Or(a=nota,b=notb,out=x);
        And(a=aorb,b=x, out=out);

}