-
-
Save itsmemattchung/fe518d0988214a679df5575e2632c8ee to your computer and use it in GitHub Desktop.
Dmux implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: | |
// A | |
And(a=sel, b=in, out=b); | |
//B | |
Not(in=sel, out=notsel); | |
Xor(a=false, b=notsel, out=newsel); | |
And(a=newsel, b=in, out=a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment