#### /1/Mux16.hdl

http://github.com/happy4crazy/elements_of_computing_systems
Unknown | 32 lines | 28 code | 4 blank | 0 comment | 0 complexity | 888efa73aeee3355f016c617d8dc586c MD5 | raw file
``` 1// This file is part of the materials accompanying the book
2// "The Elements of Computing Systems" by Nisan and Schocken,
3// MIT Press. Book site: www.idc.ac.il/tecs
4// File name: projects/01/Mux16.hdl
5
6/**
7 * 16-bit multiplexor. If sel=0 then out = a else out = b.
8 */
9
10CHIP Mux16 {
11
12    IN  a[16], b[16], sel;
13    OUT out[16];
14
15    PARTS:
16    Mux(a=a[0], b=b[0], sel=sel, out=out[0]);
17    Mux(a=a[1], b=b[1], sel=sel, out=out[1]);
18    Mux(a=a[2], b=b[2], sel=sel, out=out[2]);
19    Mux(a=a[3], b=b[3], sel=sel, out=out[3]);
20    Mux(a=a[4], b=b[4], sel=sel, out=out[4]);
21    Mux(a=a[5], b=b[5], sel=sel, out=out[5]);
22    Mux(a=a[6], b=b[6], sel=sel, out=out[6]);
23    Mux(a=a[7], b=b[7], sel=sel, out=out[7]);
24    Mux(a=a[8], b=b[8], sel=sel, out=out[8]);
25    Mux(a=a[9], b=b[9], sel=sel, out=out[9]);
26    Mux(a=a[10], b=b[10], sel=sel, out=out[10]);
27    Mux(a=a[11], b=b[11], sel=sel, out=out[11]);
28    Mux(a=a[12], b=b[12], sel=sel, out=out[12]);
29    Mux(a=a[13], b=b[13], sel=sel, out=out[13]);
30    Mux(a=a[14], b=b[14], sel=sel, out=out[14]);
31    Mux(a=a[15], b=b[15], sel=sel, out=out[15]);
32}
```