Files
Nand2Tetris/1_Boolean_Arithmetic/Mux.hdl
2024-11-28 12:43:34 +04:00

18 lines
399 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/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=nsel);
And(a=nsel, b=a, out=aa);
And(a=sel, b=b, out=bb);
Or(a=aa, b=bb, out=out);
}