Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nand2tetris/projects/1/And.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ CHIP And {
OUT out;

PARTS:
//// Replace this comment with your code.
Nand(a = a, b = b, out = tmp);
Not(in = tmp, out = out);
}
5 changes: 5 additions & 0 deletions nand2tetris/projects/1/And.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| a | b |out|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
17 changes: 16 additions & 1 deletion nand2tetris/projects/1/And16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,20 @@ CHIP And16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
And(a = a[0], b = b[0], out = out[0]);
And(a = a[1], b = b[1], out = out[1]);
And(a = a[2], b = b[2], out = out[2]);
And(a = a[3], b = b[3], out = out[3]);
And(a = a[4], b = b[4], out = out[4]);
And(a = a[5], b = b[5], out = out[5]);
And(a = a[6], b = b[6], out = out[6]);
And(a = a[7], b = b[7], out = out[7]);
And(a = a[8], b = b[8], out = out[8]);
And(a = a[9], b = b[9], out = out[9]);
And(a = a[10], b = b[10], out = out[10]);
And(a = a[11], b = b[11], out = out[11]);
And(a = a[12], b = b[12], out = out[12]);
And(a = a[13], b = b[13], out = out[13]);
And(a = a[14], b = b[14], out = out[14]);
And(a = a[15], b = b[15], out = out[15]);
}
7 changes: 7 additions & 0 deletions nand2tetris/projects/1/And16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 0000000000000000 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 0000000000000000 |
| 0011110011000011 | 0000111111110000 | 0000110011000000 |
| 0001001000110100 | 1001100001110110 | 0001000000110100 |
5 changes: 4 additions & 1 deletion nand2tetris/projects/1/DMux.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ CHIP DMux {
OUT a, b;

PARTS:
//// Replace this comment with your code.
Not(in = sel, out = sela);

And(a = in, b = sela, out = a);
And(a = in, b = sel, out = b);
}
5 changes: 5 additions & 0 deletions nand2tetris/projects/1/DMux.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
|in |sel| a | b |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
14 changes: 13 additions & 1 deletion nand2tetris/projects/1/DMux4Way.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ CHIP DMux4Way {
OUT a, b, c, d;

PARTS:
//// Replace this comment with your code.
Not(in = sel[0], out = notsel0);
Not(in = sel[1], out = notsel1);

And(a = notsel1, b = notsel0, out = sel00);
And(a = notsel1, b = sel[0], out = sel01);
And(a = sel[1], b = notsel0, out = sel10);
And(a = sel[1], b = sel[0], out = sel11);


And(a = in, b = sel00, out = a);
And(a = in, b = sel01, out = b);
And(a = in, b = sel10, out = c);
And(a = in, b = sel11, out = d);
}
9 changes: 9 additions & 0 deletions nand2tetris/projects/1/DMux4Way.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
|in | sel | a | b | c | d |
| 0 | 00 | 0 | 0 | 0 | 0 |
| 0 | 01 | 0 | 0 | 0 | 0 |
| 0 | 10 | 0 | 0 | 0 | 0 |
| 0 | 11 | 0 | 0 | 0 | 0 |
| 1 | 00 | 1 | 0 | 0 | 0 |
| 1 | 01 | 0 | 1 | 0 | 0 |
| 1 | 10 | 0 | 0 | 1 | 0 |
| 1 | 11 | 0 | 0 | 0 | 1 |
29 changes: 28 additions & 1 deletion nand2tetris/projects/1/DMux8Way.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,32 @@ CHIP DMux8Way {
OUT a, b, c, d, e, f, g, h;

PARTS:
//// Replace this comment with your code.

Not(in = sel[0], out = notsel0);
Not(in = sel[1], out = notsel1);
Not(in = sel[2], out = notsel2);

And(a = notsel1, b = notsel0, out = sel00);
And(a = notsel1, b = sel[0], out = sel01);
And(a = sel[1], b = notsel0, out = sel10);
And(a = sel[1], b = sel[0], out = sel11);

And(a = notsel2, b = sel00, out = sel000);
And(a = notsel2, b = sel01, out = sel001);
And(a = notsel2, b = sel10, out = sel010);
And(a = notsel2, b = sel11, out = sel011);
And(a = sel[2], b = sel00, out = sel100);
And(a = sel[2], b = sel01, out = sel101);
And(a = sel[2], b = sel10, out = sel110);
And(a = sel[2], b = sel11, out = sel111);

And(a = in, b = sel000, out = a);
And(a = in, b = sel001, out = b);
And(a = in, b = sel010, out = c);
And(a = in, b = sel011, out = d);
And(a = in, b = sel100, out = e);
And(a = in, b = sel101, out = f);
And(a = in, b = sel110, out = g);
And(a = in, b = sel111, out = h);

}
17 changes: 17 additions & 0 deletions nand2tetris/projects/1/DMux8Way.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
|in | sel | a | b | c | d | e | f | g | h |
| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
5 changes: 4 additions & 1 deletion nand2tetris/projects/1/Mux.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ CHIP Mux {
OUT out;

PARTS:
//// Replace this comment with your code.
Not(in = sel, out = notsel);
And(a = a, b = notsel, out = sela);
And(a = sel, b = b, out = selb);
Or(a = sela, b = selb, out = out);
}
9 changes: 9 additions & 0 deletions nand2tetris/projects/1/Mux.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
| a | b |sel|out|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
17 changes: 16 additions & 1 deletion nand2tetris/projects/1/Mux16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,20 @@ CHIP Mux16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
Mux(a = a[0], b = b[0], sel = sel, out = out[0]);
Mux(a = a[1], b = b[1], sel = sel, out = out[1]);
Mux(a = a[2], b = b[2], sel = sel, out = out[2]);
Mux(a = a[3], b = b[3], sel = sel, out = out[3]);
Mux(a = a[4], b = b[4], sel = sel, out = out[4]);
Mux(a = a[5], b = b[5], sel = sel, out = out[5]);
Mux(a = a[6], b = b[6], sel = sel, out = out[6]);
Mux(a = a[7], b = b[7], sel = sel, out = out[7]);
Mux(a = a[8], b = b[8], sel = sel, out = out[8]);
Mux(a = a[9], b = b[9], sel = sel, out = out[9]);
Mux(a = a[10], b = b[10], sel = sel, out = out[10]);
Mux(a = a[11], b = b[11], sel = sel, out = out[11]);
Mux(a = a[12], b = b[12], sel = sel, out = out[12]);
Mux(a = a[13], b = b[13], sel = sel, out = out[13]);
Mux(a = a[14], b = b[14], sel = sel, out = out[14]);
Mux(a = a[15], b = b[15], sel = sel, out = out[15]);
}
9 changes: 9 additions & 0 deletions nand2tetris/projects/1/Mux16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
| a | b |sel| out |
| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 |
| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 |
| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 |
| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 |
| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 |
18 changes: 17 additions & 1 deletion nand2tetris/projects/1/Mux4Way16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,21 @@ CHIP Mux4Way16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
Not(in = sel[0], out = notsel0);
Not(in = sel[1], out = notsel1);

Nand(a = notsel1, b = notsel0, out = sel00);
Nand(a = notsel1, b = sel[0], out = sel01);
Nand(a = sel[1], b = notsel0, out = sel10);
Nand(a = sel[1], b = sel[0], out = sel11);

Mux16(a = a, b = false, sel = sel00, out = sela);
Mux16(a = b, b = false, sel = sel01, out = selb);
Mux16(a = c, b = false, sel = sel10, out = selc);
Mux16(a = d, b = false, sel = sel11, out = seld);

Or16(a = sela, b = selb, out = orAb);
Or16(a = selc, b = seld, out = orCd);

Or16(a = orAb, b = orCd, out = out);
}
9 changes: 9 additions & 0 deletions nand2tetris/projects/1/Mux4Way16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
| a | b | c | d | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 |
5 changes: 4 additions & 1 deletion nand2tetris/projects/1/Mux8Way16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ CHIP Mux8Way16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
Mux4Way16(a = a, b = b, c = c, d = d, sel = sel[0..1], out = abcd);
Mux4Way16(a = e, b = f, c = g, d = h, sel = sel[0..1], out = efgh);

Mux16(a = abcd, b = efgh, sel = sel[2], out = out);
}
17 changes: 17 additions & 0 deletions nand2tetris/projects/1/Mux8Way16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
| a | b | c | d | e | f | g | h | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 |
2 changes: 1 addition & 1 deletion nand2tetris/projects/1/Not.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ CHIP Not {
OUT out;

PARTS:
//// Replace this comment with your code.
Nand(a = in, b = in, out = out);
}
3 changes: 3 additions & 0 deletions nand2tetris/projects/1/Not.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
|in |out|
| 0 | 1 |
| 1 | 0 |
17 changes: 16 additions & 1 deletion nand2tetris/projects/1/Not16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,20 @@ CHIP Not16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
Not(in = in[0], out = out[0]);
Not(in = in[1], out = out[1]);
Not(in = in[2], out = out[2]);
Not(in = in[3], out = out[3]);
Not(in = in[4], out = out[4]);
Not(in = in[5], out = out[5]);
Not(in = in[6], out = out[6]);
Not(in = in[7], out = out[7]);
Not(in = in[8], out = out[8]);
Not(in = in[9], out = out[9]);
Not(in = in[10], out = out[10]);
Not(in = in[11], out = out[11]);
Not(in = in[12], out = out[12]);
Not(in = in[13], out = out[13]);
Not(in = in[14], out = out[14]);
Not(in = in[15], out = out[15]);
}
6 changes: 6 additions & 0 deletions nand2tetris/projects/1/Not16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
| in | out |
| 0000000000000000 | 1111111111111111 |
| 1111111111111111 | 0000000000000000 |
| 1010101010101010 | 0101010101010101 |
| 0011110011000011 | 1100001100111100 |
| 0001001000110100 | 1110110111001011 |
4 changes: 3 additions & 1 deletion nand2tetris/projects/1/Or.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ CHIP Or {
OUT out;

PARTS:
//// Replace this comment with your code.
Not(in = a, out = nota);
Not(in = b, out = notb);
Nand(a = nota, b = notb, out = out);
}
5 changes: 5 additions & 0 deletions nand2tetris/projects/1/Or.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| a | b |out|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
17 changes: 16 additions & 1 deletion nand2tetris/projects/1/Or16.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,20 @@ CHIP Or16 {
OUT out[16];

PARTS:
//// Replace this comment with your code.
Or(a = a[0], b = b[0], out = out[0]);
Or(a = a[1], b = b[1], out = out[1]);
Or(a = a[2], b = b[2], out = out[2]);
Or(a = a[3], b = b[3], out = out[3]);
Or(a = a[4], b = b[4], out = out[4]);
Or(a = a[5], b = b[5], out = out[5]);
Or(a = a[6], b = b[6], out = out[6]);
Or(a = a[7], b = b[7], out = out[7]);
Or(a = a[8], b = b[8], out = out[8]);
Or(a = a[9], b = b[9], out = out[9]);
Or(a = a[10], b = b[10], out = out[10]);
Or(a = a[11], b = b[11], out = out[11]);
Or(a = a[12], b = b[12], out = out[12]);
Or(a = a[13], b = b[13], out = out[13]);
Or(a = a[14], b = b[14], out = out[14]);
Or(a = a[15], b = b[15], out = out[15]);
}
7 changes: 7 additions & 0 deletions nand2tetris/projects/1/Or16.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 1111111111111111 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 1111111111111111 |
| 0011110011000011 | 0000111111110000 | 0011111111110011 |
| 0001001000110100 | 1001100001110110 | 1001101001110110 |
10 changes: 9 additions & 1 deletion nand2tetris/projects/1/Or8Way.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ CHIP Or8Way {
OUT out;

PARTS:
//// Replace this comment with your code.
Or(a = in[0], b = in[1], out = a0);
Or(a = in[2], b = in[3], out = a2);
Or(a = in[4], b = in[5], out = a4);
Or(a = in[6], b = in[7], out = a6);

Or(a = a0, b = a2, out = b0);
Or(a = a4, b = a4, out = b1);

Or(a = b0, b = b1, out = out);
}
6 changes: 6 additions & 0 deletions nand2tetris/projects/1/Or8Way.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
| in |out|
| 00000000 | 0 |
| 11111111 | 1 |
| 00010000 | 1 |
| 00000001 | 1 |
| 00100110 | 1 |
7 changes: 6 additions & 1 deletion nand2tetris/projects/1/Xor.hdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ CHIP Xor {
OUT out;

PARTS:
//// Replace this comment with your code.
Not(in = a, out = nota);
Not(in = b, out = notb);

And(a = a, b = notb, out = aAndNotb);
And(a = nota, b = b, out = notaAndb);
Or(a = aAndNotb, b = notaAndb, out = out);
}
5 changes: 5 additions & 0 deletions nand2tetris/projects/1/Xor.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| a | b |out|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Binary file added nand2tetris/projects/1/project1.zip
Binary file not shown.