Love the course and thanks for running this forum too!
I'm trying to build the ALU. But when doing the test, the built in Not function seems to perform the operation multiply by minus-1 and then subtract 1.
My parts for the ALU start with this
Mux16(a=x[0..15], b=false, sel=zx, out=zxx); // zx operation: zero x when zx = 1
Not16(in=zxx, out=notx); // nx part1: get not(x)
Mux16(a=zxx, b=notx, sel=nx, out=nxx); // nx part2: get not(x) when nx = 1
to deal with the first 3 columns of figure 2.6 (i.e. if (zx == 1) set x = 0 then if (nx == 1) set x = !x)
But when I first load the ALU test, notx = -1 after only running the setup code, ie:
output-list x%B1.16.1 y%B1.16.1 zx%B1.1.1 nx%B1.1.1 zy%B1.1.1
ny%B1.1.1 f%B1.1.1 no%B1.1.1 out%B1.16.1 zr%B1.1.1
set x %B0000000000000000, // x = 0
set y %B1111111111111111; // y = -1
And after running the 'compute 0' section, with the input pins correct, I get the internal pin notx = -1 again.
I have the same issue when I later do the same thing for y. And when (x, y) is set to (17, 3), after running the 'compute x' section, zxx = 17 (correctly), notx = -18, zyy = 0 (correctly) and noty = -1, which is why I think I might have some issue with the built Not gate.
I have no idea what is going on here. I've tried walking through my logic, but it seems fine. I just don't know why the Not gate is giving me this output and setting the internal pins to what it is doing. Hopefully I've explained things enough here to be clear, please let me know if I can clarify anything and any help is super appreciated.
And just to add, I am only using the built in chips and haven't added any others to the 02 folder.
If it is a 1, then your first Mux is choosing the 'b; input, which is all '0', and the Not16 is then making this all '1', which is the representation for -1. If x is set to all zeros, then it doesn't matter what zx is because if x is selected, then you have the exact same situation.