diff --git a/projects/01/abgabe/And.hdl b/projects/01/abgabe/And.hdl new file mode 100644 index 0000000..036d085 --- /dev/null +++ b/projects/01/abgabe/And.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And.hdl + +/** + * And gate: + * out = 1 if (a == 1 and b == 1) + * 0 otherwise + */ + +CHIP And { + IN a, b; + OUT out; + + PARTS: + Nand(a=a ,b=b ,out=nandout); + Not(in=nandout ,out=out); +} diff --git a/projects/01/abgabe/And16.hdl b/projects/01/abgabe/And16.hdl new file mode 100644 index 0000000..8e1d9cc --- /dev/null +++ b/projects/01/abgabe/And16.hdl @@ -0,0 +1,18 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/And16.hdl + +/** + * 16-bit bitwise And: + * for i = 0..15: out[i] = (a[i] and b[i]) + */ + +CHIP And16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + Nand16(a=a,b=b,out=outnand); + Not16(in=outnand,out=out); +} \ No newline at end of file diff --git a/projects/01/abgabe/DMux.hdl b/projects/01/abgabe/DMux.hdl new file mode 100644 index 0000000..9425b89 --- /dev/null +++ b/projects/01/abgabe/DMux.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux.hdl + +/** + * Demultiplexor: + * {a, b} = {in, 0} if sel == 0 + * {0, in} if sel == 1 + */ + +CHIP DMux { + IN in, sel; + OUT a, b; + + PARTS: + Not(in=sel, out=notsel); + And(a=in,b=notsel,out=a); + And(a=sel,b=in,out=b); +} diff --git a/projects/01/abgabe/DMux4Way.hdl b/projects/01/abgabe/DMux4Way.hdl new file mode 100644 index 0000000..ca3ca4f --- /dev/null +++ b/projects/01/abgabe/DMux4Way.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux4Way.hdl + +/** + * 4-way demultiplexor: + * {a, b, c, d} = {in, 0, 0, 0} if sel == 00 + * {0, in, 0, 0} if sel == 01 + * {0, 0, in, 0} if sel == 10 + * {0, 0, 0, in} if sel == 11 + */ + +CHIP DMux4Way { + IN in, sel[2]; + OUT a, b, c, d; + + PARTS: + DMux(in=in, sel=sel[1], a=dmuxouta, b=dmuxoutb); + DMux(in=dmuxouta, sel=sel[0], a=a, b=b); + DMux(in=dmuxoutb, sel=sel[0], a=c, b=d); +} \ No newline at end of file diff --git a/projects/01/abgabe/DMux8Way.hdl b/projects/01/abgabe/DMux8Way.hdl new file mode 100644 index 0000000..fdf4ce5 --- /dev/null +++ b/projects/01/abgabe/DMux8Way.hdl @@ -0,0 +1,23 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/DMux8Way.hdl + +/** + * 8-way demultiplexor: + * {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000 + * {0, in, 0, 0, 0, 0, 0, 0} if sel == 001 + * etc. + * {0, 0, 0, 0, 0, 0, 0, in} if sel == 111 + */ + +CHIP DMux8Way { + IN in, sel[3]; + OUT a, b, c, d, e, f, g, h; + + PARTS: + DMux(in=in, sel=sel[2], a=dmuxouta, b=dmuxoutb); + DMux4Way(in=dmuxouta, sel=sel[0..1], a=a, b=b, c=c, d=d); + DMux4Way(in=dmuxoutb, sel=sel[0..1], a=e, b=f, c=g, d=h); + // Put your code here: +} \ No newline at end of file diff --git a/projects/01/abgabe/Mux.hdl b/projects/01/abgabe/Mux.hdl new file mode 100644 index 0000000..0464e7b --- /dev/null +++ b/projects/01/abgabe/Mux.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux.hdl + +/** + * Multiplexor: + * out = a if sel == 0 + * b otherwise + */ + +CHIP Mux { + IN a, b, sel; + OUT out; + + PARTS: + Not(in=sel,out=notsel); + And(a=a,b=notsel,out=outand1); + And(a=sel,b=b,out=outand2); + Or(a=outand1,b=outand2,out=out); +} diff --git a/projects/01/abgabe/Mux16.hdl b/projects/01/abgabe/Mux16.hdl new file mode 100644 index 0000000..e507ce4 --- /dev/null +++ b/projects/01/abgabe/Mux16.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux16.hdl + +/** + * 16-bit multiplexor: + * for i = 0..15 out[i] = a[i] if sel == 0 + * b[i] if sel == 1 + */ + +CHIP Mux16 { + IN a[16], b[16], sel; + OUT out[16]; + + PARTS: + Not(in=sel,out=notsel); + And16(a=a,b[0]=notsel,b[1]=notsel,b[2]=notsel,b[3]=notsel,b[4]=notsel,b[5]=notsel,b[6]=notsel,b[7]=notsel,b[8]=notsel,b[9]=notsel,b[10]=notsel,b[11]=notsel,b[12]=notsel,b[13]=notsel,b[14]=notsel,b[15]=notsel,out=outand1); + And16(a[0]=sel,a[1]=sel,a[2]=sel,a[3]=sel,a[4]=sel,a[5]=sel,a[6]=sel,a[7]=sel,a[8]=sel,a[9]=sel,a[10]=sel,a[11]=sel,a[12]=sel,a[13]=sel,a[14]=sel,a[15]=sel,b=b,out=outand2); + Or16(a=outand1,b=outand2,out=out); +} diff --git a/projects/01/abgabe/Mux4Way16.hdl b/projects/01/abgabe/Mux4Way16.hdl new file mode 100644 index 0000000..038b7c0 --- /dev/null +++ b/projects/01/abgabe/Mux4Way16.hdl @@ -0,0 +1,22 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux4Way16.hdl + +/** + * 4-way 16-bit multiplexor: + * out = a if sel == 00 + * b if sel == 01 + * c if sel == 10 + * d if sel == 11 + */ + +CHIP Mux4Way16 { + IN a[16], b[16], c[16], d[16], sel[2]; + OUT out[16]; + + PARTS: + Mux16(a=a,b=b,sel=sel[0],out=mux16out1); + Mux16(a=c,b=d,sel=sel[0],out=mux16out2); + Mux16(a=mux16out1,b=mux16out2,sel=sel[1],out=out); +} \ No newline at end of file diff --git a/projects/01/abgabe/Mux8Way16.hdl b/projects/01/abgabe/Mux8Way16.hdl new file mode 100644 index 0000000..6ffe518 --- /dev/null +++ b/projects/01/abgabe/Mux8Way16.hdl @@ -0,0 +1,24 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Mux8Way16.hdl + +/** + * 8-way 16-bit multiplexor: + * out = a if sel == 000 + * b if sel == 001 + * etc. + * h if sel == 111 + */ + +CHIP Mux8Way16 { + IN a[16], b[16], c[16], d[16], + e[16], f[16], g[16], h[16], + sel[3]; + OUT out[16]; + + PARTS: + Mux4Way16(a=a,b=b,c=c,d=d,sel=sel[0..1],out=mux4way1); + Mux4Way16(a=e,b=f,c=g,d=h,sel=sel[0..1],out=mux4way2); + Mux16(a=mux4way1,b=mux4way2,sel=sel[2],out=out); +} \ No newline at end of file diff --git a/projects/01/abgabe/Nand16.hdl b/projects/01/abgabe/Nand16.hdl new file mode 100644 index 0000000..f9bb580 --- /dev/null +++ b/projects/01/abgabe/Nand16.hdl @@ -0,0 +1,28 @@ + +/** + * 16-bit bitwise And: + * for i = 0..15: out[i] = (a[i] and b[i]) + */ + +CHIP Nand16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + Nand(a=a[0],b=b[0],out=out[0]); + Nand(a=a[1],b=b[1],out=out[1]); + Nand(a=a[2],b=b[2],out=out[2]); + Nand(a=a[3],b=b[3],out=out[3]); + Nand(a=a[4],b=b[4],out=out[4]); + Nand(a=a[5],b=b[5],out=out[5]); + Nand(a=a[6],b=b[6],out=out[6]); + Nand(a=a[7],b=b[7],out=out[7]); + Nand(a=a[8],b=b[8],out=out[8]); + Nand(a=a[9],b=b[9],out=out[9]); + Nand(a=a[10],b=b[10],out=out[10]); + Nand(a=a[11],b=b[11],out=out[11]); + Nand(a=a[12],b=b[12],out=out[12]); + Nand(a=a[13],b=b[13],out=out[13]); + Nand(a=a[14],b=b[14],out=out[14]); + Nand(a=a[15],b=b[15],out=out[15]); +} \ No newline at end of file diff --git a/projects/01/abgabe/Not.hdl b/projects/01/abgabe/Not.hdl index 14fb886..788f638 100644 --- a/projects/01/abgabe/Not.hdl +++ b/projects/01/abgabe/Not.hdl @@ -14,5 +14,4 @@ CHIP Not { PARTS: Nand(a=in,b=in,out=out); - // Put your code here: } diff --git a/projects/01/abgabe/Not16.hdl b/projects/01/abgabe/Not16.hdl new file mode 100644 index 0000000..e13c0a0 --- /dev/null +++ b/projects/01/abgabe/Not16.hdl @@ -0,0 +1,32 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Not16.hdl + +/** + * 16-bit Not: + * for i=0..15: out[i] = not in[i] + */ + +CHIP Not16 { + IN in[16]; + OUT out[16]; + + PARTS: + Not(in=in[0],out=out[0]); + Not(in=in[1],out=out[1]); + Not(in=in[2],out=out[2]); + Not(in=in[3],out=out[3]); + Not(in=in[4],out=out[4]); + Not(in=in[5],out=out[5]); + Not(in=in[6],out=out[6]); + Not(in=in[7],out=out[7]); + Not(in=in[8],out=out[8]); + Not(in=in[9],out=out[9]); + Not(in=in[10],out=out[10]); + Not(in=in[11],out=out[11]); + Not(in=in[12],out=out[12]); + Not(in=in[13],out=out[13]); + Not(in=in[14],out=out[14]); + Not(in=in[15],out=out[15]); +} diff --git a/projects/01/abgabe/Or.hdl b/projects/01/abgabe/Or.hdl new file mode 100644 index 0000000..70bb660 --- /dev/null +++ b/projects/01/abgabe/Or.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or.hdl + + /** + * Or gate: + * out = 1 if (a == 1 or b == 1) + * 0 otherwise + */ + +CHIP Or { + IN a, b; + OUT out; + + PARTS: + Not(in=a,out=nota); + Not(in=b,out=notb); + Nand(a=nota,b=notb,out=out); +} diff --git a/projects/01/abgabe/Or16.hdl b/projects/01/abgabe/Or16.hdl new file mode 100644 index 0000000..ce585c2 --- /dev/null +++ b/projects/01/abgabe/Or16.hdl @@ -0,0 +1,19 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or16.hdl + +/** + * 16-bit bitwise Or: + * for i = 0..15 out[i] = (a[i] or b[i]) + */ + +CHIP Or16 { + IN a[16], b[16]; + OUT out[16]; + + PARTS: + Not16(in=a,out=nota); + Not16(in=b,out=notb); + Nand16(a=nota,b=notb,out=out); +} \ No newline at end of file diff --git a/projects/01/abgabe/Or8Way.hdl b/projects/01/abgabe/Or8Way.hdl new file mode 100644 index 0000000..1597f24 --- /dev/null +++ b/projects/01/abgabe/Or8Way.hdl @@ -0,0 +1,23 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Or8Way.hdl + +/** + * 8-way Or: + * out = (in[0] or in[1] or ... or in[7]) + */ + +CHIP Or8Way { + IN in[8]; + OUT out; + + PARTS: + Or(a=in[0],b=in[1],out=or1); + Or(a=or1,b=in[2],out=or2); + Or(a=or2,b=in[3],out=or3); + Or(a=or3,b=in[4],out=or4); + Or(a=or4,b=in[5],out=or5); + Or(a=or5,b=in[6],out=or6); + Or(a=or6,b=in[7],out=out); +} \ No newline at end of file diff --git a/projects/01/abgabe/Xor.hdl b/projects/01/abgabe/Xor.hdl new file mode 100644 index 0000000..a9e9d7c --- /dev/null +++ b/projects/01/abgabe/Xor.hdl @@ -0,0 +1,21 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Xor.hdl + +/** + * Exclusive-or gate: + * out = not (a == b) + */ + +CHIP Xor { + IN a, b; + OUT out; + + PARTS: + Not(in=a, out=nota); + Not(in=b, out=notb); + Nand(a=nota, b=b, out=nandout1); + Nand(a=a, b=notb, out=nandout2); + Nand(a=nandout1, b=nandout2, out=out); +} diff --git a/projects/01/abgabe/Xor2.hdl b/projects/01/abgabe/Xor2.hdl new file mode 100644 index 0000000..360621c --- /dev/null +++ b/projects/01/abgabe/Xor2.hdl @@ -0,0 +1,20 @@ +// This file is part of www.nand2tetris.org +// and the book "The Elements of Computing Systems" +// by Nisan and Schocken, MIT Press. +// File name: projects/01/Xor.hdl + +/** + * Exclusive-or gate: + * out = not (a == b) + */ + +CHIP Xor { + IN a, b; + OUT out; + + PARTS: + Nand(a=a, b=b,out=nand1); + Nand(a=a, b=nand1, out=nandout1); + Nand(a=a, b=nand1, out=nandout2); + Nand(a=nandout1, b=nandout2, out=out); +} diff --git a/projects/01/abgabe/project1.zip b/projects/01/abgabe/project1.zip new file mode 100644 index 0000000..0a1d9d0 Binary files /dev/null and b/projects/01/abgabe/project1.zip differ