Simplify comments to be more concise and student-like

- Removed verbose explanations
- Made comments shorter and more casual
- Focus on key concepts rather than formal descriptions
This commit is contained in:
2025-08-28 15:11:48 +02:00
parent ecdc6ab2bc
commit c39ce212b4
15 changed files with 15 additions and 15 deletions

View File

@@ -11,7 +11,7 @@ CHIP And {
OUT out;
PARTS:
// And(a,b) = Not(Nand(a,b))
// And = Not(Nand)
Nand(a=a, b=b, out=tmp);
Not(in=tmp, out=out);
}

View File

@@ -12,7 +12,7 @@ CHIP And16 {
OUT out[16];
PARTS:
// Apply And gate to each of the 16 bits
// And each bit
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]);

View File

@@ -12,7 +12,7 @@ CHIP DMux {
OUT a, b;
PARTS:
// DMux(in,sel) -> a = And(in, Not(sel)), b = And(in, sel)
// sel=0 sends to a, sel=1 sends to b
Not(in=sel, out=tmp);
And(a=in, b=tmp, out=a);
And(a=in, b=sel, out=b);

View File

@@ -14,7 +14,7 @@ CHIP DMux4Way {
OUT a, b, c, d;
PARTS:
// Use two levels of DMux: first level splits by sel[1], second level splits by sel[0]
// Two levels of DMux
DMux(in=in, sel=sel[1], a=tmp1, b=tmp2);
DMux(in=tmp1, sel=sel[0], a=a, b=b);
DMux(in=tmp2, sel=sel[0], a=c, b=d);

View File

@@ -18,7 +18,7 @@ CHIP DMux8Way {
OUT a, b, c, d, e, f, g, h;
PARTS:
// Use one DMux and two DMux4Way gates: first split by sel[2], then each half by sel[0..1]
// One DMux + two DMux4Way
DMux(in=in, sel=sel[2], a=tmp1, b=tmp2);
DMux4Way(in=tmp1, sel=sel[0..1], a=a, b=b, c=c, d=d);
DMux4Way(in=tmp2, sel=sel[0..1], a=e, b=f, c=g, d=h);

View File

@@ -11,7 +11,7 @@ CHIP Mux {
OUT out;
PARTS:
// Mux(a,b,sel) = Or(And(a, Not(sel)), And(b, sel))
// sel=0 picks a, sel=1 picks b
Not(in=sel, out=tmp1);
And(a=a, b=tmp1, out=tmp2);
And(a=b, b=sel, out=tmp3);

View File

@@ -12,7 +12,7 @@ CHIP Mux16 {
OUT out[16];
PARTS:
// Apply Mux gate to each of the 16 bits
// Mux each bit
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]);

View File

@@ -14,7 +14,7 @@ CHIP Mux4Way16 {
OUT out[16];
PARTS:
// Use two levels of Mux16: first level selects between pairs, second level selects final output
// Two levels of Mux16
Mux16(a=a, b=b, sel=sel[0], out=tmp1);
Mux16(a=c, b=d, sel=sel[0], out=tmp2);
Mux16(a=tmp1, b=tmp2, sel=sel[1], out=out);

View File

@@ -20,7 +20,7 @@ CHIP Mux8Way16 {
OUT out[16];
PARTS:
// Use two Mux4Way16 gates and one Mux16 to select from 8 inputs
// Two Mux4Way16 + one Mux16
Mux4Way16(a=a, b=b, c=c, d=d, sel=sel[0..1], out=tmp1);
Mux4Way16(a=e, b=f, c=g, d=h, sel=sel[0..1], out=tmp2);
Mux16(a=tmp1, b=tmp2, sel=sel[2], out=out);

View File

@@ -11,6 +11,6 @@ CHIP Not {
OUT out;
PARTS:
// Not(in) = Nand(in, in)
// Not = Nand with same input
Nand(a=in, b=in, out=out);
}

View File

@@ -12,7 +12,7 @@ CHIP Not16 {
OUT out[16];
PARTS:
// Apply Not gate to each of the 16 bits
// Not each bit
Not(in=in[0], out=out[0]);
Not(in=in[1], out=out[1]);
Not(in=in[2], out=out[2]);

View File

@@ -11,7 +11,7 @@ CHIP Or {
OUT out;
PARTS:
// Or(a,b) = Not(And(Not(a), Not(b))) - De Morgan's law
// De Morgan's law
Not(in=a, out=tmp1);
Not(in=b, out=tmp2);
And(a=tmp1, b=tmp2, out=tmp3);

View File

@@ -12,7 +12,7 @@ CHIP Or16 {
OUT out[16];
PARTS:
// Apply Or gate to each of the 16 bits
// Or each bit
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]);

View File

@@ -11,7 +11,7 @@ CHIP Or8Way {
OUT out;
PARTS:
// Chain Or gates to combine all 8 inputs
// Chain Or gates
Or(a=in[0], b=in[1], out=tmp1);
Or(a=in[2], b=in[3], out=tmp2);
Or(a=in[4], b=in[5], out=tmp3);

View File

@@ -11,7 +11,7 @@ CHIP Xor {
OUT out;
PARTS:
// Xor(a,b) = Or(And(a, Not(b)), And(Not(a), b))
// Xor = (a AND !b) OR (!a AND b)
Not(in=a, out=tmp1);
Not(in=b, out=tmp2);
And(a=a, b=tmp2, out=tmp3);