Files
2022-09-14 23:17:40 +09:00

33 lines
619 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:
// Put your code here:
//!sel
Nand(a=sel, b=sel, out=w1);
//X=a*!sel
Nand(a=a, b=w1, out=w2);
Nand(a=w2, b=w2, out=w3);
//Y=b*sel
Nand(a=b, b=sel, out=w4);
Nand(a=w4, b=w4, out=w5);
//out=X+Y
Nand(a=w3, b=w3, out=w6);
Nand(a=w5, b=w5, out=w7);
Nand(a=w6, b=w7, out=out);
}