diff options
author | Yuchen Pei <me@ypei.me> | 2018-01-20 15:41:49 +0100 |
---|---|---|
committer | Yuchen Pei <me@ypei.me> | 2018-01-20 15:41:49 +0100 |
commit | d3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 (patch) | |
tree | d58df9ec2480e2a9ec6240f9c797f83d1a0b1056 /chips/Mux16.hdl | |
parent | 3571f998b28fbc8d9250ba04c983935f10a16c15 (diff) |
rearranged the dir for github
- removed tools and pdfs
- rearranged the projects dirs
- added md files
- other minor changes
Diffstat (limited to 'chips/Mux16.hdl')
-rw-r--r-- | chips/Mux16.hdl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chips/Mux16.hdl b/chips/Mux16.hdl new file mode 100644 index 0000000..ff09c6b --- /dev/null +++ b/chips/Mux16.hdl @@ -0,0 +1,34 @@ +// 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/Mux16.hdl
+
+/**
+ * 16-bit multiplexor:
+ * for i = 0..15 out[i] = a[i] if sel == 0
+ * b[i] if sel == 1
+ */
+
+CHIP Mux16 {
+ IN a[16], b[16], sel;
+ OUT out[16];
+
+ PARTS:
+ // Put your code here:
+ Mux (a=a[0], b=b[0], sel=sel, out=out[0]);
+ Mux (a=a[1], b=b[1], sel=sel, out=out[1]);
+ Mux (a=a[2], b=b[2], sel=sel, out=out[2]);
+ Mux (a=a[3], b=b[3], sel=sel, out=out[3]);
+ Mux (a=a[4], b=b[4], sel=sel, out=out[4]);
+ Mux (a=a[5], b=b[5], sel=sel, out=out[5]);
+ Mux (a=a[6], b=b[6], sel=sel, out=out[6]);
+ Mux (a=a[7], b=b[7], sel=sel, out=out[7]);
+ Mux (a=a[8], b=b[8], sel=sel, out=out[8]);
+ Mux (a=a[9], b=b[9], sel=sel, out=out[9]);
+ Mux (a=a[10], b=b[10], sel=sel, out=out[10]);
+ Mux (a=a[11], b=b[11], sel=sel, out=out[11]);
+ Mux (a=a[12], b=b[12], sel=sel, out=out[12]);
+ Mux (a=a[13], b=b[13], sel=sel, out=out[13]);
+ Mux (a=a[14], b=b[14], sel=sel, out=out[14]);
+ Mux (a=a[15], b=b[15], sel=sel, out=out[15]);
+}
|