// 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/DMux8Way.hdl /** * 8-way demultiplexor: * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000 * {0, in, 0, 0, 0, 0, 0, 0} if sel == 001 * etc. * {0, 0, 0, 0, 0, 0, 0, in} if sel == 111 */ CHIP DMux8Way { IN in, sel[3]; OUT a, b, c, d, e, f, g, h; PARTS: // Put your code here: Not(in=sel[0], out=w0); Not(in=sel[1], out=w1); Not(in=sel[2], out=w2); And(a=w0, b=w1, out=w3); And(a=w2, b=w3, out=w4); And(a=sel[0], b=w1, out=w5); And(a=w2, b=w5, out=w6); And(a=w0, b=sel[1], out=w7); And(a=w2, b=w7, out=w8); And(a=sel[0], b=sel[1], out=w9); And(a=w2, b=w9, out=w10); And(a=w0, b=w1, out=w11); And(a=sel[2], b=w11, out=w12); And(a=sel[0], b=w1, out=w13); And(a=sel[2], b=w13, out=w14); And(a=w0, b=sel[1], out=w15); And(a=sel[2], b=w15, out=w16); And(a=sel[0], b=sel[1], out=w17); And(a=sel[2], b=w17, out=w18); And(a=in, b=w4, out=a); And(a=in, b=w6, out=b); And(a=in, b=w8, out=c); And(a=in, b=w10, out=d); And(a=in, b=w12, out=e); And(a=in, b=w14, out=f); And(a=in, b=w16, out=g); And(a=in, b=w18, out=h); }