Files

46 lines
1.2 KiB
Plaintext

// 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:
Not(in=sel[0],out=negSel1);
Not(in=sel[1],out=negSel2);
Not(in=sel[2],out=negSel3);
And(a=in,b=sel[0],out=out1);
And(a=in,b=negSel1,out=out2);
And(a=in,b=sel[1],out=out3);
And(a=in,b=negSel2,out=out4);
And(a=in,b=sel[2],out=out5);
And(a=in,b=negSel3,out=out6);
And(a=out1,b=out3,out=outX11);
And(a=out2,b=out3,out=outX10);
And(a=out1,b=out4,out=outX01);
And(a=out2,b=out4,out=outX00);
And(a=outX11,b=out5,out=h);
And(a=outX10,b=out5,out=g);
And(a=outX01,b=out5,out=f);
And(a=outX00,b=out5,out=e);
And(a=outX11,b=out6,out=d);
And(a=outX10,b=out6,out=c);
And(a=outX01,b=out6,out=b);
And(a=outX00,b=out6,out=a);
}