Files
nand2tetris/projects/01/DMux.hdl
2014-11-10 21:50:48 -08:00

23 lines
509 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:
Nand(a=sel, b=sel, out=notsel);
Nand(a=in, b=notsel, out=asel);
Nand(a=in, b=sel, out=bsel);
Nand(a=asel, b=asel, out=a);
Nand(a=bsel, b=bsel, out=b);
}