// 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:
    Mux(sel=sel, a=a[0], b=b[0], out=out[0]);
    Mux(sel=sel, a=a[1], b=b[1], out=out[1]);
    Mux(sel=sel, a=a[2], b=b[2], out=out[2]);
    Mux(sel=sel, a=a[3], b=b[3], out=out[3]);
    Mux(sel=sel, a=a[4], b=b[4], out=out[4]);
    Mux(sel=sel, a=a[5], b=b[5], out=out[5]);
    Mux(sel=sel, a=a[6], b=b[6], out=out[6]);
    Mux(sel=sel, a=a[7], b=b[7], out=out[7]);
    Mux(sel=sel, a=a[8], b=b[8], out=out[8]);
    Mux(sel=sel, a=a[9], b=b[9], out=out[9]);
    Mux(sel=sel, a=a[10], b=b[10], out=out[10]);
    Mux(sel=sel, a=a[11], b=b[11], out=out[11]);
    Mux(sel=sel, a=a[12], b=b[12], out=out[12]);
    Mux(sel=sel, a=a[13], b=b[13], out=out[13]);
    Mux(sel=sel, a=a[14], b=b[14], out=out[14]);
    Mux(sel=sel, a=a[15], b=b[15], out=out[15]);
}
