24 lines
477 B
Plaintext
24 lines
477 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/Mux.hdl
|
|
|
|
/**
|
|
* Multiplexor:
|
|
* out = a if sel == 0
|
|
* b otherwise
|
|
*/
|
|
|
|
CHIP Mux {
|
|
IN a, b, sel;
|
|
OUT out;
|
|
|
|
PARTS:
|
|
//Invert Sel
|
|
Not(in=sel, out=notsel);
|
|
//Mux Logic
|
|
And(a=a, b=notsel, out=and1);
|
|
And(a=b, b=sel, out=and2);
|
|
Or(a=and1, b=and2, out=out);
|
|
}
|