diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b95ab74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# Compiled outputs +*.hack +*.out + +# Simulator-generated files +*.cmp +*.diff +*.log +*.out + +# OS-generated files +.DS_Store +Thumbs.db + +# IDE / editor settings +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Build artifacts (if using assembler/compiler scripts) +bin/ +out/ +target/ + +# Python / Java tooling (if you extend projects with custom scripts) +__pycache__/ +*.pyc +*.class diff --git a/00/Off.out b/00/Off.out deleted file mode 100644 index df73827..0000000 --- a/00/Off.out +++ /dev/null @@ -1,2 +0,0 @@ -| a | b | out | -| 0 | 0 | 1 | diff --git a/01/DMux4Way.out b/01/DMux4Way.out deleted file mode 100644 index 7734e2a..0000000 --- a/01/DMux4Way.out +++ /dev/null @@ -1,9 +0,0 @@ -|in | sel | a | b | c | d | -| 0 | 00 | 0 | 0 | 0 | 0 | -| 0 | 01 | 0 | 0 | 0 | 0 | -| 0 | 10 | 0 | 0 | 0 | 0 | -| 0 | 11 | 0 | 0 | 0 | 0 | -| 1 | 00 | 1 | 0 | 0 | 0 | -| 1 | 01 | 0 | 1 | 0 | 0 | -| 1 | 10 | 0 | 0 | 1 | 0 | -| 1 | 11 | 0 | 0 | 0 | 1 | diff --git a/02/ALU.hdl b/02/ALU.hdl index 51c71a2..7525c19 100644 --- a/02/ALU.hdl +++ b/02/ALU.hdl @@ -55,7 +55,8 @@ CHIP ALU { Not16(in=y1, out=noty1); Mux16(a=y1, b=noty1, sel=ny, out=y2); - // handle f (add or and) + // handle f (+ or &) + // do both ops here, is this wasteful? otherwise we run an or, but then we have to "predict" Add16(a=x2, b=y2, out=addout); And16(a=x2, b=y2, out=andout); Mux16(a=andout, b=addout, sel=f, out=fout); diff --git a/02/Add16.hdl b/02/Add16.hdl index 8fbc679..f08ff33 100644 --- a/02/Add16.hdl +++ b/02/Add16.hdl @@ -27,4 +27,5 @@ CHIP Add16 { FullAdder(a=a[13], b=b[13], c=c12, sum=out[13], carry=c13); FullAdder(a=a[14], b=b[14], c=c13, sum=out[14], carry=c14); FullAdder(a=a[15], b=b[15], c=c14, sum=out[15], carry=c15); + // carry 15 is needed but ignored } diff --git a/02/Add16.out b/02/Add16.out deleted file mode 100644 index 20f9c65..0000000 --- a/02/Add16.out +++ /dev/null @@ -1,7 +0,0 @@ -| a | b | out | -| 0000000000000000 | 0000000000000000 | 0000000000000000 | -| 0000000000000000 | 1111111111111111 | 1111111111111111 | -| 1111111111111111 | 1111111111111111 | 1111111111111110 | -| 1010101010101010 | 0101010101010101 | 1111111111111111 | -| 0011110011000011 | 0000111111110000 | 0100110010110011 | -| 0001001000110100 | 1001100001110110 | 1010101010101010 | diff --git a/02/FullAdder.hdl b/02/FullAdder.hdl index c3b65fd..14a49ed 100644 --- a/02/FullAdder.hdl +++ b/02/FullAdder.hdl @@ -11,7 +11,7 @@ CHIP FullAdder { carry; // Left bit of a + b + c PARTS: - HalfAdder(a=a, b=b, sum=tmp1, carry=tmp2); - HalfAdder(a=tmp1, b=c, sum=sum, carry=tmp3); - Or(a=tmp2, b=tmp3, out=carry); + HalfAdder(a=a, b=b, sum=absum, carry=c0); + HalfAdder(a=absum, b=c, sum=sum, carry=c1); + Or(a=c0, b=c1, out=carry); } diff --git a/02/HalfAdder.out b/02/HalfAdder.out deleted file mode 100644 index d081087..0000000 --- a/02/HalfAdder.out +++ /dev/null @@ -1,5 +0,0 @@ -| a | b |sum|car| -| 0 | 0 | 0 | 0 | -| 0 | 1 | 1 | 0 | -| 1 | 0 | 1 | 0 | -| 1 | 1 | 0 | 1 | diff --git a/02/Inc16.hdl b/02/Inc16.hdl index 47ec1a0..e1e4272 100644 --- a/02/Inc16.hdl +++ b/02/Inc16.hdl @@ -14,3 +14,4 @@ CHIP Inc16 { // out = in + 1 Add16(a=in, b[0]=true, b[1..15]=false, out=out); } + \ No newline at end of file diff --git a/02/Inc16.out b/02/Inc16.out deleted file mode 100644 index e69de29..0000000