Files
nand2tetris/projects/01/Xor.hdl
2014-11-10 21:50:48 -08:00

21 lines
459 B
Plaintext

// 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:
Nand (a=a, b=a, out=nota);
Nand (a=b, b=b, out=notb);
Nand (a=a, b=notb, out=tmp1);
Nand (a=nota, b=b, out=tmp2);
Nand (a=tmp1, b=tmp2, out=out);
}