// 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/Mux4Way16.hdl /** * 4-way 16-bit multiplexor: * out = a if sel == 00 * b if sel == 01 * c if sel == 10 * d if sel == 11 */ CHIP Mux4Way16 { IN a[16], b[16], c[16], d[16], sel[2]; OUT out[16]; PARTS: Not(in=sel[0], out=w1); Not(in=sel[1], out=w2); And(a=w1, b=w2, out=w3); And(a=sel[0], b=w2, out=w4); And(a=w1, b=sel[1], out=w5); And(a=sel[0], b=sel[1], out=w6); And(a=a[0], b=w3, out=wa0); And(a=a[1], b=w3, out=wa1); And(a=a[2], b=w3, out=wa2); And(a=a[3], b=w3, out=wa3); And(a=a[4], b=w3, out=wa4); And(a=a[5], b=w3, out=wa5); And(a=a[6], b=w3, out=wa6); And(a=a[7], b=w3, out=wa7); And(a=a[8], b=w3, out=wa8); And(a=a[9], b=w3, out=wa9); And(a=a[10], b=w3, out=wa10); And(a=a[11], b=w3, out=wa11); And(a=a[12], b=w3, out=wa12); And(a=a[13], b=w3, out=wa13); And(a=a[14], b=w3, out=wa14); And(a=a[15], b=w3, out=wa15); And(a=b[0], b=w4, out=wb0); And(a=b[1], b=w4, out=wb1); And(a=b[2], b=w4, out=wb2); And(a=b[3], b=w4, out=wb3); And(a=b[4], b=w4, out=wb4); And(a=b[5], b=w4, out=wb5); And(a=b[6], b=w4, out=wb6); And(a=b[7], b=w4, out=wb7); And(a=b[8], b=w4, out=wb8); And(a=b[9], b=w4, out=wb9); And(a=b[10], b=w4, out=wb10); And(a=b[11], b=w4, out=wb11); And(a=b[12], b=w4, out=wb12); And(a=b[13], b=w4, out=wb13); And(a=b[14], b=w4, out=wb14); And(a=b[15], b=w4, out=wb15); And(a=c[0], b=w5, out=wc0); And(a=c[1], b=w5, out=wc1); And(a=c[2], b=w5, out=wc2); And(a=c[3], b=w5, out=wc3); And(a=c[4], b=w5, out=wc4); And(a=c[5], b=w5, out=wc5); And(a=c[6], b=w5, out=wc6); And(a=c[7], b=w5, out=wc7); And(a=c[8], b=w5, out=wc8); And(a=c[9], b=w5, out=wc9); And(a=c[10], b=w5, out=wc10); And(a=c[11], b=w5, out=wc11); And(a=c[12], b=w5, out=wc12); And(a=c[13], b=w5, out=wc13); And(a=c[14], b=w5, out=wc14); And(a=c[15], b=w5, out=wc15); And(a=d[0], b=w6, out=wd0); And(a=d[1], b=w6, out=wd1); And(a=d[2], b=w6, out=wd2); And(a=d[3], b=w6, out=wd3); And(a=d[4], b=w6, out=wd4); And(a=d[5], b=w6, out=wd5); And(a=d[6], b=w6, out=wd6); And(a=d[7], b=w6, out=wd7); And(a=d[8], b=w6, out=wd8); And(a=d[9], b=w6, out=wd9); And(a=d[10], b=w6, out=wd10); And(a=d[11], b=w6, out=wd11); And(a=d[12], b=w6, out=wd12); And(a=d[13], b=w6, out=wd13); And(a=d[14], b=w6, out=wd14); And(a=d[15], b=w6, out=wd15); Or(a=wa0, b=wb0, out=we0); Or(a=wa1, b=wb1, out=we1); Or(a=wa2, b=wb2, out=we2); Or(a=wa3, b=wb3, out=we3); Or(a=wa4, b=wb4, out=we4); Or(a=wa5, b=wb5, out=we5); Or(a=wa6, b=wb6, out=we6); Or(a=wa7, b=wb7, out=we7); Or(a=wa8, b=wb8, out=we8); Or(a=wa9, b=wb9, out=we9); Or(a=wa10, b=wb10, out=we10); Or(a=wa11, b=wb11, out=we11); Or(a=wa12, b=wb12, out=we12); Or(a=wa13, b=wb13, out=we13); Or(a=wa14, b=wb14, out=we14); Or(a=wa15, b=wb15, out=we15); Or(a=wc0, b=wd0, out=wf0); Or(a=wc1, b=wd1, out=wf1); Or(a=wc2, b=wd2, out=wf2); Or(a=wc3, b=wd3, out=wf3); Or(a=wc4, b=wd4, out=wf4); Or(a=wc5, b=wd5, out=wf5); Or(a=wc6, b=wd6, out=wf6); Or(a=wc7, b=wd7, out=wf7); Or(a=wc8, b=wd8, out=wf8); Or(a=wc9, b=wd9, out=wf9); Or(a=wc10, b=wd10, out=wf10); Or(a=wc11, b=wd11, out=wf11); Or(a=wc12, b=wd12, out=wf12); Or(a=wc13, b=wd13, out=wf13); Or(a=wc14, b=wd14, out=wf14); Or(a=wc15, b=wd15, out=wf15); Or(a=we0, b=wf0, out=out[0]); Or(a=we1, b=wf1, out=out[1]); Or(a=we2, b=wf2, out=out[2]); Or(a=we3, b=wf3, out=out[3]); Or(a=we4, b=wf4, out=out[4]); Or(a=we5, b=wf5, out=out[5]); Or(a=we6, b=wf6, out=out[6]); Or(a=we7, b=wf7, out=out[7]); Or(a=we8, b=wf8, out=out[8]); Or(a=we9, b=wf9, out=out[9]); Or(a=we10, b=wf10, out=out[10]); Or(a=we11, b=wf11, out=out[11]); Or(a=we12, b=wf12, out=out[12]); Or(a=we13, b=wf13, out=out[13]); Or(a=we14, b=wf14, out=out[14]); Or(a=we15, b=wf15, out=out[15]); // Put your code here: }