Skip to content

Commit 15188bf

Browse files
committed
Mirror the current website projects.
1 parent 09f7b5e commit 15188bf

File tree

257 files changed

+78402
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+78402
-2
lines changed

.DS_Store

6 KB
Binary file not shown.

00/file.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The only purpose of this file is to practice submitting files
2+
in the Nand to Tetris course websites in Coursera.
3+
4+
There is no need to modify the contents of this file.
5+
All you have to do is submit it as is, following the
6+
Project 0 guidelines in the website.

01/And.cmp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| a | b | out |
2+
| 0 | 0 | 0 |
3+
| 0 | 1 | 0 |
4+
| 1 | 0 | 0 |
5+
| 1 | 1 | 1 |

And.hdl renamed to 01/And.hdl

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
// and the book "The Elements of Computing Systems"
33
// by Nisan and Schocken, MIT Press.
44
// File name: projects/01/And.hdl
5+
56
/**
6-
* out = ((a == 1) & (b == 1)), 1, 0)
7+
* And gate:
8+
* out = 1 if (a == 1 and b == 1)
9+
* 0 otherwise
710
*/
11+
812
CHIP And {
913
IN a, b;
1014
OUT out;
1115

1216
PARTS:
1317
// Put your code here:
14-
}
18+
}

01/And.tst

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/And.tst
5+
6+
load And.hdl,
7+
output-file And.out,
8+
compare-to And.cmp,
9+
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
10+
11+
set a 0,
12+
set b 0,
13+
eval,
14+
output;
15+
16+
set a 0,
17+
set b 1,
18+
eval,
19+
output;
20+
21+
set a 1,
22+
set b 0,
23+
eval,
24+
output;
25+
26+
set a 1,
27+
set b 1,
28+
eval,
29+
output;

01/And16.cmp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
| a | b | out |
2+
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
3+
| 0000000000000000 | 1111111111111111 | 0000000000000000 |
4+
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
5+
| 1010101010101010 | 0101010101010101 | 0000000000000000 |
6+
| 0011110011000011 | 0000111111110000 | 0000110011000000 |
7+
| 0001001000110100 | 1001100001110110 | 0001000000110100 |

01/And16.hdl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/And16.hdl
5+
6+
/**
7+
* 16-bit bitwise And:
8+
* for i = 0..15: out[i] = (a[i] and b[i])
9+
*/
10+
11+
CHIP And16 {
12+
IN a[16], b[16];
13+
OUT out[16];
14+
15+
PARTS:
16+
// Put your code here:
17+
}

01/And16.tst

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/And16.tst
5+
6+
load And16.hdl,
7+
output-file And16.out,
8+
compare-to And16.cmp,
9+
output-list a%B1.16.1 b%B1.16.1 out%B1.16.1;
10+
11+
set a %B0000000000000000,
12+
set b %B0000000000000000,
13+
eval,
14+
output;
15+
16+
set a %B0000000000000000,
17+
set b %B1111111111111111,
18+
eval,
19+
output;
20+
21+
set a %B1111111111111111,
22+
set b %B1111111111111111,
23+
eval,
24+
output;
25+
26+
set a %B1010101010101010,
27+
set b %B0101010101010101,
28+
eval,
29+
output;
30+
31+
set a %B0011110011000011,
32+
set b %B0000111111110000,
33+
eval,
34+
output;
35+
36+
set a %B0001001000110100,
37+
set b %B1001100001110110,
38+
eval,
39+
output;

01/DMux.cmp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| in | sel | a | b |
2+
| 0 | 0 | 0 | 0 |
3+
| 0 | 1 | 0 | 0 |
4+
| 1 | 0 | 1 | 0 |
5+
| 1 | 1 | 0 | 1 |

01/DMux.hdl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux.hdl
5+
6+
/**
7+
* Demultiplexor:
8+
* {a, b} = {in, 0} if sel == 0
9+
* {0, in} if sel == 1
10+
*/
11+
12+
CHIP DMux {
13+
IN in, sel;
14+
OUT a, b;
15+
16+
PARTS:
17+
// Put your code here:
18+
}

01/DMux.tst

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux.tst
5+
6+
load DMux.hdl,
7+
output-file DMux.out,
8+
compare-to DMux.cmp,
9+
output-list in%B3.1.3 sel%B3.1.3 a%B3.1.3 b%B3.1.3;
10+
11+
set in 0,
12+
set sel 0,
13+
eval,
14+
output;
15+
16+
set sel 1,
17+
eval,
18+
output;
19+
20+
set in 1,
21+
set sel 0,
22+
eval,
23+
output;
24+
25+
set sel 1,
26+
eval,
27+
output;

01/DMux4Way.cmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| in | sel | a | b | c | d |
2+
| 0 | 00 | 0 | 0 | 0 | 0 |
3+
| 0 | 01 | 0 | 0 | 0 | 0 |
4+
| 0 | 10 | 0 | 0 | 0 | 0 |
5+
| 0 | 11 | 0 | 0 | 0 | 0 |
6+
| 1 | 00 | 1 | 0 | 0 | 0 |
7+
| 1 | 01 | 0 | 1 | 0 | 0 |
8+
| 1 | 10 | 0 | 0 | 1 | 0 |
9+
| 1 | 11 | 0 | 0 | 0 | 1 |

01/DMux4Way.hdl

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux4Way.hdl
5+
6+
/**
7+
* 4-way demultiplexor:
8+
* {a, b, c, d} = {in, 0, 0, 0} if sel == 00
9+
* {0, in, 0, 0} if sel == 01
10+
* {0, 0, in, 0} if sel == 10
11+
* {0, 0, 0, in} if sel == 11
12+
*/
13+
14+
CHIP DMux4Way {
15+
IN in, sel[2];
16+
OUT a, b, c, d;
17+
18+
PARTS:
19+
// Put your code here:
20+
}

01/DMux4Way.tst

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux4Way.tst
5+
6+
load DMux4Way.hdl,
7+
output-file DMux4Way.out,
8+
compare-to DMux4Way.cmp,
9+
output-list in%B2.1.2 sel%B2.2.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2;
10+
11+
set in 0,
12+
set sel %B00,
13+
eval,
14+
output;
15+
16+
set sel %B01,
17+
eval,
18+
output;
19+
20+
set sel %B10,
21+
eval,
22+
output;
23+
24+
set sel %B11,
25+
eval,
26+
output;
27+
28+
set in 1,
29+
set sel %B00,
30+
eval,
31+
output;
32+
33+
set sel %B01,
34+
eval,
35+
output;
36+
37+
set sel %B10,
38+
eval,
39+
output;
40+
41+
set sel %B11,
42+
eval,
43+
output;

01/DMux8Way.cmp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
| in | sel | a | b | c | d | e | f | g | h |
2+
| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
3+
| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
4+
| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
5+
| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
6+
| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7+
| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
8+
| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
9+
| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
10+
| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
11+
| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
12+
| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
13+
| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
14+
| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
15+
| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
16+
| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
17+
| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

01/DMux8Way.hdl

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux8Way.hdl
5+
6+
/**
7+
* 8-way demultiplexor:
8+
* {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000
9+
* {0, in, 0, 0, 0, 0, 0, 0} if sel == 001
10+
* etc.
11+
* {0, 0, 0, 0, 0, 0, 0, in} if sel == 111
12+
*/
13+
14+
CHIP DMux8Way {
15+
IN in, sel[3];
16+
OUT a, b, c, d, e, f, g, h;
17+
18+
PARTS:
19+
// Put your code here:
20+
}

01/DMux8Way.tst

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// This file is part of www.nand2tetris.org
2+
// and the book "The Elements of Computing Systems"
3+
// by Nisan and Schocken, MIT Press.
4+
// File name: projects/01/DMux8Way.tst
5+
6+
load DMux8Way.hdl,
7+
output-file DMux8Way.out,
8+
compare-to DMux8Way.cmp,
9+
output-list in%B2.1.2 sel%B2.3.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2 e%B2.1.2 f%B2.1.2 g%B2.1.2 h%B2.1.2;
10+
11+
set in 0,
12+
set sel %B000,
13+
eval,
14+
output;
15+
16+
set sel %B001,
17+
eval,
18+
output;
19+
20+
set sel %B010,
21+
eval,
22+
output;
23+
24+
set sel %B011,
25+
eval,
26+
output;
27+
28+
set sel %B100,
29+
eval,
30+
output;
31+
32+
set sel %B101,
33+
eval,
34+
output;
35+
36+
set sel %B110,
37+
eval,
38+
output;
39+
40+
set sel %B111,
41+
eval,
42+
output;
43+
44+
set in 1,
45+
set sel %B000,
46+
eval,
47+
output;
48+
49+
set sel %B001,
50+
eval,
51+
output;
52+
53+
set sel %B010,
54+
eval,
55+
output;
56+
57+
set sel %B011,
58+
eval,
59+
output;
60+
61+
set sel %B100,
62+
eval,
63+
output;
64+
65+
set sel %B101,
66+
eval,
67+
output;
68+
69+
set sel %B110,
70+
eval,
71+
output;
72+
73+
set sel %B111,
74+
eval,
75+
output;

01/Mux.cmp

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| a | b | sel | out |
2+
| 0 | 0 | 0 | 0 |
3+
| 0 | 0 | 1 | 0 |
4+
| 0 | 1 | 0 | 0 |
5+
| 0 | 1 | 1 | 1 |
6+
| 1 | 0 | 0 | 1 |
7+
| 1 | 0 | 1 | 0 |
8+
| 1 | 1 | 0 | 1 |
9+
| 1 | 1 | 1 | 1 |

0 commit comments

Comments
 (0)