Files
nand2tetris/project-1-boolean-logic/01/Mux.hdl
2026-01-10 07:00:38 +01:00

19 lines
422 B
Plaintext
Executable File

// 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/1/Mux.hdl
/**
* Multiplexor:
* if (sel = 0) out = a, else out = b
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
Not(in=sel,out=notSel);
And(a= a, b= notSel, out= andA);
And(a= b, b= sel, out= andB);
Xor(a= andA , b= andB, out=out );
}