bwspot wrote
My though process is just to do what the table shows or the worksheet.
Based on the input bits zero or not zero x,y , negate or not negate x,y , then or or and x,y , then not out or leave it alone. I feel like i need to use dmux to start with above, but still cannot see the whole picture.
* The ALU. Computes a pre-defined set of functions out = f(x,y)
* where x and y are two 16-bit inputs. The function f is selected
* by a set of 6 control bits denoted zx, nx, zy, ny, f, no.
* The ALU operation can be described using the following pseudocode:
* if zx=1 set x = 0 // 16-bit zero constant
* if nx=1 set x = !x // Bit-wise negation
* if zy=1 set y = 0 // 16-bit zero constant
* if ny=1 set y = !y // Bit-wise negation
* if f=1 set out = x + y // Integer 2's complement addition
* else set out = x & y // Bit-wise And
* if no=1 set out = !out // Bit-wise negation
You are thinking correctly. You need to do what the the pseudo-code in the ALU.hdl comments shows, in that order. Note that in hardware you cannot replace the value of a "variable" since it is a physical wire so the pseudo-code should really look more like
if zx=1 then x1=0 else x1=x
if nz=1 then x2=!x1 else x2=x1
...
Each if-then-else is a choice between two 16-bit values. You mada a part in project 1 that does that...
--Mark