all repos — nand2tetris @ a89b07f225c7c8ad8255e9ebccc06fc331f3298b

my nand2tetris progress

Re-do ALU.hdl
x1phosura x1phosura@x1phosura.zone
Sat, 04 Dec 2021 15:12:24 -0800
commit

a89b07f225c7c8ad8255e9ebccc06fc331f3298b

parent

ae38c018d23f6076e83b296d977b3bb94fdc2e22

2 files changed, 24 insertions(+), 5 deletions(-)

jump to
M projects/02/ALU.hdlprojects/02/ALU.hdl

@@ -42,5 +42,26 @@ zr, // 1 if (out == 0), 0 otherwise

ng; // 1 if (out < 0), 0 otherwise PARTS: - // Put you code here: -}+ Mux16(a=x, b=false, sel=zx, out=x-or-zero); + Mux16(a=y, b=false, sel=zy, out=y-or-zero); + + Not16(in=x-or-zero, out=not-xoz); + Not16(in=y-or-zero, out=not-yoz); + + Mux16(a=x-or-zero, b=not-xoz, sel=nx, out=x-arg); + Mux16(a=y-or-zero, b=not-yoz, sel=ny, out=y-arg); + + Add16(a=x-arg, b=y-arg, out=add-xy); + And16(a=x-arg, b=y-arg, out=and-xy); + Mux16(a=and-xy, b=add-xy, sel=f, out=func-out); + + Not16(in=func-out, out=not-func-out); + Mux16(a=func-out, b=not-func-out, sel=no, out[0..7]=or8-in1, + out[8..15]=or8-in2, out[15]=ng, + out=out); + + Or8Way(in=or8-in1, out=or8-1); + Or8Way(in=or8-in2, out= or8-2); + Or(a=or8-1, b=or8-2, out=not-zr); + Not(in=not-zr, out=zr); +}
M projects/02/PROGRESS.mdprojects/02/PROGRESS.md

@@ -1,11 +1,9 @@

# Progress -## TODO -ALU - ## DONE Add16 +ALU FullAdder HalfAdder Inc16