# nx=1 and zx=1?

7 messages
Open this post in threaded view
|

## nx=1 and zx=1?

 For the ALU, what should the output of X be if both nx and zx are set? That is, should x first be negated, and then zeroed, or zeroed, and then negated? Is this behaviour specified, or have I simply overlooked it?
Open this post in threaded view
|

## Re: nx=1 and zx=1?

 Administrator Follow the steps in order as written in the comment in ALU.hdl     if zx=1         set x = 0     if nx=1         set x = !x     etc. Note that in hardware you cannot replace the signal on a wire so this is implemented as     if zx=1         set x1 = 0     else         set x1 = x     if nx=1         set x2 = !x1     else         set x2 = x1     etc. --Mark
Open this post in threaded view
|

## Re: nx=1 and zx=1?

 Thank you very much. I realize now I could have also figured that out from the truth table on the opposite page of the ALU specification, too!
Open this post in threaded view
|

## Re: nx=1 and zx=1?

 Administrator ybakos also wrote a worksheet for the ALU if you want to learn how the various control combinations cause the ALU to compute the specific operations. --Mark
Open this post in threaded view
|

## Re: nx=1 and zx=1?

 I'm having trouble understanding the 2nd and 3rd rows of that truth table. I have no idea how the builtin ALU is getting that LSB set to just one on its own. My ALU is stuck on the following: |        x         |        y         |zx |nx |zy |ny | f |no |       out        |zr |ng | | 0000000000000000 | 1111111111111111 | 1 | 0 | 1 | 0 | 1 | 0 | 0000000000000000 | 1 | 0 | | 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 1111111111111111 | 0 | 1 |