// 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=w1); // one or the other... Nand(a=a, b=b, out=w2); // ...but not both! And(a=w1, b=w2, out=out); }