Files

26 lines
565 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/DMux.hdl
/**
* Demultiplexor:
* {a, b} = {in, 0} if sel == 0
* {0, in} if sel == 1
*/
CHIP DMux {
IN in, sel;
OUT a, b;
PARTS:
// Put your code here:
// AND in, sel
Nand(a=in, b=sel, out=out1);
Nand(a=out1, b=out1, out=b);
// NAND( (NOT sel), AND in)
Nand(a=sel, b=sel, out=out2);
Nand(a=in, b=out2, out=out3);
Nand(a=out3, b=out3, out=a);
}