-
Notifications
You must be signed in to change notification settings - Fork 1
/
Or16.hdl
96 lines (62 loc) · 1.83 KB
/
Or16.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// 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/Or16.hdl
/**
* 16-bit bitwise Or:
* for i = 0..15 out[i] = (a[i] or b[i])
*/
CHIP Or16 {
IN a[16], b[16];
OUT out[16];
PARTS:
// Put your code here:
Nand(a=a[0],b=a[0],out=w1);
Nand(a=b[0],b=b[0],out=w2);
Nand(a=w1,b=w2,out=out[0]);
Nand(a=a[1],b=a[1],out=w3);
Nand(a=b[1],b=b[1],out=w4);
Nand(a=w3,b=w4,out=out[1]);
Nand(a=a[2],b=a[2],out=w5);
Nand(a=b[2],b=b[2],out=w6);
Nand(a=w5,b=w6,out=out[2]);
Nand(a=a[3],b=a[3],out=w7);
Nand(a=b[3],b=b[3],out=w8);
Nand(a=w7,b=w8,out=out[3]);
Nand(a=a[4],b=a[4],out=w9);
Nand(a=b[4],b=b[4],out=w10);
Nand(a=w9,b=w10,out=out[4]);
Nand(a=a[5],b=a[5],out=w11);
Nand(a=b[5],b=b[5],out=w12);
Nand(a=w11,b=w12,out=out[5]);
Nand(a=a[6],b=a[6],out=w13);
Nand(a=b[6],b=b[6],out=w14);
Nand(a=w13,b=w14,out=out[6]);
Nand(a=a[7],b=a[7],out=w15);
Nand(a=b[7],b=b[7],out=w16);
Nand(a=w15,b=w16,out=out[7]);
Nand(a=a[8],b=a[8],out=w17);
Nand(a=b[8],b=b[8],out=w18);
Nand(a=w17,b=w18,out=out[8]);
Nand(a=a[9],b=a[9],out=w19);
Nand(a=b[9],b=b[9],out=w20);
Nand(a=w19,b=w20,out=out[9]);
Nand(a=a[10],b=a[10],out=w21);
Nand(a=b[10],b=b[10],out=w22);
Nand(a=w21,b=w22,out=out[10]);
Nand(a=a[11],b=a[11],out=w23);
Nand(a=b[11],b=b[11],out=w24);
Nand(a=w23,b=w24,out=out[11]);
Nand(a=a[12],b=a[12],out=w25);
Nand(a=b[12],b=b[12],out=w26);
Nand(a=w25,b=w26,out=out[12]);
Nand(a=a[13],b=a[13],out=w27);
Nand(a=b[13],b=b[13],out=w28);
Nand(a=w27,b=w28,out=out[13]);
Nand(a=a[14],b=a[14],out=w29);
Nand(a=b[14],b=b[14],out=w30);
Nand(a=w29,b=w30,out=out[14]);
Nand(a=a[15],b=a[15],out=w31);
Nand(a=b[15],b=b[15],out=w32);
Nand(a=w31,b=w32,out=out[15]);
}