ALU Compare Not Comparing

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ALU Compare Not Comparing

PolarBear
I built my ALU, but when I go to run it when the X values are all 0 and the Y values are all 1, it runs fine until the output should be something like 0000000000000001 or 1111111111111110 then it errors out on me.
Also when the X=0000000000010001 Y=0000000000000011 it seems to error out on each one.
I've been racking my brain trying to figure it out. I'm betting it is something easy that I'm just not seeing.

Maybe if someone can explain how the ALU can end up with an out of 0000000000000001 when X=0000000000000000 Y=1111111111111111

Many thanks!

---------------------------------------------------------------------------------

My output

|        x         |        y         |zx |nx |zy |ny | f |no |       out        |zr |ng |
| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000000 | 1 | 0 |

Correct output

|        x         |        y         |zx |nx |zy |ny | f |no |       out        |zr |ng |
| 0000000000000000 | 1111111111111111 | 1 | 1 | 1 | 1 | 1 | 1 | 0000000000000001 | 0 | 0 |
Reply | Threaded
Open this post in threaded view
|

Re: ALU Compare Not Comparing

cadet1620
Administrator
PolarBear wrote
I built my ALU, but when I go to run it when the X values are all 0 and the Y values are all 1, it runs fine until the output should be something like 0000000000000001 or 1111111111111110 then it errors out on me.
Also when the X=0000000000010001 Y=0000000000000011 it seems to error out on each one.
I've been racking my brain trying to figure it out. I'm betting it is something easy that I'm just not seeing.

Maybe if someone can explain how the ALU can end up with an out of 0000000000000001 when X=0000000000000000 Y=1111111111111111
For the test line that is failing, all the control bits are TRUE, so the ALU is to compute the "constant 1" function (figure 2.6). The actual computation is ~((~0)+(~0)). If you are having trouble understanding how this computation results in 1, check out this worksheet.

Also, so that you can concentrate on the computation first, this post has ALU test files that ignore the status outputs.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: ALU Compare Not Comparing

PolarBear
Thank you Mark for your quick response. A work collogue and I sat down today over lunch and went over the chart you mentioned and we did a number of the problems. Turns out for the "f" (x+y) and (x&y) I was interpreting the (x+y) to be (x or y). I think I had my head stuck in the boolean algebra too much :)
I will fix up my ALU tonight and post if I was successful or not.

Many Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: ALU Compare Not Comparing

PolarBear
I adjusted my code to correct for the add/or mistake and my ALU passed with flying colours.
Hopefully if others are having this problem, they can learn from my mistake :)