// 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: //Invert inputs Not(in=a, out=nota); Not(in=b, out=notb); //Xor Logic And(a=a, b=notb, out=and1); And(a=nota, b=b, out=and2); Or(a=and1, b=and2, out=out); }