forked from cccnqu/co107a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDMux8Way.hdl
55 lines (44 loc) · 1.49 KB
/
DMux8Way.hdl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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=sel0inv);
Not(in=sel[1], out=sel1inv);
Not(in=sel[2], out=sel2inv);
And(a=in, b=sel0inv, out=a1);
And(a=a1, b=sel1inv, out=a2);
And(a=a2, b=sel2inv, out=a);
And(a=in, b=sel[0], out=b1);
And(a=b1, b=sel1inv, out=b2);
And(a=b2, b=sel2inv, out=b);
And(a=in, b=sel0inv, out=c1);
And(a=c1, b=sel[1], out=c2);
And(a=c2, b=sel2inv, out=c);
And(a=in, b=sel[0], out=d1);
And(a=d1, b=sel[1], out=d2);
And(a=d2, b=sel2inv, out=d);
And(a=in, b=sel0inv, out=e1);
And(a=e1, b=sel1inv, out=e2);
And(a=e2, b=sel[2], out=e);
And(a=in, b=sel[0], out=f1);
And(a=f1, b=sel1inv, out=f2);
And(a=f2, b=sel[2], out=f);
And(a=in, b=sel0inv, out=g1);
And(a=g1, b=sel[1], out=g2);
And(a=g2, b=sel[2], out=g);
And(a=in, b=sel[0], out=h1);
And(a=h1, b=sel[1], out=h2);
And(a=h2, b=sel[2], out=h);
}