/1/Mux8Way16.hdl
http://github.com/happy4crazy/elements_of_computing_systems · Unknown · 34 lines · 28 code · 6 blank · 0 comment · 0 complexity · 25425610dcb1d7423c259dd005a188ca MD5 · raw file
- // This file is part of the materials accompanying the book
- // "The Elements of Computing Systems" by Nisan and Schocken,
- // MIT Press. Book site: www.idc.ac.il/tecs
- // File name: projects/01/Mux8Way16.hdl
-
- /**
- * 8-way 16-bit multiplexor.
- * out = a -- if sel=000
- * b -- if sel=001
- * c -- if sel=010
- * d -- if sel=011
- * ...
- * h -- if sel=111
- */
-
- /**
- * Note that the numerical value of x[k] is x[k] * 2^k
- * So if sel=100, then sel[0] = 0, sel[1] = 0, and sel[2] = 1
- * This tripped me up because I was reading the bits in the wrong direction!
- */
-
- CHIP Mux8Way16 {
-
- IN a[16], b[16], c[16], d[16],
- e[16], f[16], g[16], h[16],
- sel[3];
-
- OUT out[16];
-
- PARTS:
- Mux4Way16(a=a, b=b, c=c, d=d, sel=sel[0..1], out=abcd);
- Mux4Way16(a=e, b=f, c=g, d=h, sel=sel[0..1], out=efgh);
- Mux16(a=abcd, b=efgh, sel=sel[2], out=out);
- }