Skip to content

Instantly share code, notes, and snippets.

@itsmemattchung
Created February 3, 2017 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsmemattchung/fe518d0988214a679df5575e2632c8ee to your computer and use it in GitHub Desktop.
Save itsmemattchung/fe518d0988214a679df5575e2632c8ee to your computer and use it in GitHub Desktop.
Dmux implementation
// 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