diff --git a/01/And.hdl b/01/And.hdl index e3698c1c..a28059de 100644 --- a/01/And.hdl +++ b/01/And.hdl @@ -15,4 +15,6 @@ CHIP And { PARTS: // Put your code here: + Nand(a=a,b=b,out = anandb ); + Nand(a=anandb,b=anandb,out = out); } diff --git a/01/And.out b/01/And.out new file mode 100644 index 00000000..8199ca54 --- /dev/null +++ b/01/And.out @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 1 | diff --git a/01/And16.hdl b/01/And16.hdl index b81bf101..b9c157a0 100644 --- a/01/And16.hdl +++ b/01/And16.hdl @@ -14,4 +14,21 @@ CHIP And16 { PARTS: // Put your code here: + //網路上找查的 + 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]); } \ No newline at end of file diff --git a/01/And16.out b/01/And16.out new file mode 100644 index 00000000..19abc5a8 --- /dev/null +++ b/01/And16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0000000000000000 | +| 1111111111111111 | 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0000000000000000 | +| 0011110011000011 | 0000111111110000 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 0000000000000000 | diff --git a/01/DMux.hdl b/01/DMux.hdl index e4fbb7ec..097bd548 100644 --- a/01/DMux.hdl +++ b/01/DMux.hdl @@ -15,4 +15,8 @@ CHIP DMux { PARTS: // Put your code here: + //網路上找查 + Not(in=sel, out=nsel); + And(a=nsel, b=in, out=a); + And(a=sel, b=in, out=b); } diff --git a/01/DMux.out b/01/DMux.out new file mode 100644 index 00000000..8079fd69 --- /dev/null +++ b/01/DMux.out @@ -0,0 +1,5 @@ +| in | sel | a | b | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1 | 1 | 0 | 0 | diff --git a/01/DMux4Way.hdl b/01/DMux4Way.hdl index cfdfcbb3..b461e52a 100644 --- a/01/DMux4Way.hdl +++ b/01/DMux4Way.hdl @@ -17,4 +17,8 @@ CHIP DMux4Way { PARTS: // Put your code here: + //網路上找查 + DMux(in=in, sel=sel[1], a=c1, b=c2); + DMux(in=c1, sel=sel[0], a=a, b=b); + DMux(in=c2, sel=sel[0], a=c, b=d); } \ No newline at end of file diff --git a/01/DMux4Way.out b/01/DMux4Way.out new file mode 100644 index 00000000..f5ae39c8 --- /dev/null +++ b/01/DMux4Way.out @@ -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 | 0 | 0 | 0 | 0 | +| 1 | 01 | 0 | 0 | 0 | 0 | +| 1 | 10 | 0 | 0 | 0 | 0 | +| 1 | 11 | 0 | 0 | 0 | 0 | diff --git a/01/DMux8Way.hdl b/01/DMux8Way.hdl index e24fcaae..1fc4babb 100644 --- a/01/DMux8Way.hdl +++ b/01/DMux8Way.hdl @@ -17,4 +17,8 @@ CHIP DMux8Way { PARTS: // Put your code here: + //網路上找查 + DMux(in=in, sel=sel[2], a=c1, b=c2); + DMux4Way(in=c1, sel[0]=sel[0], sel[1]=sel[1], a=a, b=b, c=c, d=d); + DMux4Way(in=c2, sel[0]=sel[0], sel[1]=sel[1], a=e, b=f, c=g, d=h); } \ No newline at end of file diff --git a/01/DMux8Way.out b/01/DMux8Way.out new file mode 100644 index 00000000..03f80ea1 --- /dev/null +++ b/01/DMux8Way.out @@ -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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | diff --git a/01/Mux.hdl b/01/Mux.hdl index 6220f3f7..904ebc68 100644 --- a/01/Mux.hdl +++ b/01/Mux.hdl @@ -15,4 +15,9 @@ CHIP Mux { PARTS: // Put your code here: + //網路上找查 + Not(in=sel, out=nsel); + And(a=sel, b=b, out=c1); + And(a=nsel, b=a, out=c2); + Or(a=c1, b=c2, out=out); } \ No newline at end of file diff --git a/01/Mux.out b/01/Mux.out new file mode 100644 index 00000000..b019d85f --- /dev/null +++ b/01/Mux.out @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 0 | +| 0 | 1 | 0 | 0 | +| 0 | 1 | 1 | 0 | +| 1 | 0 | 0 | 0 | +| 1 | 0 | 1 | 0 | +| 1 | 1 | 0 | 0 | +| 1 | 1 | 1 | 0 | diff --git a/01/Mux16.hdl b/01/Mux16.hdl index 3be57801..ae4df2d7 100644 --- a/01/Mux16.hdl +++ b/01/Mux16.hdl @@ -15,4 +15,21 @@ CHIP Mux16 { PARTS: // Put your code here: + //網路上找查 + 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]); } diff --git a/01/Mux16.out b/01/Mux16.out new file mode 100644 index 00000000..48a92a91 --- /dev/null +++ b/01/Mux16.out @@ -0,0 +1,9 @@ +| a | b | sel | out | +| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 | +| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 | +| 0000000000000000 | 0001001000110100 | 1 | 0000000000000000 | +| 1001100001110110 | 0000000000000000 | 0 | 0000000000000000 | +| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 1 | 0000000000000000 | diff --git a/01/Mux4Way16.hdl b/01/Mux4Way16.hdl index 45f1d278..03110051 100644 --- a/01/Mux4Way16.hdl +++ b/01/Mux4Way16.hdl @@ -17,4 +17,8 @@ CHIP Mux4Way16 { PARTS: // Put your code here: + //網路上找查 + Mux16(a=a, b=b, sel=sel[0], out=c1); + Mux16(a=c, b=d, sel=sel[0], out=c2); + Mux16(a=c1, b=c2, sel=sel[1], out=out); } \ No newline at end of file diff --git a/01/Mux4Way16.out b/01/Mux4Way16.out new file mode 100644 index 00000000..9dd254f5 --- /dev/null +++ b/01/Mux4Way16.out @@ -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 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0000000000000000 | diff --git a/01/Mux8Way16.hdl b/01/Mux8Way16.hdl index 4e6b2631..e36c7e7b 100644 --- a/01/Mux8Way16.hdl +++ b/01/Mux8Way16.hdl @@ -19,4 +19,8 @@ CHIP Mux8Way16 { PARTS: // Put your code here: + //網路上找查 + Mux4Way16(a=a, b=b, c=c, d=d, sel[0]=sel[0], sel[1]=sel[1], out=c1); + Mux4Way16(a=e, b=f, c=g, d=h, sel[0]=sel[0], sel[1]=sel[1], out=c2); + Mux16(a=c1, b=c2, sel=sel[2], out=out); } \ No newline at end of file diff --git a/01/Mux8Way16.out b/01/Mux8Way16.out new file mode 100644 index 00000000..c43ccf78 --- /dev/null +++ b/01/Mux8Way16.out @@ -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 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0000000000000000 | +| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 0000000000000000 | diff --git a/01/Not.out b/01/Not.out index 7b640920..e69de29b 100644 --- a/01/Not.out +++ b/01/Not.out @@ -1,3 +0,0 @@ -| in | out | -| 0 | 1 | -| 1 | 0 | diff --git a/01/Not16.hdl b/01/Not16.hdl index ee717fa8..49d10a7d 100644 --- a/01/Not16.hdl +++ b/01/Not16.hdl @@ -14,4 +14,21 @@ CHIP Not16 { PARTS: // Put your code here: + //網路上找查 + Nand(a=in[0], b=in[0], out=out[0]); + Nand(a=in[1], b=in[1], out=out[1]); + Nand(a=in[2], b=in[2], out=out[2]); + Nand(a=in[3], b=in[3], out=out[3]); + Nand(a=in[4], b=in[4], out=out[4]); + Nand(a=in[5], b=in[5], out=out[5]); + Nand(a=in[6], b=in[6], out=out[6]); + Nand(a=in[7], b=in[7], out=out[7]); + Nand(a=in[8], b=in[8], out=out[8]); + Nand(a=in[9], b=in[9], out=out[9]); + Nand(a=in[10], b=in[10], out=out[10]); + Nand(a=in[11], b=in[11], out=out[11]); + Nand(a=in[12], b=in[12], out=out[12]); + Nand(a=in[13], b=in[13], out=out[13]); + Nand(a=in[14], b=in[14], out=out[14]); + Nand(a=in[15], b=in[15], out=out[15]); } \ No newline at end of file diff --git a/01/Not16.out b/01/Not16.out new file mode 100644 index 00000000..cfa6696d --- /dev/null +++ b/01/Not16.out @@ -0,0 +1,6 @@ +| in | out | +| 0000000000000000 | 0000000000000000 | +| 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0000000000000000 | +| 0011110011000011 | 0000000000000000 | +| 0001001000110100 | 0000000000000000 | diff --git a/01/Or.hdl b/01/Or.hdl index 00fbea53..f70730ce 100644 --- a/01/Or.hdl +++ b/01/Or.hdl @@ -15,4 +15,7 @@ CHIP Or { PARTS: // Put your code here: + Nand(a=a, b=a, out=aa); + Nand(a=b, b=b, out=bb); + Nand(a=aa, b=bb, out=out); } diff --git a/01/Or.out b/01/Or.out new file mode 100644 index 00000000..9eea38e2 --- /dev/null +++ b/01/Or.out @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 0 | diff --git a/01/Or16.hdl b/01/Or16.hdl index 28097f40..f53e9523 100644 --- a/01/Or16.hdl +++ b/01/Or16.hdl @@ -14,4 +14,21 @@ CHIP Or16 { PARTS: // Put your code here: + //網路上找查 + 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]); } \ No newline at end of file diff --git a/01/Or16.out b/01/Or16.out new file mode 100644 index 00000000..19abc5a8 --- /dev/null +++ b/01/Or16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0000000000000000 | +| 1111111111111111 | 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0000000000000000 | +| 0011110011000011 | 0000111111110000 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 0000000000000000 | diff --git a/01/Or8Way.hdl b/01/Or8Way.hdl index db03a730..5b5300c1 100644 --- a/01/Or8Way.hdl +++ b/01/Or8Way.hdl @@ -14,4 +14,12 @@ CHIP Or8Way { PARTS: // Put your code here: + //網路上找查 + Or(a=in[0], b=in[1], out=c1); + Or(a=in[2], b=in[3], out=c2); + Or(a=in[4], b=in[5], out=c3); + Or(a=in[6], b=in[7], out=c4); + Or(a=c1, b=c2, out=c5); + Or(a=c3, b=c4, out=c6); + Or(a=c5, b=c6, out=out); } \ No newline at end of file diff --git a/01/Or8Way.out b/01/Or8Way.out new file mode 100644 index 00000000..69315131 --- /dev/null +++ b/01/Or8Way.out @@ -0,0 +1,6 @@ +| in | out | +| 00000000 | 0 | +| 11111111 | 0 | +| 00010000 | 0 | +| 00000001 | 0 | +| 00100110 | 0 | diff --git a/01/Xor.hdl b/01/Xor.hdl index 167947b5..c755c485 100644 --- a/01/Xor.hdl +++ b/01/Xor.hdl @@ -14,4 +14,8 @@ CHIP Xor { PARTS: // Put your code here: + //網路上找查 + Or(a=a, b=b, out=c1); + Nand(a=a, b=b, out=c2); + And(a=c1, b=c2, out=out); } \ No newline at end of file diff --git a/01/Xor.out b/01/Xor.out new file mode 100644 index 00000000..9eea38e2 --- /dev/null +++ b/01/Xor.out @@ -0,0 +1,5 @@ +| a | b | out | +| 0 | 0 | 0 | +| 0 | 1 | 0 | +| 1 | 0 | 0 | +| 1 | 1 | 0 | diff --git a/02/ALU.hdl b/02/ALU.hdl index e12c1f64..de9d78a9 100644 --- a/02/ALU.hdl +++ b/02/ALU.hdl @@ -43,4 +43,38 @@ CHIP ALU { PARTS: // Put you code here: + // if (zx == 1) set x = 0 // 16-bit constant + Mux16(a = x, b[0..15] = false, sel = zx, out = ozx); + + // if (nx == 1) set x = !x // bitwise not + Not16(in = ozx, out = nnx); + Mux16(a = ozx, b = nnx, sel = nx, out = exx); + + // if (zy == 1) set y = 0 // 16-bit constant + Mux16(a = y, b[0..15] = false, sel = zy, out = ozy); + + // if (ny == 1) set y = !y // bitwise not + Not16(in = ozy, out = nny); + Mux16(a = ozy, b = nny, sel = ny, out = exy); + + // if (f == 1) set out = x + y // integer 2's complement addition + // if (f == 0) set out = x & y // bitwise and + Add16(a = exx, b = exy, out = xplusy); + And16(a = exx, b = exy, out = xandy); + Mux16(a = xandy, b = xplusy, sel = f, out = fxy); + + // if (no == 1) set out = !out // bitwise not + Not16(in = fxy, out = nfxy); + Mux16(a = fxy, b = nfxy, sel = no, out[0..7] = ret0, out[8..14] = ret1, out[15] = retsign, out = out); + + // if (out == 0) set zr = 1 + Or8Way(in[0..7] = ret0, out = ret0is0); + Or8Way(in[0..6] = ret1, in[7] = retsign, out = ret1is0); + + Or(a = ret0is0, b = ret1is0, out = yzr); + Not(in = yzr, out = zr); + + // if (out < 0) set ng = 1 + //And(a = retsign, b = true, out = ng); + Mux(a = false , b = true , sel = retsign , out = ng); } \ No newline at end of file diff --git a/02/ALU.out b/02/ALU.out new file mode 100644 index 00000000..211edf75 --- /dev/null +++ b/02/ALU.out @@ -0,0 +1,37 @@ +| x | y |zx |nx |zy |ny | f |no | out |zr |ng | +| 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 0 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000000000 | 1111111111111111 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 1 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 0 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 0 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 1 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 1 | 1 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 1 | 1 | 0 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 1 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 0 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 1 | 1 | 1 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 0 | 0 | 0 | 0 | 0 | 0000000000000000 | 0 | 0 | +| 0000000000010001 | 0000000000000011 | 0 | 1 | 0 | 1 | 0 | 1 | 0000000000000000 | 0 | 0 | diff --git a/02/Add16.hdl b/02/Add16.hdl index bafd3ce3..549dfd30 100644 --- a/02/Add16.hdl +++ b/02/Add16.hdl @@ -14,4 +14,21 @@ CHIP Add16 { PARTS: // Put you code here: + //網路上找查、朋友指教 + HalfAdder(a = a[0], b = b[0], sum = out[0], carry = carry1); + FullAdder(a = a[1], b = b[1], c = carry1, sum = out[1], carry = carry2); + FullAdder(a = a[2], b = b[2], c = carry2, sum = out[2], carry = carry3); + FullAdder(a = a[3], b = b[3], c = carry3, sum = out[3], carry = carry4); + FullAdder(a = a[4], b = b[4], c = carry4, sum = out[4], carry = carry5); + FullAdder(a = a[5], b = b[5], c = carry5, sum = out[5], carry = carry6); + FullAdder(a = a[6], b = b[6], c = carry6, sum = out[6], carry = carry7); + FullAdder(a = a[7], b = b[7], c = carry7, sum = out[7], carry = carry8); + FullAdder(a = a[8], b = b[8], c = carry8, sum = out[8], carry = carry9); + FullAdder(a = a[9], b = b[9], c = carry9, sum = out[9], carry = carry10); + FullAdder(a = a[10], b = b[10], c = carry10, sum = out[10], carry = carry11); + FullAdder(a = a[11], b = b[11], c = carry11, sum = out[11], carry = carry12); + FullAdder(a = a[12], b = b[12], c = carry12, sum = out[12], carry = carry13); + FullAdder(a = a[13], b = b[13], c = carry13, sum = out[13], carry = carry14); + FullAdder(a = a[14], b = b[14], c = carry14, sum = out[14], carry = carry15); + FullAdder(a = a[15], b = b[15], c = carry15, sum = out[15], carry = carry16); } \ No newline at end of file diff --git a/02/Add16.out b/02/Add16.out new file mode 100644 index 00000000..19abc5a8 --- /dev/null +++ b/02/Add16.out @@ -0,0 +1,7 @@ +| a | b | out | +| 0000000000000000 | 0000000000000000 | 0000000000000000 | +| 0000000000000000 | 1111111111111111 | 0000000000000000 | +| 1111111111111111 | 1111111111111111 | 0000000000000000 | +| 1010101010101010 | 0101010101010101 | 0000000000000000 | +| 0011110011000011 | 0000111111110000 | 0000000000000000 | +| 0001001000110100 | 1001100001110110 | 0000000000000000 | diff --git a/02/FullAdder.hdl b/02/FullAdder.hdl index 6b568d06..a1903d6a 100644 --- a/02/FullAdder.hdl +++ b/02/FullAdder.hdl @@ -14,4 +14,12 @@ CHIP FullAdder { PARTS: // Put you code here: + //網路上找查、朋友指教 + Xor(a = a , b = b , out = xab); + Xor(a = xab , b = c , out = sum); + And(a = a , b = b , out = ab); + And(a = a , b = c , out = ac); + And(a = b , b = c , out = bc); + Or(a = ab , b = ac , out = abac); + Or(a = abac , b = bc , out = carry); } \ No newline at end of file diff --git a/02/FullAdder.out b/02/FullAdder.out new file mode 100644 index 00000000..d402cb54 --- /dev/null +++ b/02/FullAdder.out @@ -0,0 +1,9 @@ +| a | b | c | sum | carry | +| 0 | 0 | 0 | 0 | 0 | +| 0 | 0 | 1 | 0 | 0 | +| 0 | 1 | 0 | 0 | 0 | +| 0 | 1 | 1 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1 | 0 | 1 | 0 | 0 | +| 1 | 1 | 0 | 0 | 0 | +| 1 | 1 | 1 | 0 | 0 | diff --git a/02/HalfAdder.hdl b/02/HalfAdder.hdl index 76217bd6..1a3b2951 100644 --- a/02/HalfAdder.hdl +++ b/02/HalfAdder.hdl @@ -14,4 +14,7 @@ CHIP HalfAdder { PARTS: // Put you code here: + //網路上找查、朋友指教 + Xor(a = a, b = b, out = sum); + And(a = a, b = b, out = carry); } diff --git a/02/HalfAdder.out b/02/HalfAdder.out new file mode 100644 index 00000000..848cdce5 --- /dev/null +++ b/02/HalfAdder.out @@ -0,0 +1,5 @@ +| a | b | sum | carry | +| 0 | 0 | 0 | 0 | +| 0 | 1 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1 | 1 | 0 | 0 | diff --git a/02/Inc16.hdl b/02/Inc16.hdl index d820b483..693b59ca 100644 --- a/02/Inc16.hdl +++ b/02/Inc16.hdl @@ -14,4 +14,6 @@ CHIP Inc16 { PARTS: // Put you code here: + //網路上找查、朋友指教 + Add16(a = in, b[0] = true, out = out); } \ No newline at end of file diff --git a/02/Inc16.out b/02/Inc16.out new file mode 100644 index 00000000..3b452dbf --- /dev/null +++ b/02/Inc16.out @@ -0,0 +1,5 @@ +| in | out | +| 0000000000000000 | 0000000000000000 | +| 1111111111111111 | 0000000000000000 | +| 0000000000000101 | 0000000000000000 | +| 1111111111111011 | 0000000000000000 | diff --git a/03/a/Bit.hdl b/03/a/Bit.hdl index cb6da15b..d7044311 100644 --- a/03/a/Bit.hdl +++ b/03/a/Bit.hdl @@ -15,4 +15,6 @@ CHIP Bit { PARTS: // Put your code here: + Mux(a = a , b = in , sel = load , out = o ); + DFF(in = o , out = a , out = out); } diff --git a/03/a/Bit.out b/03/a/Bit.out new file mode 100644 index 00000000..dfb8e51c --- /dev/null +++ b/03/a/Bit.out @@ -0,0 +1,215 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | 1 | 0 | 0 | +| 3 | 1 | 0 | 0 | +| 3+ | 1 | 1 | 0 | +| 4 | 1 | 1 | 0 | +| 4+ | 0 | 0 | 0 | +| 5 | 0 | 0 | 0 | +| 5+ | 1 | 0 | 0 | +| 6 | 1 | 0 | 0 | +| 6+ | 0 | 1 | 0 | +| 7 | 0 | 1 | 0 | +| 7+ | 1 | 1 | 0 | +| 8 | 1 | 1 | 0 | +| 8+ | 0 | 0 | 0 | +| 9 | 0 | 0 | 0 | +| 9+ | 0 | 0 | 0 | +| 10 | 0 | 0 | 0 | +| 10+ | 0 | 0 | 0 | +| 11 | 0 | 0 | 0 | +| 11+ | 0 | 0 | 0 | +| 12 | 0 | 0 | 0 | +| 12+ | 0 | 0 | 0 | +| 13 | 0 | 0 | 0 | +| 13+ | 0 | 0 | 0 | +| 14 | 0 | 0 | 0 | +| 14+ | 0 | 0 | 0 | +| 15 | 0 | 0 | 0 | +| 15+ | 0 | 0 | 0 | +| 16 | 0 | 0 | 0 | +| 16+ | 0 | 0 | 0 | +| 17 | 0 | 0 | 0 | +| 17+ | 0 | 0 | 0 | +| 18 | 0 | 0 | 0 | +| 18+ | 0 | 0 | 0 | +| 19 | 0 | 0 | 0 | +| 19+ | 0 | 0 | 0 | +| 20 | 0 | 0 | 0 | +| 20+ | 0 | 0 | 0 | +| 21 | 0 | 0 | 0 | +| 21+ | 0 | 0 | 0 | +| 22 | 0 | 0 | 0 | +| 22+ | 0 | 0 | 0 | +| 23 | 0 | 0 | 0 | +| 23+ | 0 | 0 | 0 | +| 24 | 0 | 0 | 0 | +| 24+ | 0 | 0 | 0 | +| 25 | 0 | 0 | 0 | +| 25+ | 0 | 0 | 0 | +| 26 | 0 | 0 | 0 | +| 26+ | 0 | 0 | 0 | +| 27 | 0 | 0 | 0 | +| 27+ | 0 | 0 | 0 | +| 28 | 0 | 0 | 0 | +| 28+ | 0 | 0 | 0 | +| 29 | 0 | 0 | 0 | +| 29+ | 0 | 0 | 0 | +| 30 | 0 | 0 | 0 | +| 30+ | 0 | 0 | 0 | +| 31 | 0 | 0 | 0 | +| 31+ | 0 | 0 | 0 | +| 32 | 0 | 0 | 0 | +| 32+ | 0 | 0 | 0 | +| 33 | 0 | 0 | 0 | +| 33+ | 0 | 0 | 0 | +| 34 | 0 | 0 | 0 | +| 34+ | 0 | 0 | 0 | +| 35 | 0 | 0 | 0 | +| 35+ | 0 | 0 | 0 | +| 36 | 0 | 0 | 0 | +| 36+ | 0 | 0 | 0 | +| 37 | 0 | 0 | 0 | +| 37+ | 0 | 0 | 0 | +| 38 | 0 | 0 | 0 | +| 38+ | 0 | 0 | 0 | +| 39 | 0 | 0 | 0 | +| 39+ | 0 | 0 | 0 | +| 40 | 0 | 0 | 0 | +| 40+ | 0 | 0 | 0 | +| 41 | 0 | 0 | 0 | +| 41+ | 0 | 0 | 0 | +| 42 | 0 | 0 | 0 | +| 42+ | 0 | 0 | 0 | +| 43 | 0 | 0 | 0 | +| 43+ | 0 | 0 | 0 | +| 44 | 0 | 0 | 0 | +| 44+ | 0 | 0 | 0 | +| 45 | 0 | 0 | 0 | +| 45+ | 0 | 0 | 0 | +| 46 | 0 | 0 | 0 | +| 46+ | 0 | 0 | 0 | +| 47 | 0 | 0 | 0 | +| 47+ | 0 | 0 | 0 | +| 48 | 0 | 0 | 0 | +| 48+ | 0 | 0 | 0 | +| 49 | 0 | 0 | 0 | +| 49+ | 0 | 0 | 0 | +| 50 | 0 | 0 | 0 | +| 50+ | 0 | 0 | 0 | +| 51 | 0 | 0 | 0 | +| 51+ | 0 | 0 | 0 | +| 52 | 0 | 0 | 0 | +| 52+ | 0 | 0 | 0 | +| 53 | 0 | 0 | 0 | +| 53+ | 0 | 0 | 0 | +| 54 | 0 | 0 | 0 | +| 54+ | 0 | 0 | 0 | +| 55 | 0 | 0 | 0 | +| 55+ | 0 | 0 | 0 | +| 56 | 0 | 0 | 0 | +| 56+ | 0 | 0 | 0 | +| 57 | 0 | 0 | 0 | +| 57+ | 0 | 1 | 0 | +| 58 | 0 | 1 | 0 | +| 58+ | 1 | 0 | 0 | +| 59 | 1 | 0 | 0 | +| 59+ | 1 | 0 | 0 | +| 60 | 1 | 0 | 0 | +| 60+ | 1 | 0 | 0 | +| 61 | 1 | 0 | 0 | +| 61+ | 1 | 0 | 0 | +| 62 | 1 | 0 | 0 | +| 62+ | 1 | 0 | 0 | +| 63 | 1 | 0 | 0 | +| 63+ | 1 | 0 | 0 | +| 64 | 1 | 0 | 0 | +| 64+ | 1 | 0 | 0 | +| 65 | 1 | 0 | 0 | +| 65+ | 1 | 0 | 0 | +| 66 | 1 | 0 | 0 | +| 66+ | 1 | 0 | 0 | +| 67 | 1 | 0 | 0 | +| 67+ | 1 | 0 | 0 | +| 68 | 1 | 0 | 0 | +| 68+ | 1 | 0 | 0 | +| 69 | 1 | 0 | 0 | +| 69+ | 1 | 0 | 0 | +| 70 | 1 | 0 | 0 | +| 70+ | 1 | 0 | 0 | +| 71 | 1 | 0 | 0 | +| 71+ | 1 | 0 | 0 | +| 72 | 1 | 0 | 0 | +| 72+ | 1 | 0 | 0 | +| 73 | 1 | 0 | 0 | +| 73+ | 1 | 0 | 0 | +| 74 | 1 | 0 | 0 | +| 74+ | 1 | 0 | 0 | +| 75 | 1 | 0 | 0 | +| 75+ | 1 | 0 | 0 | +| 76 | 1 | 0 | 0 | +| 76+ | 1 | 0 | 0 | +| 77 | 1 | 0 | 0 | +| 77+ | 1 | 0 | 0 | +| 78 | 1 | 0 | 0 | +| 78+ | 1 | 0 | 0 | +| 79 | 1 | 0 | 0 | +| 79+ | 1 | 0 | 0 | +| 80 | 1 | 0 | 0 | +| 80+ | 1 | 0 | 0 | +| 81 | 1 | 0 | 0 | +| 81+ | 1 | 0 | 0 | +| 82 | 1 | 0 | 0 | +| 82+ | 1 | 0 | 0 | +| 83 | 1 | 0 | 0 | +| 83+ | 1 | 0 | 0 | +| 84 | 1 | 0 | 0 | +| 84+ | 1 | 0 | 0 | +| 85 | 1 | 0 | 0 | +| 85+ | 1 | 0 | 0 | +| 86 | 1 | 0 | 0 | +| 86+ | 1 | 0 | 0 | +| 87 | 1 | 0 | 0 | +| 87+ | 1 | 0 | 0 | +| 88 | 1 | 0 | 0 | +| 88+ | 1 | 0 | 0 | +| 89 | 1 | 0 | 0 | +| 89+ | 1 | 0 | 0 | +| 90 | 1 | 0 | 0 | +| 90+ | 1 | 0 | 0 | +| 91 | 1 | 0 | 0 | +| 91+ | 1 | 0 | 0 | +| 92 | 1 | 0 | 0 | +| 92+ | 1 | 0 | 0 | +| 93 | 1 | 0 | 0 | +| 93+ | 1 | 0 | 0 | +| 94 | 1 | 0 | 0 | +| 94+ | 1 | 0 | 0 | +| 95 | 1 | 0 | 0 | +| 95+ | 1 | 0 | 0 | +| 96 | 1 | 0 | 0 | +| 96+ | 1 | 0 | 0 | +| 97 | 1 | 0 | 0 | +| 97+ | 1 | 0 | 0 | +| 98 | 1 | 0 | 0 | +| 98+ | 1 | 0 | 0 | +| 99 | 1 | 0 | 0 | +| 99+ | 1 | 0 | 0 | +| 100 | 1 | 0 | 0 | +| 100+ | 1 | 0 | 0 | +| 101 | 1 | 0 | 0 | +| 101+ | 1 | 0 | 0 | +| 102 | 1 | 0 | 0 | +| 102+ | 1 | 0 | 0 | +| 103 | 1 | 0 | 0 | +| 103+ | 1 | 0 | 0 | +| 104 | 1 | 0 | 0 | +| 104+ | 1 | 0 | 0 | +| 105 | 1 | 0 | 0 | +| 105+ | 1 | 0 | 0 | +| 106 | 1 | 0 | 0 | +| 106+ | 1 | 0 | 0 | +| 107 | 1 | 0 | 0 | diff --git a/03/a/PC.hdl b/03/a/PC.hdl index ae8173a7..5d82173a 100644 --- a/03/a/PC.hdl +++ b/03/a/PC.hdl @@ -17,4 +17,13 @@ CHIP PC { PARTS: // Put your code here: + Inc16(in=a,out=b); + + Mux16(a=a,b=b,sel=inc,out=c); + + Mux16(a=c,b=in,sel=load,out=d); + + Mux16(a=d,b[0..15]=false,sel=reset,out=e); + + Register(in=e,load=true,out=out,out=a); } diff --git a/03/a/PC.out b/03/a/PC.out new file mode 100644 index 00000000..0884ed34 --- /dev/null +++ b/03/a/PC.out @@ -0,0 +1,31 @@ +| time | in |reset|load | inc | out | +| 0+ | 0 | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 0 | 0 | 1 | 0 | +| 2 | 0 | 0 | 0 | 1 | 0 | +| 2+ | -32123 | 0 | 0 | 1 | 0 | +| 3 | -32123 | 0 | 0 | 1 | 0 | +| 3+ | -32123 | 0 | 1 | 1 | 0 | +| 4 | -32123 | 0 | 1 | 1 | 0 | +| 4+ | -32123 | 0 | 0 | 1 | 0 | +| 5 | -32123 | 0 | 0 | 1 | 0 | +| 5+ | -32123 | 0 | 0 | 1 | 0 | +| 6 | -32123 | 0 | 0 | 1 | 0 | +| 6+ | 12345 | 0 | 1 | 0 | 0 | +| 7 | 12345 | 0 | 1 | 0 | 0 | +| 7+ | 12345 | 1 | 1 | 0 | 0 | +| 8 | 12345 | 1 | 1 | 0 | 0 | +| 8+ | 12345 | 0 | 1 | 1 | 0 | +| 9 | 12345 | 0 | 1 | 1 | 0 | +| 9+ | 12345 | 1 | 1 | 1 | 0 | +| 10 | 12345 | 1 | 1 | 1 | 0 | +| 10+ | 12345 | 0 | 0 | 1 | 0 | +| 11 | 12345 | 0 | 0 | 1 | 0 | +| 11+ | 12345 | 1 | 0 | 1 | 0 | +| 12 | 12345 | 1 | 0 | 1 | 0 | +| 12+ | 0 | 0 | 1 | 1 | 0 | +| 13 | 0 | 0 | 1 | 1 | 0 | +| 13+ | 0 | 0 | 0 | 1 | 0 | +| 14 | 0 | 0 | 0 | 1 | 0 | +| 14+ | 22222 | 1 | 0 | 0 | 0 | +| 15 | 22222 | 1 | 0 | 0 | 0 | diff --git a/03/a/RAM64.hdl b/03/a/RAM64.hdl index df132a39..e653b230 100644 --- a/03/a/RAM64.hdl +++ b/03/a/RAM64.hdl @@ -16,4 +16,14 @@ CHIP RAM64 { PARTS: // Put your code here: + DMux8Way(in = load, sel = address[3..5], a = in0, b = in1, c = in2, d = in3, e = in4, f = in5, g = in6, h = in7); + RAM8(in = in, load = in0, address = address[0..2], out = o0); + RAM8(in = in, load = in1, address = address[0..2], out = o1); + RAM8(in = in, load = in2, address = address[0..2], out = o2); + RAM8(in = in, load = in3, address = address[0..2], out = o3); + RAM8(in = in, load = in4, address = address[0..2], out = o4); + RAM8(in = in, load = in5, address = address[0..2], out = o5); + RAM8(in = in, load = in6, address = address[0..2], out = o6); + RAM8(in = in, load = in7, address = address[0..2], out = o7); + Mux8Way16(a = o0, b = o1, c = o2, d = o3, e = o4, f = o5, g = o6, h = o7, sel = address[3..5], out = out); } \ No newline at end of file diff --git a/03/a/RAM64.out b/03/a/RAM64.out new file mode 100644 index 00000000..03365c52 --- /dev/null +++ b/03/a/RAM64.out @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1313 | 0 | 0 | 0 | +| 3 | 1313 | 0 | 0 | 0 | +| 3+ | 1313 | 1 | 13 | 0 | +| 4 | 1313 | 1 | 13 | 0 | +| 4+ | 1313 | 0 | 0 | 0 | +| 5 | 1313 | 0 | 0 | 0 | +| 5+ | 4747 | 0 | 47 | 0 | +| 6 | 4747 | 0 | 47 | 0 | +| 6+ | 4747 | 1 | 47 | 0 | +| 7 | 4747 | 1 | 47 | 0 | +| 7+ | 4747 | 0 | 47 | 0 | +| 8 | 4747 | 0 | 47 | 0 | +| 8 | 4747 | 0 | 13 | 0 | +| 8+ | 6363 | 0 | 13 | 0 | +| 9 | 6363 | 0 | 13 | 0 | +| 9+ | 6363 | 1 | 63 | 0 | +| 10 | 6363 | 1 | 63 | 0 | +| 10+ | 6363 | 0 | 63 | 0 | +| 11 | 6363 | 0 | 63 | 0 | +| 11 | 6363 | 0 | 47 | 0 | +| 11 | 6363 | 0 | 63 | 0 | +| 11+ | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 40 | 0 | +| 12 | 6363 | 0 | 41 | 0 | +| 12 | 6363 | 0 | 42 | 0 | +| 12 | 6363 | 0 | 43 | 0 | +| 12 | 6363 | 0 | 44 | 0 | +| 12 | 6363 | 0 | 45 | 0 | +| 12 | 6363 | 0 | 46 | 0 | +| 12 | 6363 | 0 | 47 | 0 | +| 12+ | 21845 | 1 | 40 | 0 | +| 13 | 21845 | 1 | 40 | 0 | +| 13+ | 21845 | 1 | 41 | 0 | +| 14 | 21845 | 1 | 41 | 0 | +| 14+ | 21845 | 1 | 42 | 0 | +| 15 | 21845 | 1 | 42 | 0 | +| 15+ | 21845 | 1 | 43 | 0 | +| 16 | 21845 | 1 | 43 | 0 | +| 16+ | 21845 | 1 | 44 | 0 | +| 17 | 21845 | 1 | 44 | 0 | +| 17+ | 21845 | 1 | 45 | 0 | +| 18 | 21845 | 1 | 45 | 0 | +| 18+ | 21845 | 1 | 46 | 0 | +| 19 | 21845 | 1 | 46 | 0 | +| 19+ | 21845 | 1 | 47 | 0 | +| 20 | 21845 | 1 | 47 | 0 | +| 20+ | 21845 | 0 | 40 | 0 | +| 21 | 21845 | 0 | 40 | 0 | +| 21 | 21845 | 0 | 41 | 0 | +| 21 | 21845 | 0 | 42 | 0 | +| 21 | 21845 | 0 | 43 | 0 | +| 21 | 21845 | 0 | 44 | 0 | +| 21 | 21845 | 0 | 45 | 0 | +| 21 | 21845 | 0 | 46 | 0 | +| 21 | 21845 | 0 | 47 | 0 | +| 21+ | -21846 | 1 | 40 | 0 | +| 22 | -21846 | 1 | 40 | 0 | +| 22+ | -21846 | 0 | 40 | 0 | +| 23 | -21846 | 0 | 40 | 0 | +| 23 | -21846 | 0 | 41 | 0 | +| 23 | -21846 | 0 | 42 | 0 | +| 23 | -21846 | 0 | 43 | 0 | +| 23 | -21846 | 0 | 44 | 0 | +| 23 | -21846 | 0 | 45 | 0 | +| 23 | -21846 | 0 | 46 | 0 | +| 23 | -21846 | 0 | 47 | 0 | +| 23+ | 21845 | 1 | 40 | 0 | +| 24 | 21845 | 1 | 40 | 0 | +| 24+ | -21846 | 1 | 41 | 0 | +| 25 | -21846 | 1 | 41 | 0 | +| 25+ | -21846 | 0 | 40 | 0 | +| 26 | -21846 | 0 | 40 | 0 | +| 26 | -21846 | 0 | 41 | 0 | +| 26 | -21846 | 0 | 42 | 0 | +| 26 | -21846 | 0 | 43 | 0 | +| 26 | -21846 | 0 | 44 | 0 | +| 26 | -21846 | 0 | 45 | 0 | +| 26 | -21846 | 0 | 46 | 0 | +| 26 | -21846 | 0 | 47 | 0 | +| 26+ | 21845 | 1 | 41 | 0 | +| 27 | 21845 | 1 | 41 | 0 | +| 27+ | -21846 | 1 | 42 | 0 | +| 28 | -21846 | 1 | 42 | 0 | +| 28+ | -21846 | 0 | 40 | 0 | +| 29 | -21846 | 0 | 40 | 0 | +| 29 | -21846 | 0 | 41 | 0 | +| 29 | -21846 | 0 | 42 | 0 | +| 29 | -21846 | 0 | 43 | 0 | +| 29 | -21846 | 0 | 44 | 0 | +| 29 | -21846 | 0 | 45 | 0 | +| 29 | -21846 | 0 | 46 | 0 | +| 29 | -21846 | 0 | 47 | 0 | +| 29+ | 21845 | 1 | 42 | 0 | +| 30 | 21845 | 1 | 42 | 0 | +| 30+ | -21846 | 1 | 43 | 0 | +| 31 | -21846 | 1 | 43 | 0 | +| 31+ | -21846 | 0 | 40 | 0 | +| 32 | -21846 | 0 | 40 | 0 | +| 32 | -21846 | 0 | 41 | 0 | +| 32 | -21846 | 0 | 42 | 0 | +| 32 | -21846 | 0 | 43 | 0 | +| 32 | -21846 | 0 | 44 | 0 | +| 32 | -21846 | 0 | 45 | 0 | +| 32 | -21846 | 0 | 46 | 0 | +| 32 | -21846 | 0 | 47 | 0 | +| 32+ | 21845 | 1 | 43 | 0 | +| 33 | 21845 | 1 | 43 | 0 | +| 33+ | -21846 | 1 | 44 | 0 | +| 34 | -21846 | 1 | 44 | 0 | +| 34+ | -21846 | 0 | 40 | 0 | +| 35 | -21846 | 0 | 40 | 0 | +| 35 | -21846 | 0 | 41 | 0 | +| 35 | -21846 | 0 | 42 | 0 | +| 35 | -21846 | 0 | 43 | 0 | +| 35 | -21846 | 0 | 44 | 0 | +| 35 | -21846 | 0 | 45 | 0 | +| 35 | -21846 | 0 | 46 | 0 | +| 35 | -21846 | 0 | 47 | 0 | +| 35+ | 21845 | 1 | 44 | 0 | +| 36 | 21845 | 1 | 44 | 0 | +| 36+ | -21846 | 1 | 45 | 0 | +| 37 | -21846 | 1 | 45 | 0 | +| 37+ | -21846 | 0 | 40 | 0 | +| 38 | -21846 | 0 | 40 | 0 | +| 38 | -21846 | 0 | 41 | 0 | +| 38 | -21846 | 0 | 42 | 0 | +| 38 | -21846 | 0 | 43 | 0 | +| 38 | -21846 | 0 | 44 | 0 | +| 38 | -21846 | 0 | 45 | 0 | +| 38 | -21846 | 0 | 46 | 0 | +| 38 | -21846 | 0 | 47 | 0 | +| 38+ | 21845 | 1 | 45 | 0 | +| 39 | 21845 | 1 | 45 | 0 | +| 39+ | -21846 | 1 | 46 | 0 | +| 40 | -21846 | 1 | 46 | 0 | +| 40+ | -21846 | 0 | 40 | 0 | +| 41 | -21846 | 0 | 40 | 0 | +| 41 | -21846 | 0 | 41 | 0 | +| 41 | -21846 | 0 | 42 | 0 | +| 41 | -21846 | 0 | 43 | 0 | +| 41 | -21846 | 0 | 44 | 0 | +| 41 | -21846 | 0 | 45 | 0 | +| 41 | -21846 | 0 | 46 | 0 | +| 41 | -21846 | 0 | 47 | 0 | +| 41+ | 21845 | 1 | 46 | 0 | +| 42 | 21845 | 1 | 46 | 0 | +| 42+ | -21846 | 1 | 47 | 0 | +| 43 | -21846 | 1 | 47 | 0 | +| 43+ | -21846 | 0 | 40 | 0 | +| 44 | -21846 | 0 | 40 | 0 | +| 44 | -21846 | 0 | 41 | 0 | +| 44 | -21846 | 0 | 42 | 0 | +| 44 | -21846 | 0 | 43 | 0 | +| 44 | -21846 | 0 | 44 | 0 | +| 44 | -21846 | 0 | 45 | 0 | +| 44 | -21846 | 0 | 46 | 0 | +| 44 | -21846 | 0 | 47 | 0 | +| 44+ | 21845 | 1 | 47 | 0 | +| 45 | 21845 | 1 | 47 | 0 | +| 45+ | 21845 | 0 | 40 | 0 | +| 46 | 21845 | 0 | 40 | 0 | +| 46 | 21845 | 0 | 41 | 0 | +| 46 | 21845 | 0 | 42 | 0 | +| 46 | 21845 | 0 | 43 | 0 | +| 46 | 21845 | 0 | 44 | 0 | +| 46 | 21845 | 0 | 45 | 0 | +| 46 | 21845 | 0 | 46 | 0 | +| 46 | 21845 | 0 | 47 | 0 | +| 46+ | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 5 | 0 | +| 47 | 21845 | 0 | 13 | 0 | +| 47 | 21845 | 0 | 21 | 0 | +| 47 | 21845 | 0 | 29 | 0 | +| 47 | 21845 | 0 | 37 | 0 | +| 47 | 21845 | 0 | 45 | 0 | +| 47 | 21845 | 0 | 53 | 0 | +| 47 | 21845 | 0 | 61 | 0 | +| 47+ | 21845 | 1 | 5 | 0 | +| 48 | 21845 | 1 | 5 | 0 | +| 48+ | 21845 | 1 | 13 | 0 | +| 49 | 21845 | 1 | 13 | 0 | +| 49+ | 21845 | 1 | 21 | 0 | +| 50 | 21845 | 1 | 21 | 0 | +| 50+ | 21845 | 1 | 29 | 0 | +| 51 | 21845 | 1 | 29 | 0 | +| 51+ | 21845 | 1 | 37 | 0 | +| 52 | 21845 | 1 | 37 | 0 | +| 52+ | 21845 | 1 | 45 | 0 | +| 53 | 21845 | 1 | 45 | 0 | +| 53+ | 21845 | 1 | 53 | 0 | +| 54 | 21845 | 1 | 53 | 0 | +| 54+ | 21845 | 1 | 61 | 0 | +| 55 | 21845 | 1 | 61 | 0 | +| 55+ | 21845 | 0 | 5 | 0 | +| 56 | 21845 | 0 | 5 | 0 | +| 56 | 21845 | 0 | 13 | 0 | +| 56 | 21845 | 0 | 21 | 0 | +| 56 | 21845 | 0 | 29 | 0 | +| 56 | 21845 | 0 | 37 | 0 | +| 56 | 21845 | 0 | 45 | 0 | +| 56 | 21845 | 0 | 53 | 0 | +| 56 | 21845 | 0 | 61 | 0 | +| 56+ | -21846 | 1 | 5 | 0 | +| 57 | -21846 | 1 | 5 | 0 | +| 57+ | -21846 | 0 | 5 | 0 | +| 58 | -21846 | 0 | 5 | 0 | +| 58 | -21846 | 0 | 13 | 0 | +| 58 | -21846 | 0 | 21 | 0 | +| 58 | -21846 | 0 | 29 | 0 | +| 58 | -21846 | 0 | 37 | 0 | +| 58 | -21846 | 0 | 45 | 0 | +| 58 | -21846 | 0 | 53 | 0 | +| 58 | -21846 | 0 | 61 | 0 | +| 58+ | 21845 | 1 | 5 | 0 | +| 59 | 21845 | 1 | 5 | 0 | +| 59+ | -21846 | 1 | 13 | 0 | +| 60 | -21846 | 1 | 13 | 0 | +| 60+ | -21846 | 0 | 5 | 0 | +| 61 | -21846 | 0 | 5 | 0 | +| 61 | -21846 | 0 | 13 | 0 | +| 61 | -21846 | 0 | 21 | 0 | +| 61 | -21846 | 0 | 29 | 0 | +| 61 | -21846 | 0 | 37 | 0 | +| 61 | -21846 | 0 | 45 | 0 | +| 61 | -21846 | 0 | 53 | 0 | +| 61 | -21846 | 0 | 61 | 0 | +| 61+ | 21845 | 1 | 13 | 0 | +| 62 | 21845 | 1 | 13 | 0 | +| 62+ | -21846 | 1 | 21 | 0 | +| 63 | -21846 | 1 | 21 | 0 | +| 63+ | -21846 | 0 | 5 | 0 | +| 64 | -21846 | 0 | 5 | 0 | +| 64 | -21846 | 0 | 13 | 0 | +| 64 | -21846 | 0 | 21 | 0 | +| 64 | -21846 | 0 | 29 | 0 | +| 64 | -21846 | 0 | 37 | 0 | +| 64 | -21846 | 0 | 45 | 0 | +| 64 | -21846 | 0 | 53 | 0 | +| 64 | -21846 | 0 | 61 | 0 | +| 64+ | 21845 | 1 | 21 | 0 | +| 65 | 21845 | 1 | 21 | 0 | +| 65+ | -21846 | 1 | 29 | 0 | +| 66 | -21846 | 1 | 29 | 0 | +| 66+ | -21846 | 0 | 5 | 0 | +| 67 | -21846 | 0 | 5 | 0 | +| 67 | -21846 | 0 | 13 | 0 | +| 67 | -21846 | 0 | 21 | 0 | +| 67 | -21846 | 0 | 29 | 0 | +| 67 | -21846 | 0 | 37 | 0 | +| 67 | -21846 | 0 | 45 | 0 | +| 67 | -21846 | 0 | 53 | 0 | +| 67 | -21846 | 0 | 61 | 0 | +| 67+ | 21845 | 1 | 29 | 0 | +| 68 | 21845 | 1 | 29 | 0 | +| 68+ | -21846 | 1 | 37 | 0 | +| 69 | -21846 | 1 | 37 | 0 | +| 69+ | -21846 | 0 | 5 | 0 | +| 70 | -21846 | 0 | 5 | 0 | +| 70 | -21846 | 0 | 13 | 0 | +| 70 | -21846 | 0 | 21 | 0 | +| 70 | -21846 | 0 | 29 | 0 | +| 70 | -21846 | 0 | 37 | 0 | +| 70 | -21846 | 0 | 45 | 0 | +| 70 | -21846 | 0 | 53 | 0 | +| 70 | -21846 | 0 | 61 | 0 | +| 70+ | 21845 | 1 | 37 | 0 | +| 71 | 21845 | 1 | 37 | 0 | +| 71+ | -21846 | 1 | 45 | 0 | +| 72 | -21846 | 1 | 45 | 0 | +| 72+ | -21846 | 0 | 5 | 0 | +| 73 | -21846 | 0 | 5 | 0 | +| 73 | -21846 | 0 | 13 | 0 | +| 73 | -21846 | 0 | 21 | 0 | +| 73 | -21846 | 0 | 29 | 0 | +| 73 | -21846 | 0 | 37 | 0 | +| 73 | -21846 | 0 | 45 | 0 | +| 73 | -21846 | 0 | 53 | 0 | +| 73 | -21846 | 0 | 61 | 0 | +| 73+ | 21845 | 1 | 45 | 0 | +| 74 | 21845 | 1 | 45 | 0 | +| 74+ | -21846 | 1 | 53 | 0 | +| 75 | -21846 | 1 | 53 | 0 | +| 75+ | -21846 | 0 | 5 | 0 | +| 76 | -21846 | 0 | 5 | 0 | +| 76 | -21846 | 0 | 13 | 0 | +| 76 | -21846 | 0 | 21 | 0 | +| 76 | -21846 | 0 | 29 | 0 | +| 76 | -21846 | 0 | 37 | 0 | +| 76 | -21846 | 0 | 45 | 0 | +| 76 | -21846 | 0 | 53 | 0 | +| 76 | -21846 | 0 | 61 | 0 | +| 76+ | 21845 | 1 | 53 | 0 | +| 77 | 21845 | 1 | 53 | 0 | +| 77+ | -21846 | 1 | 61 | 0 | +| 78 | -21846 | 1 | 61 | 0 | +| 78+ | -21846 | 0 | 5 | 0 | +| 79 | -21846 | 0 | 5 | 0 | +| 79 | -21846 | 0 | 13 | 0 | +| 79 | -21846 | 0 | 21 | 0 | +| 79 | -21846 | 0 | 29 | 0 | +| 79 | -21846 | 0 | 37 | 0 | +| 79 | -21846 | 0 | 45 | 0 | +| 79 | -21846 | 0 | 53 | 0 | +| 79 | -21846 | 0 | 61 | 0 | +| 79+ | 21845 | 1 | 61 | 0 | +| 80 | 21845 | 1 | 61 | 0 | +| 80+ | 21845 | 0 | 5 | 0 | +| 81 | 21845 | 0 | 5 | 0 | +| 81 | 21845 | 0 | 13 | 0 | +| 81 | 21845 | 0 | 21 | 0 | +| 81 | 21845 | 0 | 29 | 0 | +| 81 | 21845 | 0 | 37 | 0 | +| 81 | 21845 | 0 | 45 | 0 | +| 81 | 21845 | 0 | 53 | 0 | +| 81 | 21845 | 0 | 61 | 0 | diff --git a/03/a/RAM8.hdl b/03/a/RAM8.hdl index efa885dc..14847059 100644 --- a/03/a/RAM8.hdl +++ b/03/a/RAM8.hdl @@ -16,4 +16,14 @@ CHIP RAM8 { PARTS: // Put your code here: + DMux8Way(in = load, sel = address, a = in0, b = in1, c = in2, d = in3, e = in4, f = in5, g = in6, h = in7); + Register(in = in, load = in0, out = o0); + Register(in = in, load = in1, out = o1); + Register(in = in, load = in2, out = o2); + Register(in = in, load = in3, out = o3); + Register(in = in, load = in4, out = o4); + Register(in = in, load = in5, out = o5); + Register(in = in, load = in6, out = o6); + Register(in = in, load = in7, out = o7); + Mux8Way16(a = o0, b = o1, c = o2, d = o3, e = o4, f = o5, g = o6, h = o7, sel = address, out = out); } \ No newline at end of file diff --git a/03/a/RAM8.out b/03/a/RAM8.out new file mode 100644 index 00000000..8569193e --- /dev/null +++ b/03/a/RAM8.out @@ -0,0 +1,173 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 11111 | 0 | 0 | 0 | +| 3 | 11111 | 0 | 0 | 0 | +| 3+ | 11111 | 1 | 1 | 0 | +| 4 | 11111 | 1 | 1 | 0 | +| 4+ | 11111 | 0 | 0 | 0 | +| 5 | 11111 | 0 | 0 | 0 | +| 5+ | 3333 | 0 | 3 | 0 | +| 6 | 3333 | 0 | 3 | 0 | +| 6+ | 3333 | 1 | 3 | 0 | +| 7 | 3333 | 1 | 3 | 0 | +| 7+ | 3333 | 0 | 3 | 0 | +| 8 | 3333 | 0 | 3 | 0 | +| 8 | 3333 | 0 | 1 | 0 | +| 8+ | 7777 | 0 | 1 | 0 | +| 9 | 7777 | 0 | 1 | 0 | +| 9+ | 7777 | 1 | 7 | 0 | +| 10 | 7777 | 1 | 7 | 0 | +| 10+ | 7777 | 0 | 7 | 0 | +| 11 | 7777 | 0 | 7 | 0 | +| 11 | 7777 | 0 | 3 | 0 | +| 11 | 7777 | 0 | 7 | 0 | +| 11+ | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 0 | 0 | +| 12 | 7777 | 0 | 1 | 0 | +| 12 | 7777 | 0 | 2 | 0 | +| 12 | 7777 | 0 | 3 | 0 | +| 12 | 7777 | 0 | 4 | 0 | +| 12 | 7777 | 0 | 5 | 0 | +| 12 | 7777 | 0 | 6 | 0 | +| 12 | 7777 | 0 | 7 | 0 | +| 12+ | 21845 | 1 | 0 | 0 | +| 13 | 21845 | 1 | 0 | 0 | +| 13+ | 21845 | 1 | 1 | 0 | +| 14 | 21845 | 1 | 1 | 0 | +| 14+ | 21845 | 1 | 2 | 0 | +| 15 | 21845 | 1 | 2 | 0 | +| 15+ | 21845 | 1 | 3 | 0 | +| 16 | 21845 | 1 | 3 | 0 | +| 16+ | 21845 | 1 | 4 | 0 | +| 17 | 21845 | 1 | 4 | 0 | +| 17+ | 21845 | 1 | 5 | 0 | +| 18 | 21845 | 1 | 5 | 0 | +| 18+ | 21845 | 1 | 6 | 0 | +| 19 | 21845 | 1 | 6 | 0 | +| 19+ | 21845 | 1 | 7 | 0 | +| 20 | 21845 | 1 | 7 | 0 | +| 20+ | 21845 | 0 | 0 | 0 | +| 21 | 21845 | 0 | 0 | 0 | +| 21 | 21845 | 0 | 1 | 0 | +| 21 | 21845 | 0 | 2 | 0 | +| 21 | 21845 | 0 | 3 | 0 | +| 21 | 21845 | 0 | 4 | 0 | +| 21 | 21845 | 0 | 5 | 0 | +| 21 | 21845 | 0 | 6 | 0 | +| 21 | 21845 | 0 | 7 | 0 | +| 21+ | -21846 | 1 | 0 | 0 | +| 22 | -21846 | 1 | 0 | 0 | +| 22+ | -21846 | 0 | 0 | 0 | +| 23 | -21846 | 0 | 0 | 0 | +| 23 | -21846 | 0 | 1 | 0 | +| 23 | -21846 | 0 | 2 | 0 | +| 23 | -21846 | 0 | 3 | 0 | +| 23 | -21846 | 0 | 4 | 0 | +| 23 | -21846 | 0 | 5 | 0 | +| 23 | -21846 | 0 | 6 | 0 | +| 23 | -21846 | 0 | 7 | 0 | +| 23+ | 21845 | 1 | 0 | 0 | +| 24 | 21845 | 1 | 0 | 0 | +| 24+ | -21846 | 1 | 1 | 0 | +| 25 | -21846 | 1 | 1 | 0 | +| 25+ | -21846 | 0 | 0 | 0 | +| 26 | -21846 | 0 | 0 | 0 | +| 26 | -21846 | 0 | 1 | 0 | +| 26 | -21846 | 0 | 2 | 0 | +| 26 | -21846 | 0 | 3 | 0 | +| 26 | -21846 | 0 | 4 | 0 | +| 26 | -21846 | 0 | 5 | 0 | +| 26 | -21846 | 0 | 6 | 0 | +| 26 | -21846 | 0 | 7 | 0 | +| 26+ | 21845 | 1 | 1 | 0 | +| 27 | 21845 | 1 | 1 | 0 | +| 27+ | -21846 | 1 | 2 | 0 | +| 28 | -21846 | 1 | 2 | 0 | +| 28+ | -21846 | 0 | 0 | 0 | +| 29 | -21846 | 0 | 0 | 0 | +| 29 | -21846 | 0 | 1 | 0 | +| 29 | -21846 | 0 | 2 | 0 | +| 29 | -21846 | 0 | 3 | 0 | +| 29 | -21846 | 0 | 4 | 0 | +| 29 | -21846 | 0 | 5 | 0 | +| 29 | -21846 | 0 | 6 | 0 | +| 29 | -21846 | 0 | 7 | 0 | +| 29+ | 21845 | 1 | 2 | 0 | +| 30 | 21845 | 1 | 2 | 0 | +| 30+ | -21846 | 1 | 3 | 0 | +| 31 | -21846 | 1 | 3 | 0 | +| 31+ | -21846 | 0 | 0 | 0 | +| 32 | -21846 | 0 | 0 | 0 | +| 32 | -21846 | 0 | 1 | 0 | +| 32 | -21846 | 0 | 2 | 0 | +| 32 | -21846 | 0 | 3 | 0 | +| 32 | -21846 | 0 | 4 | 0 | +| 32 | -21846 | 0 | 5 | 0 | +| 32 | -21846 | 0 | 6 | 0 | +| 32 | -21846 | 0 | 7 | 0 | +| 32+ | 21845 | 1 | 3 | 0 | +| 33 | 21845 | 1 | 3 | 0 | +| 33+ | -21846 | 1 | 4 | 0 | +| 34 | -21846 | 1 | 4 | 0 | +| 34+ | -21846 | 0 | 0 | 0 | +| 35 | -21846 | 0 | 0 | 0 | +| 35 | -21846 | 0 | 1 | 0 | +| 35 | -21846 | 0 | 2 | 0 | +| 35 | -21846 | 0 | 3 | 0 | +| 35 | -21846 | 0 | 4 | 0 | +| 35 | -21846 | 0 | 5 | 0 | +| 35 | -21846 | 0 | 6 | 0 | +| 35 | -21846 | 0 | 7 | 0 | +| 35+ | 21845 | 1 | 4 | 0 | +| 36 | 21845 | 1 | 4 | 0 | +| 36+ | -21846 | 1 | 5 | 0 | +| 37 | -21846 | 1 | 5 | 0 | +| 37+ | -21846 | 0 | 0 | 0 | +| 38 | -21846 | 0 | 0 | 0 | +| 38 | -21846 | 0 | 1 | 0 | +| 38 | -21846 | 0 | 2 | 0 | +| 38 | -21846 | 0 | 3 | 0 | +| 38 | -21846 | 0 | 4 | 0 | +| 38 | -21846 | 0 | 5 | 0 | +| 38 | -21846 | 0 | 6 | 0 | +| 38 | -21846 | 0 | 7 | 0 | +| 38+ | 21845 | 1 | 5 | 0 | +| 39 | 21845 | 1 | 5 | 0 | +| 39+ | -21846 | 1 | 6 | 0 | +| 40 | -21846 | 1 | 6 | 0 | +| 40+ | -21846 | 0 | 0 | 0 | +| 41 | -21846 | 0 | 0 | 0 | +| 41 | -21846 | 0 | 1 | 0 | +| 41 | -21846 | 0 | 2 | 0 | +| 41 | -21846 | 0 | 3 | 0 | +| 41 | -21846 | 0 | 4 | 0 | +| 41 | -21846 | 0 | 5 | 0 | +| 41 | -21846 | 0 | 6 | 0 | +| 41 | -21846 | 0 | 7 | 0 | +| 41+ | 21845 | 1 | 6 | 0 | +| 42 | 21845 | 1 | 6 | 0 | +| 42+ | -21846 | 1 | 7 | 0 | +| 43 | -21846 | 1 | 7 | 0 | +| 43+ | -21846 | 0 | 0 | 0 | +| 44 | -21846 | 0 | 0 | 0 | +| 44 | -21846 | 0 | 1 | 0 | +| 44 | -21846 | 0 | 2 | 0 | +| 44 | -21846 | 0 | 3 | 0 | +| 44 | -21846 | 0 | 4 | 0 | +| 44 | -21846 | 0 | 5 | 0 | +| 44 | -21846 | 0 | 6 | 0 | +| 44 | -21846 | 0 | 7 | 0 | +| 44+ | 21845 | 1 | 7 | 0 | +| 45 | 21845 | 1 | 7 | 0 | +| 45+ | 21845 | 0 | 0 | 0 | +| 46 | 21845 | 0 | 0 | 0 | +| 46 | 21845 | 0 | 1 | 0 | +| 46 | 21845 | 0 | 2 | 0 | +| 46 | 21845 | 0 | 3 | 0 | +| 46 | 21845 | 0 | 4 | 0 | +| 46 | 21845 | 0 | 5 | 0 | +| 46 | 21845 | 0 | 6 | 0 | +| 46 | 21845 | 0 | 7 | 0 | diff --git a/03/a/Register.hdl b/03/a/Register.hdl index 5a36794f..a4038130 100644 --- a/03/a/Register.hdl +++ b/03/a/Register.hdl @@ -15,4 +15,20 @@ CHIP Register { PARTS: // Put your code here: + Bit(in = in[0], out = out[0], load = load); + Bit(in = in[1], out = out[1], load = load); + Bit(in = in[2], out = out[2], load = load); + Bit(in = in[3], out = out[3], load = load); + Bit(in = in[4], out = out[4], load = load); + Bit(in = in[5], out = out[5], load = load); + Bit(in = in[6], out = out[6], load = load); + Bit(in = in[7], out = out[7], load = load); + Bit(in = in[8], out = out[8], load = load); + Bit(in = in[9], out = out[9], load = load); + Bit(in = in[10], out = out[10], load = load); + Bit(in = in[11], out = out[11], load = load); + Bit(in = in[12], out = out[12], load = load); + Bit(in = in[13], out = out[13], load = load); + Bit(in = in[14], out = out[14], load = load); + Bit(in = in[15], out = out[15], load = load); } diff --git a/03/a/Register.out b/03/a/Register.out new file mode 100644 index 00000000..955184f2 --- /dev/null +++ b/03/a/Register.out @@ -0,0 +1,149 @@ +| time | in |load | out | +| 0+ | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | +| 2 | 0 | 1 | 0 | +| 2+ | -32123 | 0 | 0 | +| 3 | -32123 | 0 | 0 | +| 3+ | 11111 | 0 | 0 | +| 4 | 11111 | 0 | 0 | +| 4+ | -32123 | 1 | 0 | +| 5 | -32123 | 1 | 0 | +| 5+ | -32123 | 1 | 0 | +| 6 | -32123 | 1 | 0 | +| 6+ | -32123 | 0 | 0 | +| 7 | -32123 | 0 | 0 | +| 7+ | 12345 | 1 | 0 | +| 8 | 12345 | 1 | 0 | +| 8+ | 0 | 0 | 0 | +| 9 | 0 | 0 | 0 | +| 9+ | 0 | 1 | 0 | +| 10 | 0 | 1 | 0 | +| 10+ | 1 | 0 | 0 | +| 11 | 1 | 0 | 0 | +| 11+ | 1 | 1 | 0 | +| 12 | 1 | 1 | 0 | +| 12+ | 2 | 0 | 0 | +| 13 | 2 | 0 | 0 | +| 13+ | 2 | 1 | 0 | +| 14 | 2 | 1 | 0 | +| 14+ | 4 | 0 | 0 | +| 15 | 4 | 0 | 0 | +| 15+ | 4 | 1 | 0 | +| 16 | 4 | 1 | 0 | +| 16+ | 8 | 0 | 0 | +| 17 | 8 | 0 | 0 | +| 17+ | 8 | 1 | 0 | +| 18 | 8 | 1 | 0 | +| 18+ | 16 | 0 | 0 | +| 19 | 16 | 0 | 0 | +| 19+ | 16 | 1 | 0 | +| 20 | 16 | 1 | 0 | +| 20+ | 32 | 0 | 0 | +| 21 | 32 | 0 | 0 | +| 21+ | 32 | 1 | 0 | +| 22 | 32 | 1 | 0 | +| 22+ | 64 | 0 | 0 | +| 23 | 64 | 0 | 0 | +| 23+ | 64 | 1 | 0 | +| 24 | 64 | 1 | 0 | +| 24+ | 128 | 0 | 0 | +| 25 | 128 | 0 | 0 | +| 25+ | 128 | 1 | 0 | +| 26 | 128 | 1 | 0 | +| 26+ | 256 | 0 | 0 | +| 27 | 256 | 0 | 0 | +| 27+ | 256 | 1 | 0 | +| 28 | 256 | 1 | 0 | +| 28+ | 512 | 0 | 0 | +| 29 | 512 | 0 | 0 | +| 29+ | 512 | 1 | 0 | +| 30 | 512 | 1 | 0 | +| 30+ | 1024 | 0 | 0 | +| 31 | 1024 | 0 | 0 | +| 31+ | 1024 | 1 | 0 | +| 32 | 1024 | 1 | 0 | +| 32+ | 2048 | 0 | 0 | +| 33 | 2048 | 0 | 0 | +| 33+ | 2048 | 1 | 0 | +| 34 | 2048 | 1 | 0 | +| 34+ | 4096 | 0 | 0 | +| 35 | 4096 | 0 | 0 | +| 35+ | 4096 | 1 | 0 | +| 36 | 4096 | 1 | 0 | +| 36+ | 8192 | 0 | 0 | +| 37 | 8192 | 0 | 0 | +| 37+ | 8192 | 1 | 0 | +| 38 | 8192 | 1 | 0 | +| 38+ | 16384 | 0 | 0 | +| 39 | 16384 | 0 | 0 | +| 39+ | 16384 | 1 | 0 | +| 40 | 16384 | 1 | 0 | +| 40+ | -32768 | 0 | 0 | +| 41 | -32768 | 0 | 0 | +| 41+ | -32768 | 1 | 0 | +| 42 | -32768 | 1 | 0 | +| 42+ | -2 | 0 | 0 | +| 43 | -2 | 0 | 0 | +| 43+ | -2 | 1 | 0 | +| 44 | -2 | 1 | 0 | +| 44+ | -3 | 0 | 0 | +| 45 | -3 | 0 | 0 | +| 45+ | -3 | 1 | 0 | +| 46 | -3 | 1 | 0 | +| 46+ | -5 | 0 | 0 | +| 47 | -5 | 0 | 0 | +| 47+ | -5 | 1 | 0 | +| 48 | -5 | 1 | 0 | +| 48+ | -9 | 0 | 0 | +| 49 | -9 | 0 | 0 | +| 49+ | -9 | 1 | 0 | +| 50 | -9 | 1 | 0 | +| 50+ | -17 | 0 | 0 | +| 51 | -17 | 0 | 0 | +| 51+ | -17 | 1 | 0 | +| 52 | -17 | 1 | 0 | +| 52+ | -33 | 0 | 0 | +| 53 | -33 | 0 | 0 | +| 53+ | -33 | 1 | 0 | +| 54 | -33 | 1 | 0 | +| 54+ | -65 | 0 | 0 | +| 55 | -65 | 0 | 0 | +| 55+ | -65 | 1 | 0 | +| 56 | -65 | 1 | 0 | +| 56+ | -129 | 0 | 0 | +| 57 | -129 | 0 | 0 | +| 57+ | -129 | 1 | 0 | +| 58 | -129 | 1 | 0 | +| 58+ | -257 | 0 | 0 | +| 59 | -257 | 0 | 0 | +| 59+ | -257 | 1 | 0 | +| 60 | -257 | 1 | 0 | +| 60+ | -513 | 0 | 0 | +| 61 | -513 | 0 | 0 | +| 61+ | -513 | 1 | 0 | +| 62 | -513 | 1 | 0 | +| 62+ | -1025 | 0 | 0 | +| 63 | -1025 | 0 | 0 | +| 63+ | -1025 | 1 | 0 | +| 64 | -1025 | 1 | 0 | +| 64+ | -2049 | 0 | 0 | +| 65 | -2049 | 0 | 0 | +| 65+ | -2049 | 1 | 0 | +| 66 | -2049 | 1 | 0 | +| 66+ | -4097 | 0 | 0 | +| 67 | -4097 | 0 | 0 | +| 67+ | -4097 | 1 | 0 | +| 68 | -4097 | 1 | 0 | +| 68+ | -8193 | 0 | 0 | +| 69 | -8193 | 0 | 0 | +| 69+ | -8193 | 1 | 0 | +| 70 | -8193 | 1 | 0 | +| 70+ | -16385 | 0 | 0 | +| 71 | -16385 | 0 | 0 | +| 71+ | -16385 | 1 | 0 | +| 72 | -16385 | 1 | 0 | +| 72+ | 32767 | 0 | 0 | +| 73 | 32767 | 0 | 0 | +| 73+ | 32767 | 1 | 0 | +| 74 | 32767 | 1 | 0 | diff --git a/03/b/RAM16K.hdl b/03/b/RAM16K.hdl index a4306194..eb59cc40 100644 --- a/03/b/RAM16K.hdl +++ b/03/b/RAM16K.hdl @@ -16,4 +16,12 @@ CHIP RAM16K { PARTS: // Put your code here: + DMux4Way(in=load,sel=address[12..13],a=a,b=b,c=c,d=d); + + RAM4K(in=in,load=a,address=address[0..11],out=oa); + RAM4K(in=in,load=b,address=address[0..11],out=ob); + RAM4K(in=in,load=c,address=address[0..11],out=oc); + RAM4K(in=in,load=d,address=address[0..11],out=od); + + Mux4Way16(a=oa,b=ob,c=oc,d=od,sel=address[12..13],out=out); } \ No newline at end of file diff --git a/03/b/RAM16K.out b/03/b/RAM16K.out new file mode 100644 index 00000000..8f473b1c --- /dev/null +++ b/03/b/RAM16K.out @@ -0,0 +1,320 @@ +| time | in |load | address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 4321 | 0 | 0 | 0 | +| 3 | 4321 | 0 | 0 | 0 | +| 3+ | 4321 | 1 | 4321 | 0 | +| 4 | 4321 | 1 | 4321 | 0 | +| 4+ | 4321 | 0 | 0 | 0 | +| 5 | 4321 | 0 | 0 | 0 | +| 5+ | 12345 | 0 | 12345 | 0 | +| 6 | 12345 | 0 | 12345 | 0 | +| 6+ | 12345 | 1 | 12345 | 0 | +| 7 | 12345 | 1 | 12345 | 0 | +| 7+ | 12345 | 0 | 12345 | 0 | +| 8 | 12345 | 0 | 12345 | 0 | +| 8 | 12345 | 0 | 4321 | 0 | +| 8+ | 16383 | 0 | 4321 | 0 | +| 9 | 16383 | 0 | 4321 | 0 | +| 9+ | 16383 | 1 | 16383 | 0 | +| 10 | 16383 | 1 | 16383 | 0 | +| 10+ | 16383 | 0 | 16383 | 0 | +| 11 | 16383 | 0 | 16383 | 0 | +| 11 | 16383 | 0 | 12345 | 0 | +| 11 | 16383 | 0 | 16383 | 0 | +| 11+ | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10920 | 0 | +| 12 | 16383 | 0 | 10921 | 0 | +| 12 | 16383 | 0 | 10922 | 0 | +| 12 | 16383 | 0 | 10923 | 0 | +| 12 | 16383 | 0 | 10924 | 0 | +| 12 | 16383 | 0 | 10925 | 0 | +| 12 | 16383 | 0 | 10926 | 0 | +| 12 | 16383 | 0 | 10927 | 0 | +| 12+ | 21845 | 1 | 10920 | 0 | +| 13 | 21845 | 1 | 10920 | 0 | +| 13+ | 21845 | 1 | 10921 | 0 | +| 14 | 21845 | 1 | 10921 | 0 | +| 14+ | 21845 | 1 | 10922 | 0 | +| 15 | 21845 | 1 | 10922 | 0 | +| 15+ | 21845 | 1 | 10923 | 0 | +| 16 | 21845 | 1 | 10923 | 0 | +| 16+ | 21845 | 1 | 10924 | 0 | +| 17 | 21845 | 1 | 10924 | 0 | +| 17+ | 21845 | 1 | 10925 | 0 | +| 18 | 21845 | 1 | 10925 | 0 | +| 18+ | 21845 | 1 | 10926 | 0 | +| 19 | 21845 | 1 | 10926 | 0 | +| 19+ | 21845 | 1 | 10927 | 0 | +| 20 | 21845 | 1 | 10927 | 0 | +| 20+ | 21845 | 0 | 10920 | 0 | +| 21 | 21845 | 0 | 10920 | 0 | +| 21 | 21845 | 0 | 10921 | 0 | +| 21 | 21845 | 0 | 10922 | 0 | +| 21 | 21845 | 0 | 10923 | 0 | +| 21 | 21845 | 0 | 10924 | 0 | +| 21 | 21845 | 0 | 10925 | 0 | +| 21 | 21845 | 0 | 10926 | 0 | +| 21 | 21845 | 0 | 10927 | 0 | +| 21+ | -21846 | 1 | 10920 | 0 | +| 22 | -21846 | 1 | 10920 | 0 | +| 22+ | -21846 | 0 | 10920 | 0 | +| 23 | -21846 | 0 | 10920 | 0 | +| 23 | -21846 | 0 | 10921 | 0 | +| 23 | -21846 | 0 | 10922 | 0 | +| 23 | -21846 | 0 | 10923 | 0 | +| 23 | -21846 | 0 | 10924 | 0 | +| 23 | -21846 | 0 | 10925 | 0 | +| 23 | -21846 | 0 | 10926 | 0 | +| 23 | -21846 | 0 | 10927 | 0 | +| 23+ | 21845 | 1 | 10920 | 0 | +| 24 | 21845 | 1 | 10920 | 0 | +| 24+ | -21846 | 1 | 10921 | 0 | +| 25 | -21846 | 1 | 10921 | 0 | +| 25+ | -21846 | 0 | 10920 | 0 | +| 26 | -21846 | 0 | 10920 | 0 | +| 26 | -21846 | 0 | 10921 | 0 | +| 26 | -21846 | 0 | 10922 | 0 | +| 26 | -21846 | 0 | 10923 | 0 | +| 26 | -21846 | 0 | 10924 | 0 | +| 26 | -21846 | 0 | 10925 | 0 | +| 26 | -21846 | 0 | 10926 | 0 | +| 26 | -21846 | 0 | 10927 | 0 | +| 26+ | 21845 | 1 | 10921 | 0 | +| 27 | 21845 | 1 | 10921 | 0 | +| 27+ | -21846 | 1 | 10922 | 0 | +| 28 | -21846 | 1 | 10922 | 0 | +| 28+ | -21846 | 0 | 10920 | 0 | +| 29 | -21846 | 0 | 10920 | 0 | +| 29 | -21846 | 0 | 10921 | 0 | +| 29 | -21846 | 0 | 10922 | 0 | +| 29 | -21846 | 0 | 10923 | 0 | +| 29 | -21846 | 0 | 10924 | 0 | +| 29 | -21846 | 0 | 10925 | 0 | +| 29 | -21846 | 0 | 10926 | 0 | +| 29 | -21846 | 0 | 10927 | 0 | +| 29+ | 21845 | 1 | 10922 | 0 | +| 30 | 21845 | 1 | 10922 | 0 | +| 30+ | -21846 | 1 | 10923 | 0 | +| 31 | -21846 | 1 | 10923 | 0 | +| 31+ | -21846 | 0 | 10920 | 0 | +| 32 | -21846 | 0 | 10920 | 0 | +| 32 | -21846 | 0 | 10921 | 0 | +| 32 | -21846 | 0 | 10922 | 0 | +| 32 | -21846 | 0 | 10923 | 0 | +| 32 | -21846 | 0 | 10924 | 0 | +| 32 | -21846 | 0 | 10925 | 0 | +| 32 | -21846 | 0 | 10926 | 0 | +| 32 | -21846 | 0 | 10927 | 0 | +| 32+ | 21845 | 1 | 10923 | 0 | +| 33 | 21845 | 1 | 10923 | 0 | +| 33+ | -21846 | 1 | 10924 | 0 | +| 34 | -21846 | 1 | 10924 | 0 | +| 34+ | -21846 | 0 | 10920 | 0 | +| 35 | -21846 | 0 | 10920 | 0 | +| 35 | -21846 | 0 | 10921 | 0 | +| 35 | -21846 | 0 | 10922 | 0 | +| 35 | -21846 | 0 | 10923 | 0 | +| 35 | -21846 | 0 | 10924 | 0 | +| 35 | -21846 | 0 | 10925 | 0 | +| 35 | -21846 | 0 | 10926 | 0 | +| 35 | -21846 | 0 | 10927 | 0 | +| 35+ | 21845 | 1 | 10924 | 0 | +| 36 | 21845 | 1 | 10924 | 0 | +| 36+ | -21846 | 1 | 10925 | 0 | +| 37 | -21846 | 1 | 10925 | 0 | +| 37+ | -21846 | 0 | 10920 | 0 | +| 38 | -21846 | 0 | 10920 | 0 | +| 38 | -21846 | 0 | 10921 | 0 | +| 38 | -21846 | 0 | 10922 | 0 | +| 38 | -21846 | 0 | 10923 | 0 | +| 38 | -21846 | 0 | 10924 | 0 | +| 38 | -21846 | 0 | 10925 | 0 | +| 38 | -21846 | 0 | 10926 | 0 | +| 38 | -21846 | 0 | 10927 | 0 | +| 38+ | 21845 | 1 | 10925 | 0 | +| 39 | 21845 | 1 | 10925 | 0 | +| 39+ | -21846 | 1 | 10926 | 0 | +| 40 | -21846 | 1 | 10926 | 0 | +| 40+ | -21846 | 0 | 10920 | 0 | +| 41 | -21846 | 0 | 10920 | 0 | +| 41 | -21846 | 0 | 10921 | 0 | +| 41 | -21846 | 0 | 10922 | 0 | +| 41 | -21846 | 0 | 10923 | 0 | +| 41 | -21846 | 0 | 10924 | 0 | +| 41 | -21846 | 0 | 10925 | 0 | +| 41 | -21846 | 0 | 10926 | 0 | +| 41 | -21846 | 0 | 10927 | 0 | +| 41+ | 21845 | 1 | 10926 | 0 | +| 42 | 21845 | 1 | 10926 | 0 | +| 42+ | -21846 | 1 | 10927 | 0 | +| 43 | -21846 | 1 | 10927 | 0 | +| 43+ | -21846 | 0 | 10920 | 0 | +| 44 | -21846 | 0 | 10920 | 0 | +| 44 | -21846 | 0 | 10921 | 0 | +| 44 | -21846 | 0 | 10922 | 0 | +| 44 | -21846 | 0 | 10923 | 0 | +| 44 | -21846 | 0 | 10924 | 0 | +| 44 | -21846 | 0 | 10925 | 0 | +| 44 | -21846 | 0 | 10926 | 0 | +| 44 | -21846 | 0 | 10927 | 0 | +| 44+ | 21845 | 1 | 10927 | 0 | +| 45 | 21845 | 1 | 10927 | 0 | +| 45+ | 21845 | 0 | 10920 | 0 | +| 46 | 21845 | 0 | 10920 | 0 | +| 46 | 21845 | 0 | 10921 | 0 | +| 46 | 21845 | 0 | 10922 | 0 | +| 46 | 21845 | 0 | 10923 | 0 | +| 46 | 21845 | 0 | 10924 | 0 | +| 46 | 21845 | 0 | 10925 | 0 | +| 46 | 21845 | 0 | 10926 | 0 | +| 46 | 21845 | 0 | 10927 | 0 | +| 46+ | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 5461 | 0 | +| 47 | 21845 | 0 | 7509 | 0 | +| 47 | 21845 | 0 | 9557 | 0 | +| 47 | 21845 | 0 | 11605 | 0 | +| 47 | 21845 | 0 | 13653 | 0 | +| 47 | 21845 | 0 | 15701 | 0 | +| 47+ | 21845 | 1 | 1365 | 0 | +| 48 | 21845 | 1 | 1365 | 0 | +| 48+ | 21845 | 1 | 3413 | 0 | +| 49 | 21845 | 1 | 3413 | 0 | +| 49+ | 21845 | 1 | 5461 | 0 | +| 50 | 21845 | 1 | 5461 | 0 | +| 50+ | 21845 | 1 | 7509 | 0 | +| 51 | 21845 | 1 | 7509 | 0 | +| 51+ | 21845 | 1 | 9557 | 0 | +| 52 | 21845 | 1 | 9557 | 0 | +| 52+ | 21845 | 1 | 11605 | 0 | +| 53 | 21845 | 1 | 11605 | 0 | +| 53+ | 21845 | 1 | 13653 | 0 | +| 54 | 21845 | 1 | 13653 | 0 | +| 54+ | 21845 | 1 | 15701 | 0 | +| 55 | 21845 | 1 | 15701 | 0 | +| 55+ | 21845 | 0 | 1365 | 0 | +| 56 | 21845 | 0 | 1365 | 0 | +| 56 | 21845 | 0 | 3413 | 0 | +| 56 | 21845 | 0 | 5461 | 0 | +| 56 | 21845 | 0 | 7509 | 0 | +| 56 | 21845 | 0 | 9557 | 0 | +| 56 | 21845 | 0 | 11605 | 0 | +| 56 | 21845 | 0 | 13653 | 0 | +| 56 | 21845 | 0 | 15701 | 0 | +| 56+ | -21846 | 1 | 1365 | 0 | +| 57 | -21846 | 1 | 1365 | 0 | +| 57+ | -21846 | 0 | 1365 | 0 | +| 58 | -21846 | 0 | 1365 | 0 | +| 58 | -21846 | 0 | 3413 | 0 | +| 58 | -21846 | 0 | 5461 | 0 | +| 58 | -21846 | 0 | 7509 | 0 | +| 58 | -21846 | 0 | 9557 | 0 | +| 58 | -21846 | 0 | 11605 | 0 | +| 58 | -21846 | 0 | 13653 | 0 | +| 58 | -21846 | 0 | 15701 | 0 | +| 58+ | 21845 | 1 | 1365 | 0 | +| 59 | 21845 | 1 | 1365 | 0 | +| 59+ | -21846 | 1 | 3413 | 0 | +| 60 | -21846 | 1 | 3413 | 0 | +| 60+ | -21846 | 0 | 1365 | 0 | +| 61 | -21846 | 0 | 1365 | 0 | +| 61 | -21846 | 0 | 3413 | 0 | +| 61 | -21846 | 0 | 5461 | 0 | +| 61 | -21846 | 0 | 7509 | 0 | +| 61 | -21846 | 0 | 9557 | 0 | +| 61 | -21846 | 0 | 11605 | 0 | +| 61 | -21846 | 0 | 13653 | 0 | +| 61 | -21846 | 0 | 15701 | 0 | +| 61+ | 21845 | 1 | 3413 | 0 | +| 62 | 21845 | 1 | 3413 | 0 | +| 62+ | -21846 | 1 | 5461 | 0 | +| 63 | -21846 | 1 | 5461 | 0 | +| 63+ | -21846 | 0 | 1365 | 0 | +| 64 | -21846 | 0 | 1365 | 0 | +| 64 | -21846 | 0 | 3413 | 0 | +| 64 | -21846 | 0 | 5461 | 0 | +| 64 | -21846 | 0 | 7509 | 0 | +| 64 | -21846 | 0 | 9557 | 0 | +| 64 | -21846 | 0 | 11605 | 0 | +| 64 | -21846 | 0 | 13653 | 0 | +| 64 | -21846 | 0 | 15701 | 0 | +| 64+ | 21845 | 1 | 5461 | 0 | +| 65 | 21845 | 1 | 5461 | 0 | +| 65+ | -21846 | 1 | 7509 | 0 | +| 66 | -21846 | 1 | 7509 | 0 | +| 66+ | -21846 | 0 | 1365 | 0 | +| 67 | -21846 | 0 | 1365 | 0 | +| 67 | -21846 | 0 | 3413 | 0 | +| 67 | -21846 | 0 | 5461 | 0 | +| 67 | -21846 | 0 | 7509 | 0 | +| 67 | -21846 | 0 | 9557 | 0 | +| 67 | -21846 | 0 | 11605 | 0 | +| 67 | -21846 | 0 | 13653 | 0 | +| 67 | -21846 | 0 | 15701 | 0 | +| 67+ | 21845 | 1 | 7509 | 0 | +| 68 | 21845 | 1 | 7509 | 0 | +| 68+ | -21846 | 1 | 9557 | 0 | +| 69 | -21846 | 1 | 9557 | 0 | +| 69+ | -21846 | 0 | 1365 | 0 | +| 70 | -21846 | 0 | 1365 | 0 | +| 70 | -21846 | 0 | 3413 | 0 | +| 70 | -21846 | 0 | 5461 | 0 | +| 70 | -21846 | 0 | 7509 | 0 | +| 70 | -21846 | 0 | 9557 | 0 | +| 70 | -21846 | 0 | 11605 | 0 | +| 70 | -21846 | 0 | 13653 | 0 | +| 70 | -21846 | 0 | 15701 | 0 | +| 70+ | 21845 | 1 | 9557 | 0 | +| 71 | 21845 | 1 | 9557 | 0 | +| 71+ | -21846 | 1 | 11605 | 0 | +| 72 | -21846 | 1 | 11605 | 0 | +| 72+ | -21846 | 0 | 1365 | 0 | +| 73 | -21846 | 0 | 1365 | 0 | +| 73 | -21846 | 0 | 3413 | 0 | +| 73 | -21846 | 0 | 5461 | 0 | +| 73 | -21846 | 0 | 7509 | 0 | +| 73 | -21846 | 0 | 9557 | 0 | +| 73 | -21846 | 0 | 11605 | 0 | +| 73 | -21846 | 0 | 13653 | 0 | +| 73 | -21846 | 0 | 15701 | 0 | +| 73+ | 21845 | 1 | 11605 | 0 | +| 74 | 21845 | 1 | 11605 | 0 | +| 74+ | -21846 | 1 | 13653 | 0 | +| 75 | -21846 | 1 | 13653 | 0 | +| 75+ | -21846 | 0 | 1365 | 0 | +| 76 | -21846 | 0 | 1365 | 0 | +| 76 | -21846 | 0 | 3413 | 0 | +| 76 | -21846 | 0 | 5461 | 0 | +| 76 | -21846 | 0 | 7509 | 0 | +| 76 | -21846 | 0 | 9557 | 0 | +| 76 | -21846 | 0 | 11605 | 0 | +| 76 | -21846 | 0 | 13653 | 0 | +| 76 | -21846 | 0 | 15701 | 0 | +| 76+ | 21845 | 1 | 13653 | 0 | +| 77 | 21845 | 1 | 13653 | 0 | +| 77+ | -21846 | 1 | 15701 | 0 | +| 78 | -21846 | 1 | 15701 | 0 | +| 78+ | -21846 | 0 | 1365 | 0 | +| 79 | -21846 | 0 | 1365 | 0 | +| 79 | -21846 | 0 | 3413 | 0 | +| 79 | -21846 | 0 | 5461 | 0 | +| 79 | -21846 | 0 | 7509 | 0 | +| 79 | -21846 | 0 | 9557 | 0 | +| 79 | -21846 | 0 | 11605 | 0 | +| 79 | -21846 | 0 | 13653 | 0 | +| 79 | -21846 | 0 | 15701 | 0 | +| 79+ | 21845 | 1 | 15701 | 0 | +| 80 | 21845 | 1 | 15701 | 0 | +| 80+ | 21845 | 0 | 1365 | 0 | +| 81 | 21845 | 0 | 1365 | 0 | +| 81 | 21845 | 0 | 3413 | 0 | +| 81 | 21845 | 0 | 5461 | 0 | +| 81 | 21845 | 0 | 7509 | 0 | +| 81 | 21845 | 0 | 9557 | 0 | +| 81 | 21845 | 0 | 11605 | 0 | +| 81 | 21845 | 0 | 13653 | 0 | +| 81 | 21845 | 0 | 15701 | 0 | diff --git a/03/b/RAM4K.hdl b/03/b/RAM4K.hdl index c3bc33bd..b82fed5b 100644 --- a/03/b/RAM4K.hdl +++ b/03/b/RAM4K.hdl @@ -16,4 +16,16 @@ CHIP RAM4K { PARTS: // Put your code here: + DMux8Way(in=load,sel=address[9..11],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + RAM512(in=in,load=a,address=address[0..8],out=oa); + RAM512(in=in,load=b,address=address[0..8],out=ob); + RAM512(in=in,load=c,address=address[0..8],out=oc); + RAM512(in=in,load=d,address=address[0..8],out=od); + RAM512(in=in,load=e,address=address[0..8],out=oe); + RAM512(in=in,load=f,address=address[0..8],out=of); + RAM512(in=in,load=g,address=address[0..8],out=og); + RAM512(in=in,load=h,address=address[0..8],out=oh); + + Mux8Way16(a=oa,b=ob,c=oc,d=od,e=oe,f=of,g=og,h=oh,sel=address[9..11],out=out); } \ No newline at end of file diff --git a/03/b/RAM4K.out b/03/b/RAM4K.out new file mode 100644 index 00000000..9b459ba9 --- /dev/null +++ b/03/b/RAM4K.out @@ -0,0 +1,320 @@ +| time | in |load |address | out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 1111 | 0 | 0 | 0 | +| 3 | 1111 | 0 | 0 | 0 | +| 3+ | 1111 | 1 | 1111 | 0 | +| 4 | 1111 | 1 | 1111 | 0 | +| 4+ | 1111 | 0 | 0 | 0 | +| 5 | 1111 | 0 | 0 | 0 | +| 5+ | 3513 | 0 | 3513 | 0 | +| 6 | 3513 | 0 | 3513 | 0 | +| 6+ | 3513 | 1 | 3513 | 0 | +| 7 | 3513 | 1 | 3513 | 0 | +| 7+ | 3513 | 0 | 3513 | 0 | +| 8 | 3513 | 0 | 3513 | 0 | +| 8 | 3513 | 0 | 1111 | 0 | +| 8+ | 4095 | 0 | 1111 | 0 | +| 9 | 4095 | 0 | 1111 | 0 | +| 9+ | 4095 | 1 | 4095 | 0 | +| 10 | 4095 | 1 | 4095 | 0 | +| 10+ | 4095 | 0 | 4095 | 0 | +| 11 | 4095 | 0 | 4095 | 0 | +| 11 | 4095 | 0 | 3513 | 0 | +| 11 | 4095 | 0 | 4095 | 0 | +| 11+ | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2728 | 0 | +| 12 | 4095 | 0 | 2729 | 0 | +| 12 | 4095 | 0 | 2730 | 0 | +| 12 | 4095 | 0 | 2731 | 0 | +| 12 | 4095 | 0 | 2732 | 0 | +| 12 | 4095 | 0 | 2733 | 0 | +| 12 | 4095 | 0 | 2734 | 0 | +| 12 | 4095 | 0 | 2735 | 0 | +| 12+ | 21845 | 1 | 2728 | 0 | +| 13 | 21845 | 1 | 2728 | 0 | +| 13+ | 21845 | 1 | 2729 | 0 | +| 14 | 21845 | 1 | 2729 | 0 | +| 14+ | 21845 | 1 | 2730 | 0 | +| 15 | 21845 | 1 | 2730 | 0 | +| 15+ | 21845 | 1 | 2731 | 0 | +| 16 | 21845 | 1 | 2731 | 0 | +| 16+ | 21845 | 1 | 2732 | 0 | +| 17 | 21845 | 1 | 2732 | 0 | +| 17+ | 21845 | 1 | 2733 | 0 | +| 18 | 21845 | 1 | 2733 | 0 | +| 18+ | 21845 | 1 | 2734 | 0 | +| 19 | 21845 | 1 | 2734 | 0 | +| 19+ | 21845 | 1 | 2735 | 0 | +| 20 | 21845 | 1 | 2735 | 0 | +| 20+ | 21845 | 0 | 2728 | 0 | +| 21 | 21845 | 0 | 2728 | 0 | +| 21 | 21845 | 0 | 2729 | 0 | +| 21 | 21845 | 0 | 2730 | 0 | +| 21 | 21845 | 0 | 2731 | 0 | +| 21 | 21845 | 0 | 2732 | 0 | +| 21 | 21845 | 0 | 2733 | 0 | +| 21 | 21845 | 0 | 2734 | 0 | +| 21 | 21845 | 0 | 2735 | 0 | +| 21+ | -21846 | 1 | 2728 | 0 | +| 22 | -21846 | 1 | 2728 | 0 | +| 22+ | -21846 | 0 | 2728 | 0 | +| 23 | -21846 | 0 | 2728 | 0 | +| 23 | -21846 | 0 | 2729 | 0 | +| 23 | -21846 | 0 | 2730 | 0 | +| 23 | -21846 | 0 | 2731 | 0 | +| 23 | -21846 | 0 | 2732 | 0 | +| 23 | -21846 | 0 | 2733 | 0 | +| 23 | -21846 | 0 | 2734 | 0 | +| 23 | -21846 | 0 | 2735 | 0 | +| 23+ | 21845 | 1 | 2728 | 0 | +| 24 | 21845 | 1 | 2728 | 0 | +| 24+ | -21846 | 1 | 2729 | 0 | +| 25 | -21846 | 1 | 2729 | 0 | +| 25+ | -21846 | 0 | 2728 | 0 | +| 26 | -21846 | 0 | 2728 | 0 | +| 26 | -21846 | 0 | 2729 | 0 | +| 26 | -21846 | 0 | 2730 | 0 | +| 26 | -21846 | 0 | 2731 | 0 | +| 26 | -21846 | 0 | 2732 | 0 | +| 26 | -21846 | 0 | 2733 | 0 | +| 26 | -21846 | 0 | 2734 | 0 | +| 26 | -21846 | 0 | 2735 | 0 | +| 26+ | 21845 | 1 | 2729 | 0 | +| 27 | 21845 | 1 | 2729 | 0 | +| 27+ | -21846 | 1 | 2730 | 0 | +| 28 | -21846 | 1 | 2730 | 0 | +| 28+ | -21846 | 0 | 2728 | 0 | +| 29 | -21846 | 0 | 2728 | 0 | +| 29 | -21846 | 0 | 2729 | 0 | +| 29 | -21846 | 0 | 2730 | 0 | +| 29 | -21846 | 0 | 2731 | 0 | +| 29 | -21846 | 0 | 2732 | 0 | +| 29 | -21846 | 0 | 2733 | 0 | +| 29 | -21846 | 0 | 2734 | 0 | +| 29 | -21846 | 0 | 2735 | 0 | +| 29+ | 21845 | 1 | 2730 | 0 | +| 30 | 21845 | 1 | 2730 | 0 | +| 30+ | -21846 | 1 | 2731 | 0 | +| 31 | -21846 | 1 | 2731 | 0 | +| 31+ | -21846 | 0 | 2728 | 0 | +| 32 | -21846 | 0 | 2728 | 0 | +| 32 | -21846 | 0 | 2729 | 0 | +| 32 | -21846 | 0 | 2730 | 0 | +| 32 | -21846 | 0 | 2731 | 0 | +| 32 | -21846 | 0 | 2732 | 0 | +| 32 | -21846 | 0 | 2733 | 0 | +| 32 | -21846 | 0 | 2734 | 0 | +| 32 | -21846 | 0 | 2735 | 0 | +| 32+ | 21845 | 1 | 2731 | 0 | +| 33 | 21845 | 1 | 2731 | 0 | +| 33+ | -21846 | 1 | 2732 | 0 | +| 34 | -21846 | 1 | 2732 | 0 | +| 34+ | -21846 | 0 | 2728 | 0 | +| 35 | -21846 | 0 | 2728 | 0 | +| 35 | -21846 | 0 | 2729 | 0 | +| 35 | -21846 | 0 | 2730 | 0 | +| 35 | -21846 | 0 | 2731 | 0 | +| 35 | -21846 | 0 | 2732 | 0 | +| 35 | -21846 | 0 | 2733 | 0 | +| 35 | -21846 | 0 | 2734 | 0 | +| 35 | -21846 | 0 | 2735 | 0 | +| 35+ | 21845 | 1 | 2732 | 0 | +| 36 | 21845 | 1 | 2732 | 0 | +| 36+ | -21846 | 1 | 2733 | 0 | +| 37 | -21846 | 1 | 2733 | 0 | +| 37+ | -21846 | 0 | 2728 | 0 | +| 38 | -21846 | 0 | 2728 | 0 | +| 38 | -21846 | 0 | 2729 | 0 | +| 38 | -21846 | 0 | 2730 | 0 | +| 38 | -21846 | 0 | 2731 | 0 | +| 38 | -21846 | 0 | 2732 | 0 | +| 38 | -21846 | 0 | 2733 | 0 | +| 38 | -21846 | 0 | 2734 | 0 | +| 38 | -21846 | 0 | 2735 | 0 | +| 38+ | 21845 | 1 | 2733 | 0 | +| 39 | 21845 | 1 | 2733 | 0 | +| 39+ | -21846 | 1 | 2734 | 0 | +| 40 | -21846 | 1 | 2734 | 0 | +| 40+ | -21846 | 0 | 2728 | 0 | +| 41 | -21846 | 0 | 2728 | 0 | +| 41 | -21846 | 0 | 2729 | 0 | +| 41 | -21846 | 0 | 2730 | 0 | +| 41 | -21846 | 0 | 2731 | 0 | +| 41 | -21846 | 0 | 2732 | 0 | +| 41 | -21846 | 0 | 2733 | 0 | +| 41 | -21846 | 0 | 2734 | 0 | +| 41 | -21846 | 0 | 2735 | 0 | +| 41+ | 21845 | 1 | 2734 | 0 | +| 42 | 21845 | 1 | 2734 | 0 | +| 42+ | -21846 | 1 | 2735 | 0 | +| 43 | -21846 | 1 | 2735 | 0 | +| 43+ | -21846 | 0 | 2728 | 0 | +| 44 | -21846 | 0 | 2728 | 0 | +| 44 | -21846 | 0 | 2729 | 0 | +| 44 | -21846 | 0 | 2730 | 0 | +| 44 | -21846 | 0 | 2731 | 0 | +| 44 | -21846 | 0 | 2732 | 0 | +| 44 | -21846 | 0 | 2733 | 0 | +| 44 | -21846 | 0 | 2734 | 0 | +| 44 | -21846 | 0 | 2735 | 0 | +| 44+ | 21845 | 1 | 2735 | 0 | +| 45 | 21845 | 1 | 2735 | 0 | +| 45+ | 21845 | 0 | 2728 | 0 | +| 46 | 21845 | 0 | 2728 | 0 | +| 46 | 21845 | 0 | 2729 | 0 | +| 46 | 21845 | 0 | 2730 | 0 | +| 46 | 21845 | 0 | 2731 | 0 | +| 46 | 21845 | 0 | 2732 | 0 | +| 46 | 21845 | 0 | 2733 | 0 | +| 46 | 21845 | 0 | 2734 | 0 | +| 46 | 21845 | 0 | 2735 | 0 | +| 46+ | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 341 | 0 | +| 47 | 21845 | 0 | 853 | 0 | +| 47 | 21845 | 0 | 1365 | 0 | +| 47 | 21845 | 0 | 1877 | 0 | +| 47 | 21845 | 0 | 2389 | 0 | +| 47 | 21845 | 0 | 2901 | 0 | +| 47 | 21845 | 0 | 3413 | 0 | +| 47 | 21845 | 0 | 3925 | 0 | +| 47+ | 21845 | 1 | 341 | 0 | +| 48 | 21845 | 1 | 341 | 0 | +| 48+ | 21845 | 1 | 853 | 0 | +| 49 | 21845 | 1 | 853 | 0 | +| 49+ | 21845 | 1 | 1365 | 0 | +| 50 | 21845 | 1 | 1365 | 0 | +| 50+ | 21845 | 1 | 1877 | 0 | +| 51 | 21845 | 1 | 1877 | 0 | +| 51+ | 21845 | 1 | 2389 | 0 | +| 52 | 21845 | 1 | 2389 | 0 | +| 52+ | 21845 | 1 | 2901 | 0 | +| 53 | 21845 | 1 | 2901 | 0 | +| 53+ | 21845 | 1 | 3413 | 0 | +| 54 | 21845 | 1 | 3413 | 0 | +| 54+ | 21845 | 1 | 3925 | 0 | +| 55 | 21845 | 1 | 3925 | 0 | +| 55+ | 21845 | 0 | 341 | 0 | +| 56 | 21845 | 0 | 341 | 0 | +| 56 | 21845 | 0 | 853 | 0 | +| 56 | 21845 | 0 | 1365 | 0 | +| 56 | 21845 | 0 | 1877 | 0 | +| 56 | 21845 | 0 | 2389 | 0 | +| 56 | 21845 | 0 | 2901 | 0 | +| 56 | 21845 | 0 | 3413 | 0 | +| 56 | 21845 | 0 | 3925 | 0 | +| 56+ | -21846 | 1 | 341 | 0 | +| 57 | -21846 | 1 | 341 | 0 | +| 57+ | -21846 | 0 | 341 | 0 | +| 58 | -21846 | 0 | 341 | 0 | +| 58 | -21846 | 0 | 853 | 0 | +| 58 | -21846 | 0 | 1365 | 0 | +| 58 | -21846 | 0 | 1877 | 0 | +| 58 | -21846 | 0 | 2389 | 0 | +| 58 | -21846 | 0 | 2901 | 0 | +| 58 | -21846 | 0 | 3413 | 0 | +| 58 | -21846 | 0 | 3925 | 0 | +| 58+ | 21845 | 1 | 341 | 0 | +| 59 | 21845 | 1 | 341 | 0 | +| 59+ | -21846 | 1 | 853 | 0 | +| 60 | -21846 | 1 | 853 | 0 | +| 60+ | -21846 | 0 | 341 | 0 | +| 61 | -21846 | 0 | 341 | 0 | +| 61 | -21846 | 0 | 853 | 0 | +| 61 | -21846 | 0 | 1365 | 0 | +| 61 | -21846 | 0 | 1877 | 0 | +| 61 | -21846 | 0 | 2389 | 0 | +| 61 | -21846 | 0 | 2901 | 0 | +| 61 | -21846 | 0 | 3413 | 0 | +| 61 | -21846 | 0 | 3925 | 0 | +| 61+ | 21845 | 1 | 853 | 0 | +| 62 | 21845 | 1 | 853 | 0 | +| 62+ | -21846 | 1 | 1365 | 0 | +| 63 | -21846 | 1 | 1365 | 0 | +| 63+ | -21846 | 0 | 341 | 0 | +| 64 | -21846 | 0 | 341 | 0 | +| 64 | -21846 | 0 | 853 | 0 | +| 64 | -21846 | 0 | 1365 | 0 | +| 64 | -21846 | 0 | 1877 | 0 | +| 64 | -21846 | 0 | 2389 | 0 | +| 64 | -21846 | 0 | 2901 | 0 | +| 64 | -21846 | 0 | 3413 | 0 | +| 64 | -21846 | 0 | 3925 | 0 | +| 64+ | 21845 | 1 | 1365 | 0 | +| 65 | 21845 | 1 | 1365 | 0 | +| 65+ | -21846 | 1 | 1877 | 0 | +| 66 | -21846 | 1 | 1877 | 0 | +| 66+ | -21846 | 0 | 341 | 0 | +| 67 | -21846 | 0 | 341 | 0 | +| 67 | -21846 | 0 | 853 | 0 | +| 67 | -21846 | 0 | 1365 | 0 | +| 67 | -21846 | 0 | 1877 | 0 | +| 67 | -21846 | 0 | 2389 | 0 | +| 67 | -21846 | 0 | 2901 | 0 | +| 67 | -21846 | 0 | 3413 | 0 | +| 67 | -21846 | 0 | 3925 | 0 | +| 67+ | 21845 | 1 | 1877 | 0 | +| 68 | 21845 | 1 | 1877 | 0 | +| 68+ | -21846 | 1 | 2389 | 0 | +| 69 | -21846 | 1 | 2389 | 0 | +| 69+ | -21846 | 0 | 341 | 0 | +| 70 | -21846 | 0 | 341 | 0 | +| 70 | -21846 | 0 | 853 | 0 | +| 70 | -21846 | 0 | 1365 | 0 | +| 70 | -21846 | 0 | 1877 | 0 | +| 70 | -21846 | 0 | 2389 | 0 | +| 70 | -21846 | 0 | 2901 | 0 | +| 70 | -21846 | 0 | 3413 | 0 | +| 70 | -21846 | 0 | 3925 | 0 | +| 70+ | 21845 | 1 | 2389 | 0 | +| 71 | 21845 | 1 | 2389 | 0 | +| 71+ | -21846 | 1 | 2901 | 0 | +| 72 | -21846 | 1 | 2901 | 0 | +| 72+ | -21846 | 0 | 341 | 0 | +| 73 | -21846 | 0 | 341 | 0 | +| 73 | -21846 | 0 | 853 | 0 | +| 73 | -21846 | 0 | 1365 | 0 | +| 73 | -21846 | 0 | 1877 | 0 | +| 73 | -21846 | 0 | 2389 | 0 | +| 73 | -21846 | 0 | 2901 | 0 | +| 73 | -21846 | 0 | 3413 | 0 | +| 73 | -21846 | 0 | 3925 | 0 | +| 73+ | 21845 | 1 | 2901 | 0 | +| 74 | 21845 | 1 | 2901 | 0 | +| 74+ | -21846 | 1 | 3413 | 0 | +| 75 | -21846 | 1 | 3413 | 0 | +| 75+ | -21846 | 0 | 341 | 0 | +| 76 | -21846 | 0 | 341 | 0 | +| 76 | -21846 | 0 | 853 | 0 | +| 76 | -21846 | 0 | 1365 | 0 | +| 76 | -21846 | 0 | 1877 | 0 | +| 76 | -21846 | 0 | 2389 | 0 | +| 76 | -21846 | 0 | 2901 | 0 | +| 76 | -21846 | 0 | 3413 | 0 | +| 76 | -21846 | 0 | 3925 | 0 | +| 76+ | 21845 | 1 | 3413 | 0 | +| 77 | 21845 | 1 | 3413 | 0 | +| 77+ | -21846 | 1 | 3925 | 0 | +| 78 | -21846 | 1 | 3925 | 0 | +| 78+ | -21846 | 0 | 341 | 0 | +| 79 | -21846 | 0 | 341 | 0 | +| 79 | -21846 | 0 | 853 | 0 | +| 79 | -21846 | 0 | 1365 | 0 | +| 79 | -21846 | 0 | 1877 | 0 | +| 79 | -21846 | 0 | 2389 | 0 | +| 79 | -21846 | 0 | 2901 | 0 | +| 79 | -21846 | 0 | 3413 | 0 | +| 79 | -21846 | 0 | 3925 | 0 | +| 79+ | 21845 | 1 | 3925 | 0 | +| 80 | 21845 | 1 | 3925 | 0 | +| 80+ | 21845 | 0 | 341 | 0 | +| 81 | 21845 | 0 | 341 | 0 | +| 81 | 21845 | 0 | 853 | 0 | +| 81 | 21845 | 0 | 1365 | 0 | +| 81 | 21845 | 0 | 1877 | 0 | +| 81 | 21845 | 0 | 2389 | 0 | +| 81 | 21845 | 0 | 2901 | 0 | +| 81 | 21845 | 0 | 3413 | 0 | +| 81 | 21845 | 0 | 3925 | 0 | diff --git a/03/b/RAM512.hdl b/03/b/RAM512.hdl index 2db7ada6..db858fd5 100644 --- a/03/b/RAM512.hdl +++ b/03/b/RAM512.hdl @@ -16,4 +16,16 @@ CHIP RAM512 { PARTS: // Put your code here: + DMux8Way(in=load,sel=address[6..8],a=a,b=b,c=c,d=d,e=e,f=f,g=g,h=h); + + RAM64(in=in,load=a,address=address[0..5],out=oa); + RAM64(in=in,load=b,address=address[0..5],out=ob); + RAM64(in=in,load=c,address=address[0..5],out=oc); + RAM64(in=in,load=d,address=address[0..5],out=od); + RAM64(in=in,load=e,address=address[0..5],out=oe); + RAM64(in=in,load=f,address=address[0..5],out=of); + RAM64(in=in,load=g,address=address[0..5],out=og); + RAM64(in=in,load=h,address=address[0..5],out=oh); + + Mux8Way16(a=oa,b=ob,c=oc,d=od,e=oe,f=of,g=og,h=oh,sel=address[6..8],out=out); } \ No newline at end of file diff --git a/03/b/RAM512.out b/03/b/RAM512.out new file mode 100644 index 00000000..3e1a921e --- /dev/null +++ b/03/b/RAM512.out @@ -0,0 +1,320 @@ +| time | in |load |address| out | +| 0+ | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 1+ | 0 | 1 | 0 | 0 | +| 2 | 0 | 1 | 0 | 0 | +| 2+ | 13099 | 0 | 0 | 0 | +| 3 | 13099 | 0 | 0 | 0 | +| 3+ | 13099 | 1 | 130 | 0 | +| 4 | 13099 | 1 | 130 | 0 | +| 4+ | 13099 | 0 | 0 | 0 | +| 5 | 13099 | 0 | 0 | 0 | +| 5+ | 4729 | 0 | 472 | 0 | +| 6 | 4729 | 0 | 472 | 0 | +| 6+ | 4729 | 1 | 472 | 0 | +| 7 | 4729 | 1 | 472 | 0 | +| 7+ | 4729 | 0 | 472 | 0 | +| 8 | 4729 | 0 | 472 | 0 | +| 8 | 4729 | 0 | 130 | 0 | +| 8+ | 5119 | 0 | 130 | 0 | +| 9 | 5119 | 0 | 130 | 0 | +| 9+ | 5119 | 1 | 511 | 0 | +| 10 | 5119 | 1 | 511 | 0 | +| 10+ | 5119 | 0 | 511 | 0 | +| 11 | 5119 | 0 | 511 | 0 | +| 11 | 5119 | 0 | 472 | 0 | +| 11 | 5119 | 0 | 511 | 0 | +| 11+ | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 168 | 0 | +| 12 | 5119 | 0 | 169 | 0 | +| 12 | 5119 | 0 | 170 | 0 | +| 12 | 5119 | 0 | 171 | 0 | +| 12 | 5119 | 0 | 172 | 0 | +| 12 | 5119 | 0 | 173 | 0 | +| 12 | 5119 | 0 | 174 | 0 | +| 12 | 5119 | 0 | 175 | 0 | +| 12+ | 21845 | 1 | 168 | 0 | +| 13 | 21845 | 1 | 168 | 0 | +| 13+ | 21845 | 1 | 169 | 0 | +| 14 | 21845 | 1 | 169 | 0 | +| 14+ | 21845 | 1 | 170 | 0 | +| 15 | 21845 | 1 | 170 | 0 | +| 15+ | 21845 | 1 | 171 | 0 | +| 16 | 21845 | 1 | 171 | 0 | +| 16+ | 21845 | 1 | 172 | 0 | +| 17 | 21845 | 1 | 172 | 0 | +| 17+ | 21845 | 1 | 173 | 0 | +| 18 | 21845 | 1 | 173 | 0 | +| 18+ | 21845 | 1 | 174 | 0 | +| 19 | 21845 | 1 | 174 | 0 | +| 19+ | 21845 | 1 | 175 | 0 | +| 20 | 21845 | 1 | 175 | 0 | +| 20+ | 21845 | 0 | 168 | 0 | +| 21 | 21845 | 0 | 168 | 0 | +| 21 | 21845 | 0 | 169 | 0 | +| 21 | 21845 | 0 | 170 | 0 | +| 21 | 21845 | 0 | 171 | 0 | +| 21 | 21845 | 0 | 172 | 0 | +| 21 | 21845 | 0 | 173 | 0 | +| 21 | 21845 | 0 | 174 | 0 | +| 21 | 21845 | 0 | 175 | 0 | +| 21+ | -21846 | 1 | 168 | 0 | +| 22 | -21846 | 1 | 168 | 0 | +| 22+ | -21846 | 0 | 168 | 0 | +| 23 | -21846 | 0 | 168 | 0 | +| 23 | -21846 | 0 | 169 | 0 | +| 23 | -21846 | 0 | 170 | 0 | +| 23 | -21846 | 0 | 171 | 0 | +| 23 | -21846 | 0 | 172 | 0 | +| 23 | -21846 | 0 | 173 | 0 | +| 23 | -21846 | 0 | 174 | 0 | +| 23 | -21846 | 0 | 175 | 0 | +| 23+ | 21845 | 1 | 168 | 0 | +| 24 | 21845 | 1 | 168 | 0 | +| 24+ | -21846 | 1 | 169 | 0 | +| 25 | -21846 | 1 | 169 | 0 | +| 25+ | -21846 | 0 | 168 | 0 | +| 26 | -21846 | 0 | 168 | 0 | +| 26 | -21846 | 0 | 169 | 0 | +| 26 | -21846 | 0 | 170 | 0 | +| 26 | -21846 | 0 | 171 | 0 | +| 26 | -21846 | 0 | 172 | 0 | +| 26 | -21846 | 0 | 173 | 0 | +| 26 | -21846 | 0 | 174 | 0 | +| 26 | -21846 | 0 | 175 | 0 | +| 26+ | 21845 | 1 | 169 | 0 | +| 27 | 21845 | 1 | 169 | 0 | +| 27+ | -21846 | 1 | 170 | 0 | +| 28 | -21846 | 1 | 170 | 0 | +| 28+ | -21846 | 0 | 168 | 0 | +| 29 | -21846 | 0 | 168 | 0 | +| 29 | -21846 | 0 | 169 | 0 | +| 29 | -21846 | 0 | 170 | 0 | +| 29 | -21846 | 0 | 171 | 0 | +| 29 | -21846 | 0 | 172 | 0 | +| 29 | -21846 | 0 | 173 | 0 | +| 29 | -21846 | 0 | 174 | 0 | +| 29 | -21846 | 0 | 175 | 0 | +| 29+ | 21845 | 1 | 170 | 0 | +| 30 | 21845 | 1 | 170 | 0 | +| 30+ | -21846 | 1 | 171 | 0 | +| 31 | -21846 | 1 | 171 | 0 | +| 31+ | -21846 | 0 | 168 | 0 | +| 32 | -21846 | 0 | 168 | 0 | +| 32 | -21846 | 0 | 169 | 0 | +| 32 | -21846 | 0 | 170 | 0 | +| 32 | -21846 | 0 | 171 | 0 | +| 32 | -21846 | 0 | 172 | 0 | +| 32 | -21846 | 0 | 173 | 0 | +| 32 | -21846 | 0 | 174 | 0 | +| 32 | -21846 | 0 | 175 | 0 | +| 32+ | 21845 | 1 | 171 | 0 | +| 33 | 21845 | 1 | 171 | 0 | +| 33+ | -21846 | 1 | 172 | 0 | +| 34 | -21846 | 1 | 172 | 0 | +| 34+ | -21846 | 0 | 168 | 0 | +| 35 | -21846 | 0 | 168 | 0 | +| 35 | -21846 | 0 | 169 | 0 | +| 35 | -21846 | 0 | 170 | 0 | +| 35 | -21846 | 0 | 171 | 0 | +| 35 | -21846 | 0 | 172 | 0 | +| 35 | -21846 | 0 | 173 | 0 | +| 35 | -21846 | 0 | 174 | 0 | +| 35 | -21846 | 0 | 175 | 0 | +| 35+ | 21845 | 1 | 172 | 0 | +| 36 | 21845 | 1 | 172 | 0 | +| 36+ | -21846 | 1 | 173 | 0 | +| 37 | -21846 | 1 | 173 | 0 | +| 37+ | -21846 | 0 | 168 | 0 | +| 38 | -21846 | 0 | 168 | 0 | +| 38 | -21846 | 0 | 169 | 0 | +| 38 | -21846 | 0 | 170 | 0 | +| 38 | -21846 | 0 | 171 | 0 | +| 38 | -21846 | 0 | 172 | 0 | +| 38 | -21846 | 0 | 173 | 0 | +| 38 | -21846 | 0 | 174 | 0 | +| 38 | -21846 | 0 | 175 | 0 | +| 38+ | 21845 | 1 | 173 | 0 | +| 39 | 21845 | 1 | 173 | 0 | +| 39+ | -21846 | 1 | 174 | 0 | +| 40 | -21846 | 1 | 174 | 0 | +| 40+ | -21846 | 0 | 168 | 0 | +| 41 | -21846 | 0 | 168 | 0 | +| 41 | -21846 | 0 | 169 | 0 | +| 41 | -21846 | 0 | 170 | 0 | +| 41 | -21846 | 0 | 171 | 0 | +| 41 | -21846 | 0 | 172 | 0 | +| 41 | -21846 | 0 | 173 | 0 | +| 41 | -21846 | 0 | 174 | 0 | +| 41 | -21846 | 0 | 175 | 0 | +| 41+ | 21845 | 1 | 174 | 0 | +| 42 | 21845 | 1 | 174 | 0 | +| 42+ | -21846 | 1 | 175 | 0 | +| 43 | -21846 | 1 | 175 | 0 | +| 43+ | -21846 | 0 | 168 | 0 | +| 44 | -21846 | 0 | 168 | 0 | +| 44 | -21846 | 0 | 169 | 0 | +| 44 | -21846 | 0 | 170 | 0 | +| 44 | -21846 | 0 | 171 | 0 | +| 44 | -21846 | 0 | 172 | 0 | +| 44 | -21846 | 0 | 173 | 0 | +| 44 | -21846 | 0 | 174 | 0 | +| 44 | -21846 | 0 | 175 | 0 | +| 44+ | 21845 | 1 | 175 | 0 | +| 45 | 21845 | 1 | 175 | 0 | +| 45+ | 21845 | 0 | 168 | 0 | +| 46 | 21845 | 0 | 168 | 0 | +| 46 | 21845 | 0 | 169 | 0 | +| 46 | 21845 | 0 | 170 | 0 | +| 46 | 21845 | 0 | 171 | 0 | +| 46 | 21845 | 0 | 172 | 0 | +| 46 | 21845 | 0 | 173 | 0 | +| 46 | 21845 | 0 | 174 | 0 | +| 46 | 21845 | 0 | 175 | 0 | +| 46+ | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 42 | 0 | +| 47 | 21845 | 0 | 106 | 0 | +| 47 | 21845 | 0 | 170 | 0 | +| 47 | 21845 | 0 | 234 | 0 | +| 47 | 21845 | 0 | 298 | 0 | +| 47 | 21845 | 0 | 362 | 0 | +| 47 | 21845 | 0 | 426 | 0 | +| 47 | 21845 | 0 | 490 | 0 | +| 47+ | 21845 | 1 | 42 | 0 | +| 48 | 21845 | 1 | 42 | 0 | +| 48+ | 21845 | 1 | 106 | 0 | +| 49 | 21845 | 1 | 106 | 0 | +| 49+ | 21845 | 1 | 170 | 0 | +| 50 | 21845 | 1 | 170 | 0 | +| 50+ | 21845 | 1 | 234 | 0 | +| 51 | 21845 | 1 | 234 | 0 | +| 51+ | 21845 | 1 | 298 | 0 | +| 52 | 21845 | 1 | 298 | 0 | +| 52+ | 21845 | 1 | 362 | 0 | +| 53 | 21845 | 1 | 362 | 0 | +| 53+ | 21845 | 1 | 426 | 0 | +| 54 | 21845 | 1 | 426 | 0 | +| 54+ | 21845 | 1 | 490 | 0 | +| 55 | 21845 | 1 | 490 | 0 | +| 55+ | 21845 | 0 | 42 | 0 | +| 56 | 21845 | 0 | 42 | 0 | +| 56 | 21845 | 0 | 106 | 0 | +| 56 | 21845 | 0 | 170 | 0 | +| 56 | 21845 | 0 | 234 | 0 | +| 56 | 21845 | 0 | 298 | 0 | +| 56 | 21845 | 0 | 362 | 0 | +| 56 | 21845 | 0 | 426 | 0 | +| 56 | 21845 | 0 | 490 | 0 | +| 56+ | -21846 | 1 | 42 | 0 | +| 57 | -21846 | 1 | 42 | 0 | +| 57+ | -21846 | 0 | 42 | 0 | +| 58 | -21846 | 0 | 42 | 0 | +| 58 | -21846 | 0 | 106 | 0 | +| 58 | -21846 | 0 | 170 | 0 | +| 58 | -21846 | 0 | 234 | 0 | +| 58 | -21846 | 0 | 298 | 0 | +| 58 | -21846 | 0 | 362 | 0 | +| 58 | -21846 | 0 | 426 | 0 | +| 58 | -21846 | 0 | 490 | 0 | +| 58+ | 21845 | 1 | 42 | 0 | +| 59 | 21845 | 1 | 42 | 0 | +| 59+ | -21846 | 1 | 106 | 0 | +| 60 | -21846 | 1 | 106 | 0 | +| 60+ | -21846 | 0 | 42 | 0 | +| 61 | -21846 | 0 | 42 | 0 | +| 61 | -21846 | 0 | 106 | 0 | +| 61 | -21846 | 0 | 170 | 0 | +| 61 | -21846 | 0 | 234 | 0 | +| 61 | -21846 | 0 | 298 | 0 | +| 61 | -21846 | 0 | 362 | 0 | +| 61 | -21846 | 0 | 426 | 0 | +| 61 | -21846 | 0 | 490 | 0 | +| 61+ | 21845 | 1 | 106 | 0 | +| 62 | 21845 | 1 | 106 | 0 | +| 62+ | -21846 | 1 | 170 | 0 | +| 63 | -21846 | 1 | 170 | 0 | +| 63+ | -21846 | 0 | 42 | 0 | +| 64 | -21846 | 0 | 42 | 0 | +| 64 | -21846 | 0 | 106 | 0 | +| 64 | -21846 | 0 | 170 | 0 | +| 64 | -21846 | 0 | 234 | 0 | +| 64 | -21846 | 0 | 298 | 0 | +| 64 | -21846 | 0 | 362 | 0 | +| 64 | -21846 | 0 | 426 | 0 | +| 64 | -21846 | 0 | 490 | 0 | +| 64+ | 21845 | 1 | 170 | 0 | +| 65 | 21845 | 1 | 170 | 0 | +| 65+ | -21846 | 1 | 234 | 0 | +| 66 | -21846 | 1 | 234 | 0 | +| 66+ | -21846 | 0 | 42 | 0 | +| 67 | -21846 | 0 | 42 | 0 | +| 67 | -21846 | 0 | 106 | 0 | +| 67 | -21846 | 0 | 170 | 0 | +| 67 | -21846 | 0 | 234 | 0 | +| 67 | -21846 | 0 | 298 | 0 | +| 67 | -21846 | 0 | 362 | 0 | +| 67 | -21846 | 0 | 426 | 0 | +| 67 | -21846 | 0 | 490 | 0 | +| 67+ | 21845 | 1 | 234 | 0 | +| 68 | 21845 | 1 | 234 | 0 | +| 68+ | -21846 | 1 | 298 | 0 | +| 69 | -21846 | 1 | 298 | 0 | +| 69+ | -21846 | 0 | 42 | 0 | +| 70 | -21846 | 0 | 42 | 0 | +| 70 | -21846 | 0 | 106 | 0 | +| 70 | -21846 | 0 | 170 | 0 | +| 70 | -21846 | 0 | 234 | 0 | +| 70 | -21846 | 0 | 298 | 0 | +| 70 | -21846 | 0 | 362 | 0 | +| 70 | -21846 | 0 | 426 | 0 | +| 70 | -21846 | 0 | 490 | 0 | +| 70+ | 21845 | 1 | 298 | 0 | +| 71 | 21845 | 1 | 298 | 0 | +| 71+ | -21846 | 1 | 362 | 0 | +| 72 | -21846 | 1 | 362 | 0 | +| 72+ | -21846 | 0 | 42 | 0 | +| 73 | -21846 | 0 | 42 | 0 | +| 73 | -21846 | 0 | 106 | 0 | +| 73 | -21846 | 0 | 170 | 0 | +| 73 | -21846 | 0 | 234 | 0 | +| 73 | -21846 | 0 | 298 | 0 | +| 73 | -21846 | 0 | 362 | 0 | +| 73 | -21846 | 0 | 426 | 0 | +| 73 | -21846 | 0 | 490 | 0 | +| 73+ | 21845 | 1 | 362 | 0 | +| 74 | 21845 | 1 | 362 | 0 | +| 74+ | -21846 | 1 | 426 | 0 | +| 75 | -21846 | 1 | 426 | 0 | +| 75+ | -21846 | 0 | 42 | 0 | +| 76 | -21846 | 0 | 42 | 0 | +| 76 | -21846 | 0 | 106 | 0 | +| 76 | -21846 | 0 | 170 | 0 | +| 76 | -21846 | 0 | 234 | 0 | +| 76 | -21846 | 0 | 298 | 0 | +| 76 | -21846 | 0 | 362 | 0 | +| 76 | -21846 | 0 | 426 | 0 | +| 76 | -21846 | 0 | 490 | 0 | +| 76+ | 21845 | 1 | 426 | 0 | +| 77 | 21845 | 1 | 426 | 0 | +| 77+ | -21846 | 1 | 490 | 0 | +| 78 | -21846 | 1 | 490 | 0 | +| 78+ | -21846 | 0 | 42 | 0 | +| 79 | -21846 | 0 | 42 | 0 | +| 79 | -21846 | 0 | 106 | 0 | +| 79 | -21846 | 0 | 170 | 0 | +| 79 | -21846 | 0 | 234 | 0 | +| 79 | -21846 | 0 | 298 | 0 | +| 79 | -21846 | 0 | 362 | 0 | +| 79 | -21846 | 0 | 426 | 0 | +| 79 | -21846 | 0 | 490 | 0 | +| 79+ | 21845 | 1 | 490 | 0 | +| 80 | 21845 | 1 | 490 | 0 | +| 80+ | 21845 | 0 | 42 | 0 | +| 81 | 21845 | 0 | 42 | 0 | +| 81 | 21845 | 0 | 106 | 0 | +| 81 | 21845 | 0 | 170 | 0 | +| 81 | 21845 | 0 | 234 | 0 | +| 81 | 21845 | 0 | 298 | 0 | +| 81 | 21845 | 0 | 362 | 0 | +| 81 | 21845 | 0 | 426 | 0 | +| 81 | 21845 | 0 | 490 | 0 | diff --git a/04/fill/Fill.asm b/04/fill/Fill.asm index eb0fefe2..990f9307 100644 --- a/04/fill/Fill.asm +++ b/04/fill/Fill.asm @@ -11,4 +11,50 @@ // "white" in every pixel; // the screen should remain fully clear as long as no key is pressed. -// Put your code here. \ No newline at end of file + @status + M=-1 + D=0 + @SETSCREEN + 0;JMP + +(LOOP) + @KBD + D=M + @SETSCREEN + D;JEQ + D=-1 + +(SETSCREEN) + @ARG + M=D + @status + D=D-M + @LOOP + D;JEQ + + @ARG + D=M + @status + M=D + + @SCREEN + D=A + @8192 + D=D+A + @i + M=D + +(SETLOOP) + @i + D=M-1 + M=D + @LOOP + D;JLT + + @status + D=M + @i + A=M + M=D + @SETLOOP + 0;JMP \ No newline at end of file diff --git a/04/fill/Fill.hack b/04/fill/Fill.hack new file mode 100644 index 00000000..08f4ed8b --- /dev/null +++ b/04/fill/Fill.hack @@ -0,0 +1,38 @@ +0000000000010000 +1110111010001000 +1110101010010000 +0000000000001010 +1110101010000111 +0110000000000000 +1111110000010000 +0000000000001010 +1110001100000010 +1110111010010000 +0000000000000010 +1110001100001000 +0000000000010000 +1111010011010000 +0000000000000101 +1110001100000010 +0000000000000010 +1111110000010000 +0000000000010000 +1110001100001000 +0100000000000000 +1110110000010000 +0010000000000000 +1110000010010000 +0000000000010001 +1110001100001000 +0000000000010001 +1111110010010000 +1110001100001000 +0000000000000101 +1110001100000100 +0000000000010000 +1111110000010000 +0000000000010001 +1111110000100000 +1110001100001000 +0000000000011010 +1110101010000111 \ No newline at end of file diff --git a/04/fill/FillAutomatic.out b/04/fill/FillAutomatic.out new file mode 100644 index 00000000..a71db276 --- /dev/null +++ b/04/fill/FillAutomatic.out @@ -0,0 +1,4 @@ +|RAM[16384]|RAM[17648]|RAM[18349]|RAM[19444]|RAM[20771]|RAM[21031]|RAM[22596]|RAM[23754]|RAM[24575]| +| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | -1 | +| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | diff --git a/04/mult/Mult.hack b/04/mult/Mult.hack new file mode 100644 index 00000000..a406296f --- /dev/null +++ b/04/mult/Mult.hack @@ -0,0 +1,20 @@ +0000000000000010 +1110101010001000 +0000000000010000 +1110101010001000 +0000000000010000 +1111110000010000 +0000000000000000 +1111010011010000 +0000000000010010 +1110001100000011 +0000000000000001 +1111110000010000 +0000000000000010 +1111000010001000 +0000000000010000 +1111110111001000 +0000000000000100 +1110101010000111 +0000000000010010 +1110101010000111 \ No newline at end of file diff --git a/04/mult/Mult.out b/04/mult/Mult.out new file mode 100644 index 00000000..e31b5dfa --- /dev/null +++ b/04/mult/Mult.out @@ -0,0 +1,7 @@ +| RAM[0] | RAM[1] | RAM[2] | +| 0 | 0 | 0 | +| 1 | 0 | 0 | +| 0 | 2 | 0 | +| 3 | 1 | 3 | +| 2 | 4 | 8 | +| 6 | 7 | 42 | diff --git a/04/mult/mult.asm b/04/mult/mult.asm index 8781f7a7..62c01dbe 100644 --- a/04/mult/mult.asm +++ b/04/mult/mult.asm @@ -6,4 +6,26 @@ // Multiplies R0 and R1 and stores the result in R2. // (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.) -// Put your code here. \ No newline at end of file + @2 + M=0 + @i + M=0 +(LOOP) + @i + D=M + @0 + D=D-M + @END + D;JGE + + @1 + D=M + @2 + M=D+M + @i + M=M+1 + @LOOP + 0;JMP +(END) + @END + 0;JMP \ No newline at end of file diff --git a/05/CPU-external.out b/05/CPU-external.out new file mode 100644 index 00000000..6ac73309 --- /dev/null +++ b/05/CPU-external.out @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc | +|0+ | 0|0011000000111001| 0 | 0| 0 | 0| 0| +|1 | 0|0011000000111001| 0 | 0| 0 |12345| 1| +|1+ | 0|1110110000010000| 0 | 12345| 0 |12345| 1| +|2 | 0|1110110000010000| 0 | 12345| 0 |12345| 2| +|2+ | 0|0101101110100000| 0 | -1| 0 |12345| 2| +|3 | 0|0101101110100000| 0 | -1| 0 |23456| 3| +|3+ | 0|1110000111010000| 0 | 11111| 0 |23456| 3| +|4 | 0|1110000111010000| 0 | 12345| 0 |23456| 4| +|4+ | 0|0000001111101000| 0 | -11111| 0 |23456| 4| +|5 | 0|0000001111101000| 0 | -11111| 0 | 1000| 5| +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| +|6+ | 0|0000001111101001| 0 | -11111| 0 | 1000| 6| +|7 | 0|0000001111101001| 0 | -11111| 0 | 1001| 7| +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| +|8+ | 0|0000001111101000| 0 | -11110| 0 | 1001| 8| +|9 | 0|0000001111101000| 0 | -11110| 0 | 1000| 9| +|9+ | 11111|1111010011010000| 0 | -1| 0 | 1000| 9| +|10 | 11111|1111010011010000| 0 | -11112| 0 | 1000| 10| +|10+ | 11111|0000000000001110| 0 | 1000| 0 | 1000| 10| +|11 | 11111|0000000000001110| 0 | 14| 0 | 14| 11| +|11+ | 11111|1110001100000100| 0 | -1| 0 | 14| 11| +|12 | 11111|1110001100000100| 0 | -1| 0 | 14| 14| +|12+ | 11111|0000001111100111| 0 | 1| 0 | 14| 14| +|13 | 11111|0000001111100111| 0 | 1| 0 | 999| 15| +|13+ | 11111|1110110111100000| 0 | 1000| 0 | 999| 15| +|14 | 11111|1110110111100000| 0 | 1001| 0 | 1000| 16| +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| +|15+ | 11111|0000000000010101| 0 | 1000| 0 | 1000| 17| +|16 | 11111|0000000000010101| 0 | 21| 0 | 21| 18| +|16+ | 11111|1110011111000010| 0 | 0| 0 | 21| 18| +|17 | 11111|1110011111000010| 0 | 0| 0 | 21| 21| +|17+ | 11111|0000000000000010| 0 | 21| 0 | 21| 21| +|18 | 11111|0000000000000010| 0 | 2| 0 | 2| 22| +|18+ | 11111|1110000010010000| 0 | 1| 0 | 2| 22| +|19 | 11111|1110000010010000| 0 | 3| 0 | 2| 23| +|19+ | 11111|0000001111101000| 0 | -1| 0 | 2| 23| +|20 | 11111|0000001111101000| 0 | -1| 0 | 1000| 24| +|20+ | 11111|1110111010010000| 0 | -1| 0 | 1000| 24| +|21 | 11111|1110111010010000| 0 | -1| 0 | 1000| 25| +|21+ | 11111|1110001100000001| 0 | -1| 0 | 1000| 25| +|22 | 11111|1110001100000001| 0 | -1| 0 | 1000| 26| +|22+ | 11111|1110001100000010| 0 | -1| 0 | 1000| 26| +|23 | 11111|1110001100000010| 0 | -1| 0 | 1000| 27| +|23+ | 11111|1110001100000011| 0 | -1| 0 | 1000| 27| +|24 | 11111|1110001100000011| 0 | -1| 0 | 1000| 28| +|24+ | 11111|1110001100000100| 0 | -1| 0 | 1000| 28| +|25 | 11111|1110001100000100| 0 | -1| 0 | 1000| 1000| +|25+ | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| +|26 | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| +|26+ | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| +|27 | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| +|27+ | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| +|28 | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| +|28+ | 11111|1110101010010000| 0 | 0| 0 | 1000| 1000| +|29 | 11111|1110101010010000| 0 | 0| 0 | 1000| 1001| +|29+ | 11111|1110001100000001| 0 | 0| 0 | 1000| 1001| +|30 | 11111|1110001100000001| 0 | 0| 0 | 1000| 1002| +|30+ | 11111|1110001100000010| 0 | 0| 0 | 1000| 1002| +|31 | 11111|1110001100000010| 0 | 0| 0 | 1000| 1000| +|31+ | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| +|32 | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| +|32+ | 11111|1110001100000100| 0 | 0| 0 | 1000| 1000| +|33 | 11111|1110001100000100| 0 | 0| 0 | 1000| 1001| +|33+ | 11111|1110001100000101| 0 | 0| 0 | 1000| 1001| +|34 | 11111|1110001100000101| 0 | 0| 0 | 1000| 1002| +|34+ | 11111|1110001100000110| 0 | 0| 0 | 1000| 1002| +|35 | 11111|1110001100000110| 0 | 0| 0 | 1000| 1000| +|35+ | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| +|36 | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| +|36+ | 11111|1110111111010000| 0 | 1| 0 | 1000| 1000| +|37 | 11111|1110111111010000| 0 | 1| 0 | 1000| 1001| +|37+ | 11111|1110001100000001| 0 | 1| 0 | 1000| 1001| +|38 | 11111|1110001100000001| 0 | 1| 0 | 1000| 1000| +|38+ | 11111|1110001100000010| 0 | 1| 0 | 1000| 1000| +|39 | 11111|1110001100000010| 0 | 1| 0 | 1000| 1001| +|39+ | 11111|1110001100000011| 0 | 1| 0 | 1000| 1001| +|40 | 11111|1110001100000011| 0 | 1| 0 | 1000| 1000| +|40+ | 11111|1110001100000100| 0 | 1| 0 | 1000| 1000| +|41 | 11111|1110001100000100| 0 | 1| 0 | 1000| 1001| +|41+ | 11111|1110001100000101| 0 | 1| 0 | 1000| 1001| +|42 | 11111|1110001100000101| 0 | 1| 0 | 1000| 1000| +|42+ | 11111|1110001100000110| 0 | 1| 0 | 1000| 1000| +|43 | 11111|1110001100000110| 0 | 1| 0 | 1000| 1001| +|43+ | 11111|1110001100000111| 0 | 1| 0 | 1000| 1001| +|44 | 11111|1110001100000111| 0 | 1| 0 | 1000| 1000| +|44+ | 11111|1110001100000111| 1 | 1| 0 | 1000| 1000| +|45 | 11111|1110001100000111| 1 | 1| 0 | 1000| 0| +|45+ | 11111|0111111111111111| 0 | 1| 0 | 1000| 0| +|46 | 11111|0111111111111111| 0 | 1| 0 |32767| 1| diff --git a/05/CPU.hdl b/05/CPU.hdl index 86558934..f878cae9 100644 --- a/05/CPU.hdl +++ b/05/CPU.hdl @@ -27,17 +27,51 @@ CHIP CPU { - IN inM[16], // M value input (M = contents of RAM[A]) - instruction[16], // Instruction for execution - reset; // Signals whether to re-start the current - // program (reset==1) or continue executing - // the current program (reset==0). + IN inM[16], + instruction[16], + reset; + + - OUT outM[16], // M value output - writeM, // Write to M? - addressM[15], // Address in data memory (of M) - pc[15]; // address of next instruction + OUT outM[16], + writeM, + addressM[15], + pc[15]; PARTS: - // Put your code here: + //網路上找查、朋友指教 + Not(in=instruction[15], out=Ainstruction); + Not(in=Ainstruction, out=Cinstruction); + + And(a=Cinstruction, b=instruction[5], out=ALUtoA); + Mux16(a=instruction, b=ALUout, sel=ALUtoA, out=Aregin); + + Or(a=Ainstruction, b=ALUtoA, out=loadA); + ARegister(in=Aregin, load=loadA, out=Aout); + + Mux16(a=Aout, b=inM, sel=instruction[12], out=AMout); + + And(a=Cinstruction, b=instruction[4], out=loadD); + DRegister(in=ALUout, load=loadD, out=Dout); + + ALU(x=Dout, y=AMout, zx=instruction[11], nx=instruction[10], + zy=instruction[9], ny=instruction[8], f=instruction[7], + no=instruction[6], out=ALUout, zr=ZRout, ng=NGout); + + // Set outputs for writing memory + Or16(a=false, b=Aout, out[0..14]=addressM); + Or16(a=false, b=ALUout, out=outM); + And(a=Cinstruction, b=instruction[3], out=writeM); + + // calc PCload & PCinc - whether to load PC with A reg + And(a=ZRout, b=instruction[1], out=jeq); + And(a=NGout, b=instruction[2], out=jlt); + Or(a=ZRout, b=NGout, out=zeroOrNeg); + Not(in=zeroOrNeg, out=positive); + And(a=positive, b=instruction[0], out=jgt); + Or(a=jeq, b=jlt, out=jle); + Or(a=jle, b=jgt, out=jumpToA); + And(a=Cinstruction, b=jumpToA, out=PCload); + Not(in=PCload, out=PCinc); + PC(in=Aout, inc=PCinc, load=PCload, reset=reset, out[0..14]=pc); } \ No newline at end of file diff --git a/05/CPU.out b/05/CPU.out new file mode 100644 index 00000000..95f17b52 --- /dev/null +++ b/05/CPU.out @@ -0,0 +1,93 @@ +|time| inM | instruction |reset| outM |writeM |addre| pc |DRegiste| +|0+ | 0|0011000000111001| 0 | 0| 0 | 0| 0| 0 | +|1 | 0|0011000000111001| 0 | 0| 0 |12345| 1| 0 | +|1+ | 0|1110110000010000| 0 | 12345| 0 |12345| 1| 12345 | +|2 | 0|1110110000010000| 0 | 12345| 0 |12345| 2| 12345 | +|2+ | 0|0101101110100000| 0 | -1| 0 |12345| 2| 12345 | +|3 | 0|0101101110100000| 0 | -1| 0 |23456| 3| 12345 | +|3+ | 0|1110000111010000| 0 | 11111| 0 |23456| 3| 11111 | +|4 | 0|1110000111010000| 0 | 12345| 0 |23456| 4| 11111 | +|4+ | 0|0000001111101000| 0 | -11111| 0 |23456| 4| 11111 | +|5 | 0|0000001111101000| 0 | -11111| 0 | 1000| 5| 11111 | +|5+ | 0|1110001100001000| 0 | 11111| 1 | 1000| 5| 11111 | +|6 | 0|1110001100001000| 0 | 11111| 1 | 1000| 6| 11111 | +|6+ | 0|0000001111101001| 0 | -11111| 0 | 1000| 6| 11111 | +|7 | 0|0000001111101001| 0 | -11111| 0 | 1001| 7| 11111 | +|7+ | 0|1110001110011000| 0 | 11110| 1 | 1001| 7| 11110 | +|8 | 0|1110001110011000| 0 | 11109| 1 | 1001| 8| 11110 | +|8+ | 0|0000001111101000| 0 | -11110| 0 | 1001| 8| 11110 | +|9 | 0|0000001111101000| 0 | -11110| 0 | 1000| 9| 11110 | +|9+ | 11111|1111010011010000| 0 | -1| 0 | 1000| 9| -1 | +|10 | 11111|1111010011010000| 0 | -11112| 0 | 1000| 10| -1 | +|10+ | 11111|0000000000001110| 0 | 1000| 0 | 1000| 10| -1 | +|11 | 11111|0000000000001110| 0 | 14| 0 | 14| 11| -1 | +|11+ | 11111|1110001100000100| 0 | -1| 0 | 14| 11| -1 | +|12 | 11111|1110001100000100| 0 | -1| 0 | 14| 14| -1 | +|12+ | 11111|0000001111100111| 0 | 1| 0 | 14| 14| -1 | +|13 | 11111|0000001111100111| 0 | 1| 0 | 999| 15| -1 | +|13+ | 11111|1110110111100000| 0 | 1000| 0 | 999| 15| -1 | +|14 | 11111|1110110111100000| 0 | 1001| 0 | 1000| 16| -1 | +|14+ | 11111|1110001100001000| 0 | -1| 1 | 1000| 16| -1 | +|15 | 11111|1110001100001000| 0 | -1| 1 | 1000| 17| -1 | +|15+ | 11111|0000000000010101| 0 | 1000| 0 | 1000| 17| -1 | +|16 | 11111|0000000000010101| 0 | 21| 0 | 21| 18| -1 | +|16+ | 11111|1110011111000010| 0 | 0| 0 | 21| 18| -1 | +|17 | 11111|1110011111000010| 0 | 0| 0 | 21| 21| -1 | +|17+ | 11111|0000000000000010| 0 | 21| 0 | 21| 21| -1 | +|18 | 11111|0000000000000010| 0 | 2| 0 | 2| 22| -1 | +|18+ | 11111|1110000010010000| 0 | 1| 0 | 2| 22| 1 | +|19 | 11111|1110000010010000| 0 | 3| 0 | 2| 23| 1 | +|19+ | 11111|0000001111101000| 0 | -1| 0 | 2| 23| 1 | +|20 | 11111|0000001111101000| 0 | -1| 0 | 1000| 24| 1 | +|20+ | 11111|1110111010010000| 0 | -1| 0 | 1000| 24| -1 | +|21 | 11111|1110111010010000| 0 | -1| 0 | 1000| 25| -1 | +|21+ | 11111|1110001100000001| 0 | -1| 0 | 1000| 25| -1 | +|22 | 11111|1110001100000001| 0 | -1| 0 | 1000| 26| -1 | +|22+ | 11111|1110001100000010| 0 | -1| 0 | 1000| 26| -1 | +|23 | 11111|1110001100000010| 0 | -1| 0 | 1000| 27| -1 | +|23+ | 11111|1110001100000011| 0 | -1| 0 | 1000| 27| -1 | +|24 | 11111|1110001100000011| 0 | -1| 0 | 1000| 28| -1 | +|24+ | 11111|1110001100000100| 0 | -1| 0 | 1000| 28| -1 | +|25 | 11111|1110001100000100| 0 | -1| 0 | 1000| 1000| -1 | +|25+ | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| -1 | +|26 | 11111|1110001100000101| 0 | -1| 0 | 1000| 1000| -1 | +|26+ | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| -1 | +|27 | 11111|1110001100000110| 0 | -1| 0 | 1000| 1000| -1 | +|27+ | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| -1 | +|28 | 11111|1110001100000111| 0 | -1| 0 | 1000| 1000| -1 | +|28+ | 11111|1110101010010000| 0 | 0| 0 | 1000| 1000| 0 | +|29 | 11111|1110101010010000| 0 | 0| 0 | 1000| 1001| 0 | +|29+ | 11111|1110001100000001| 0 | 0| 0 | 1000| 1001| 0 | +|30 | 11111|1110001100000001| 0 | 0| 0 | 1000| 1002| 0 | +|30+ | 11111|1110001100000010| 0 | 0| 0 | 1000| 1002| 0 | +|31 | 11111|1110001100000010| 0 | 0| 0 | 1000| 1000| 0 | +|31+ | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| 0 | +|32 | 11111|1110001100000011| 0 | 0| 0 | 1000| 1000| 0 | +|32+ | 11111|1110001100000100| 0 | 0| 0 | 1000| 1000| 0 | +|33 | 11111|1110001100000100| 0 | 0| 0 | 1000| 1001| 0 | +|33+ | 11111|1110001100000101| 0 | 0| 0 | 1000| 1001| 0 | +|34 | 11111|1110001100000101| 0 | 0| 0 | 1000| 1002| 0 | +|34+ | 11111|1110001100000110| 0 | 0| 0 | 1000| 1002| 0 | +|35 | 11111|1110001100000110| 0 | 0| 0 | 1000| 1000| 0 | +|35+ | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| 0 | +|36 | 11111|1110001100000111| 0 | 0| 0 | 1000| 1000| 0 | +|36+ | 11111|1110111111010000| 0 | 1| 0 | 1000| 1000| 1 | +|37 | 11111|1110111111010000| 0 | 1| 0 | 1000| 1001| 1 | +|37+ | 11111|1110001100000001| 0 | 1| 0 | 1000| 1001| 1 | +|38 | 11111|1110001100000001| 0 | 1| 0 | 1000| 1000| 1 | +|38+ | 11111|1110001100000010| 0 | 1| 0 | 1000| 1000| 1 | +|39 | 11111|1110001100000010| 0 | 1| 0 | 1000| 1001| 1 | +|39+ | 11111|1110001100000011| 0 | 1| 0 | 1000| 1001| 1 | +|40 | 11111|1110001100000011| 0 | 1| 0 | 1000| 1000| 1 | +|40+ | 11111|1110001100000100| 0 | 1| 0 | 1000| 1000| 1 | +|41 | 11111|1110001100000100| 0 | 1| 0 | 1000| 1001| 1 | +|41+ | 11111|1110001100000101| 0 | 1| 0 | 1000| 1001| 1 | +|42 | 11111|1110001100000101| 0 | 1| 0 | 1000| 1000| 1 | +|42+ | 11111|1110001100000110| 0 | 1| 0 | 1000| 1000| 1 | +|43 | 11111|1110001100000110| 0 | 1| 0 | 1000| 1001| 1 | +|43+ | 11111|1110001100000111| 0 | 1| 0 | 1000| 1001| 1 | +|44 | 11111|1110001100000111| 0 | 1| 0 | 1000| 1000| 1 | +|44+ | 11111|1110001100000111| 1 | 1| 0 | 1000| 1000| 1 | +|45 | 11111|1110001100000111| 1 | 1| 0 | 1000| 0| 1 | +|45+ | 11111|0111111111111111| 0 | 1| 0 | 1000| 0| 1 | +|46 | 11111|0111111111111111| 0 | 1| 0 |32767| 1| 1 | diff --git a/05/Computer.hdl b/05/Computer.hdl index d18dab2e..f250bf9a 100644 --- a/05/Computer.hdl +++ b/05/Computer.hdl @@ -19,5 +19,9 @@ CHIP Computer { IN reset; PARTS: - // Put your code here: + //網路上找查、朋友指教 + ROM32K(address=pc, out=instruction); + CPU(inM=memOut, instruction=instruction, reset=reset, outM=outM, + writeM=writeM, addressM=addressM, pc=pc); + Memory(in=outM, load=writeM, address=addressM, out=memOut); } diff --git a/05/ComputerAdd-external.out b/05/ComputerAdd-external.out new file mode 100644 index 00000000..2407ecac --- /dev/null +++ b/05/ComputerAdd-external.out @@ -0,0 +1,15 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0 | +| 1 | 0 | 0 | 0 | 0 | +| 2 | 0 | 0 | 0 | 0 | +| 3 | 0 | 0 | 0 | 0 | +| 4 | 0 | 0 | 0 | 0 | +| 5 | 0 | 0 | 0 | 0 | +| 6 | 0 | 5 | 0 | 0 | +| 7 | 1 | 0 | 0 | 0 | +| 8 | 0 | 0 | 0 | 0 | +| 9 | 0 | 0 | 0 | 0 | +| 10 | 0 | 0 | 0 | 0 | +| 11 | 0 | 0 | 0 | 0 | +| 12 | 0 | 0 | 0 | 0 | +| 13 | 0 | 5 | 0 | 0 | diff --git a/05/ComputerAdd.out b/05/ComputerAdd.out new file mode 100644 index 00000000..57487700 --- /dev/null +++ b/05/ComputerAdd.out @@ -0,0 +1,15 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 0 | 0 | 0 | +| 1 | 0 | 2 | 0 | 1| 0 | 0 | 0 | +| 2 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 3 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 4 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 5 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 6 | 0 | 0 | 5 | 6| 5 | 0 | 0 | +| 7 | 1 | 0 | 5 | 0| 0 | 0 | 0 | +| 8 | 0 | 2 | 5 | 1| 0 | 0 | 0 | +| 9 | 0 | 2 | 2 | 2| 0 | 0 | 0 | +| 10 | 0 | 3 | 2 | 3| 0 | 0 | 0 | +| 11 | 0 | 3 | 5 | 4| 0 | 0 | 0 | +| 12 | 0 | 0 | 5 | 5| 0 | 0 | 0 | +| 13 | 0 | 0 | 5 | 6| 5 | 0 | 0 | diff --git a/05/ComputerMax-external.out b/05/ComputerMax-external.out new file mode 100644 index 00000000..4a6dff53 --- /dev/null +++ b/05/ComputerMax-external.out @@ -0,0 +1,28 @@ +| time |reset|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 3 | 5 | 0 | +| 1 | 0 | 3 | 5 | 0 | +| 2 | 0 | 3 | 5 | 0 | +| 3 | 0 | 3 | 5 | 0 | +| 4 | 0 | 3 | 5 | 0 | +| 5 | 0 | 3 | 5 | 0 | +| 6 | 0 | 3 | 5 | 0 | +| 7 | 0 | 3 | 5 | 0 | +| 8 | 0 | 3 | 5 | 0 | +| 9 | 0 | 3 | 5 | 0 | +| 10 | 0 | 3 | 5 | 0 | +| 11 | 0 | 3 | 5 | 0 | +| 12 | 0 | 3 | 5 | 5 | +| 13 | 0 | 3 | 5 | 5 | +| 14 | 0 | 3 | 5 | 5 | +| 15 | 1 | 3 | 5 | 5 | +| 15 | 0 | 23456 | 12345 | 5 | +| 16 | 0 | 23456 | 12345 | 5 | +| 17 | 0 | 23456 | 12345 | 5 | +| 18 | 0 | 23456 | 12345 | 5 | +| 19 | 0 | 23456 | 12345 | 5 | +| 20 | 0 | 23456 | 12345 | 5 | +| 21 | 0 | 23456 | 12345 | 5 | +| 22 | 0 | 23456 | 12345 | 5 | +| 23 | 0 | 23456 | 12345 | 5 | +| 24 | 0 | 23456 | 12345 | 5 | +| 25 | 0 | 23456 | 12345 | 23456 | diff --git a/05/ComputerMax.out b/05/ComputerMax.out new file mode 100644 index 00000000..698d5a16 --- /dev/null +++ b/05/ComputerMax.out @@ -0,0 +1,28 @@ +| time |reset|ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0 | 0| 3 | 5 | 0 | +| 1 | 0 | 0 | 0 | 1| 3 | 5 | 0 | +| 2 | 0 | 0 | 3 | 2| 3 | 5 | 0 | +| 3 | 0 | 1 | 3 | 3| 3 | 5 | 0 | +| 4 | 0 | 1 | -2 | 4| 3 | 5 | 0 | +| 5 | 0 | 10 | -2 | 5| 3 | 5 | 0 | +| 6 | 0 | 10 | -2 | 6| 3 | 5 | 0 | +| 7 | 0 | 1 | -2 | 7| 3 | 5 | 0 | +| 8 | 0 | 1 | 5 | 8| 3 | 5 | 0 | +| 9 | 0 | 12 | 5 | 9| 3 | 5 | 0 | +| 10 | 0 | 12 | 5 | 12| 3 | 5 | 0 | +| 11 | 0 | 2 | 5 | 13| 3 | 5 | 0 | +| 12 | 0 | 2 | 5 | 14| 3 | 5 | 5 | +| 13 | 0 | 14 | 5 | 15| 3 | 5 | 5 | +| 14 | 0 | 14 | 5 | 14| 3 | 5 | 5 | +| 15 | 1 | 14 | 5 | 0| 3 | 5 | 5 | +| 15 | 0 | 14 | 5 | 0| 23456 | 12345 | 5 | +| 16 | 0 | 0 | 5 | 1| 23456 | 12345 | 5 | +| 17 | 0 | 0 | 23456 | 2| 23456 | 12345 | 5 | +| 18 | 0 | 1 | 23456 | 3| 23456 | 12345 | 5 | +| 19 | 0 | 1 | 11111 | 4| 23456 | 12345 | 5 | +| 20 | 0 | 10 | 11111 | 5| 23456 | 12345 | 5 | +| 21 | 0 | 10 | 11111 | 10| 23456 | 12345 | 5 | +| 22 | 0 | 0 | 11111 | 11| 23456 | 12345 | 5 | +| 23 | 0 | 0 | 23456 | 12| 23456 | 12345 | 5 | +| 24 | 0 | 2 | 23456 | 13| 23456 | 12345 | 5 | +| 25 | 0 | 2 | 23456 | 14| 23456 | 12345 | 23456 | diff --git a/05/ComputerRect-external.out b/05/ComputerRect-external.out new file mode 100644 index 00000000..afbddfee --- /dev/null +++ b/05/ComputerRect-external.out @@ -0,0 +1,65 @@ +| time | +| 0 | +| 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 | diff --git a/05/ComputerRect.out b/05/ComputerRect.out new file mode 100644 index 00000000..a6b39658 --- /dev/null +++ b/05/ComputerRect.out @@ -0,0 +1,65 @@ +| time |ARegister|DRegister|PC[]|RAM16K[0]|RAM16K[1]|RAM16K[2]| +| 0 | 0 | 0 | 0| 4 | 0 | 0 | +| 1 | 0 | 0 | 1| 4 | 0 | 0 | +| 2 | 0 | 4 | 2| 4 | 0 | 0 | +| 3 | 23 | 4 | 3| 4 | 0 | 0 | +| 4 | 23 | 4 | 4| 4 | 0 | 0 | +| 5 | 16 | 4 | 5| 4 | 0 | 0 | +| 6 | 16 | 4 | 6| 4 | 0 | 0 | +| 7 | 16384 | 4 | 7| 4 | 0 | 0 | +| 8 | 16384 | 16384 | 8| 4 | 0 | 0 | +| 9 | 17 | 16384 | 9| 4 | 0 | 0 | +| 10 | 17 | 16384 | 10| 4 | 0 | 0 | +| 11 | 17 | 16384 | 11| 4 | 0 | 0 | +| 12 | 16384 | 16384 | 12| 4 | 0 | 0 | +| 13 | 16384 | 16384 | 13| 4 | 0 | 0 | +| 14 | 17 | 16384 | 14| 4 | 0 | 0 | +| 15 | 17 | 16384 | 15| 4 | 0 | 0 | +| 16 | 32 | 16384 | 16| 4 | 0 | 0 | +| 17 | 32 | 16416 | 17| 4 | 0 | 0 | +| 18 | 17 | 16416 | 18| 4 | 0 | 0 | +| 19 | 17 | 16416 | 19| 4 | 0 | 0 | +| 20 | 16 | 16416 | 20| 4 | 0 | 0 | +| 21 | 16 | 3 | 21| 4 | 0 | 0 | +| 22 | 10 | 3 | 22| 4 | 0 | 0 | +| 23 | 10 | 3 | 10| 4 | 0 | 0 | +| 24 | 17 | 3 | 11| 4 | 0 | 0 | +| 25 | 16416 | 3 | 12| 4 | 0 | 0 | +| 26 | 16416 | 3 | 13| 4 | 0 | 0 | +| 27 | 17 | 3 | 14| 4 | 0 | 0 | +| 28 | 17 | 16416 | 15| 4 | 0 | 0 | +| 29 | 32 | 16416 | 16| 4 | 0 | 0 | +| 30 | 32 | 16448 | 17| 4 | 0 | 0 | +| 31 | 17 | 16448 | 18| 4 | 0 | 0 | +| 32 | 17 | 16448 | 19| 4 | 0 | 0 | +| 33 | 16 | 16448 | 20| 4 | 0 | 0 | +| 34 | 16 | 2 | 21| 4 | 0 | 0 | +| 35 | 10 | 2 | 22| 4 | 0 | 0 | +| 36 | 10 | 2 | 10| 4 | 0 | 0 | +| 37 | 17 | 2 | 11| 4 | 0 | 0 | +| 38 | 16448 | 2 | 12| 4 | 0 | 0 | +| 39 | 16448 | 2 | 13| 4 | 0 | 0 | +| 40 | 17 | 2 | 14| 4 | 0 | 0 | +| 41 | 17 | 16448 | 15| 4 | 0 | 0 | +| 42 | 32 | 16448 | 16| 4 | 0 | 0 | +| 43 | 32 | 16480 | 17| 4 | 0 | 0 | +| 44 | 17 | 16480 | 18| 4 | 0 | 0 | +| 45 | 17 | 16480 | 19| 4 | 0 | 0 | +| 46 | 16 | 16480 | 20| 4 | 0 | 0 | +| 47 | 16 | 1 | 21| 4 | 0 | 0 | +| 48 | 10 | 1 | 22| 4 | 0 | 0 | +| 49 | 10 | 1 | 10| 4 | 0 | 0 | +| 50 | 17 | 1 | 11| 4 | 0 | 0 | +| 51 | 16480 | 1 | 12| 4 | 0 | 0 | +| 52 | 16480 | 1 | 13| 4 | 0 | 0 | +| 53 | 17 | 1 | 14| 4 | 0 | 0 | +| 54 | 17 | 16480 | 15| 4 | 0 | 0 | +| 55 | 32 | 16480 | 16| 4 | 0 | 0 | +| 56 | 32 | 16512 | 17| 4 | 0 | 0 | +| 57 | 17 | 16512 | 18| 4 | 0 | 0 | +| 58 | 17 | 16512 | 19| 4 | 0 | 0 | +| 59 | 16 | 16512 | 20| 4 | 0 | 0 | +| 60 | 16 | 0 | 21| 4 | 0 | 0 | +| 61 | 10 | 0 | 22| 4 | 0 | 0 | +| 62 | 10 | 0 | 23| 4 | 0 | 0 | +| 63 | 23 | 0 | 24| 4 | 0 | 0 | diff --git a/05/Memory.hdl b/05/Memory.hdl index 1e46a756..8d4abfe1 100644 --- a/05/Memory.hdl +++ b/05/Memory.hdl @@ -27,5 +27,11 @@ CHIP Memory { OUT out[16]; PARTS: - // Put your code here: + //網路上找查、朋友指教 + DMux4Way(in=load, sel=address[13..14], a=loadram1, b=loadram2, c=loadscreen, d=loadkbd); + Or(a=loadram1, b=loadram2, out=loadram); + RAM16K(in=in, load=loadram, address=address[0..13], out=ramout); + Screen(in=in, load=loadscreen, address=address[0..12], out=scrout); + Keyboard(out=kbout); + Mux4Way16(a=ramout, b=ramout, c=scrout, d=kbout, sel=address[13..14], out=out); } \ No newline at end of file diff --git a/05/Memory.out b/05/Memory.out new file mode 100644 index 00000000..1dbf7eda --- /dev/null +++ b/05/Memory.out @@ -0,0 +1,54 @@ +| in |load | address | out | +| -1 | 1 | 000000000000000 | 0 | +| -1 | 1 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 010000000000000 | 0 | +| 9999 | 0 | 100000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 0 | +| 2222 | 1 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 010000000000000 | 2222 | +| 9999 | 0 | 000000000000000 | -1 | +| 9999 | 0 | 100000000000000 | 0 | +| 9999 | 0 | 000000000000001 | 0 | +| 9999 | 0 | 000000000000010 | 0 | +| 9999 | 0 | 000000000000100 | 0 | +| 9999 | 0 | 000000000001000 | 0 | +| 9999 | 0 | 000000000010000 | 0 | +| 9999 | 0 | 000000000100000 | 0 | +| 9999 | 0 | 000000001000000 | 0 | +| 9999 | 0 | 000000010000000 | 0 | +| 9999 | 0 | 000000100000000 | 0 | +| 9999 | 0 | 000001000000000 | 0 | +| 9999 | 0 | 000010000000000 | 0 | +| 9999 | 0 | 000100000000000 | 0 | +| 9999 | 0 | 001000000000000 | 0 | +| 9999 | 0 | 010000000000000 | 2222 | +| 1234 | 1 | 001001000110100 | 0 | +| 1234 | 1 | 001001000110100 | 1234 | +| 1234 | 0 | 010001000110100 | 0 | +| 1234 | 0 | 110001000110100 | 0 | +| 2345 | 1 | 010001101000101 | 0 | +| 2345 | 1 | 010001101000101 | 2345 | +| 2345 | 0 | 000001101000101 | 0 | +| 2345 | 0 | 100001101000101 | 0 | +| 2345 | 0 | 110000000000000 | 75 | +| -1 | 1 | 100111111001111 | -1 | +| -1 | 1 | 101000001001111 | -1 | +| -1 | 1 | 000111111001111 | 0 | +| -1 | 1 | 010111111001111 | 0 | +| -1 | 0 | 100111111001110 | 0 | +| -1 | 0 | 100111111001101 | 0 | +| -1 | 0 | 100111111001011 | 0 | +| -1 | 0 | 100111111000111 | 0 | +| -1 | 0 | 100111111011111 | 0 | +| -1 | 0 | 100111111101111 | 0 | +| -1 | 0 | 100111110001111 | 0 | +| -1 | 0 | 100111101001111 | 0 | +| -1 | 0 | 100111011001111 | 0 | +| -1 | 0 | 100110111001111 | 0 | +| -1 | 0 | 100101111001111 | 0 | +| -1 | 0 | 100011111001111 | 0 | +| -1 | 0 | 101111111001111 | 0 | +| -1 | 0 | 110000000000000 | 89 |