Alu error

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

Alu error

tdr
So i am comparing my Alu.hdl with the Alu-nostat.tst and i get "Comparison failure at line n" several times in the Hardware simulator.I checked several times my code and syntax seems correct.

I have now 11 gates for the Alu without the ZR and NG flags, and according to my drawing it should have worked.


Reply | Threaded
Open this post in threaded view
|

Re: Alu error

cadet1620
Administrator
tdr wrote
So i am comparing my Alu.hdl with the Alu-nostat.tst and i get "Comparison failure at line n" several times in the Hardware simulator.I checked several times my code and syntax seems correct.
Your implementation is not correct.

When the test fails, you need to look at the Compare and Output Views to see what the difference is in the output.  There is a horizontal scrolling bug in the HardwareSimulator that makes this difficult for this test. I recommend opening the ALU-nostat.cmp and ALU-nostat.out files in a text editor so that you can see the full lines when the miscompare occurs.

A common problem with ALU is to use arithmetic negation for the nx, ny and no controls. These controls should be binary Nots.
tdr
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

tdr
This is what i get in the.out file

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

This is what i should get from the .cmp file.

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

So it seems i get a 0 instead of 1 when no is 1.what does this mean?That my problem lies at the "no" flag and i should check again my build where i have the "no" condition?

I do have 3 Not16 gates in my build.
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

cadet1620
Administrator
'no' can only invert all 16 'out' bits unless it is grossly wrong. I'd look at the input to the 'no' circuit.

Tracing backwards:

'out' should be 000..001
'no' is 1 so the output from the 'f' circuit should be 111..110

Your 'out' is 000..000 so the output from your 'f' circuit is 111..111

Hint: what is the signed decimal value of 111..110?
tdr
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

tdr
This post was updated on .
i will go into more details and if you feel i have to many details that would spoil the implementation for others feel free to edit or i will edit it later.

So i still am not able to understand what is wrong.
I checked the circuits f and no and theyr connection, and i am not sure what i should do different, but based on what you said i guess my error should be somewhere arround here?


I also have done a side by side comparison between cmp and out in order to find a similarity between the errors. but i can't seem to find one.What confuses me the most is the fact that i get good results and bad results mixed together during the simulation.If something is wrong in my ALU should't i get only bad results?How does this work?

Here is the comparison:

https://imgur.com/a/tKyw4Au 

I guess the signed decimal for 111..110 should be 000...001 right? wich is the same value cmp gets but i can't seem to get in my own ALU.
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

cadet1620
Administrator
tdr wrote
I use ..., Or16 and And16 and Mux16 for f...
Read the ALU description carefully. Or16 is an incorrect part.

(In  2's-complement binary numbers, bit 15 is the sign bit so 111..110 is a negative number.
To find the corresponding positive value, invert and add 1.
    000..001 + 1 = 000...010 = 2 base 10
so 111..110 is -2 base 10.)
tdr
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

tdr
Wow , that Or16 really was the problem. I did it . comparison ended successfully. Only rz and ng remaining .

Thanks Cadet !
Reply | Threaded
Open this post in threaded view
|

Re: Alu error

YoungFear620
Thanks a lot for the right explanation!