Add16 problem in ALU

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

Add16 problem in ALU

footballfan21
I am having an adding problem in my ALU. Both of my inputs to the add16 are -1 (outNX and outNY) but after the adder is complete the output is 0 (xPlusy). If I'm not mistaken it should be -2. Where am I making a mistake?
Reply | Threaded
Open this post in threaded view
|

Re: Add16 problem in ALU

footballfan21
I had to restart my Hardware Simulator and after I did that my code worked.
Reply | Threaded
Open this post in threaded view
|

Re: Add16 problem in ALU

cadet1620
Administrator
In reply to this post by footballfan21
Yes, you are correct. The adder output should be -2 (1111 1111 1111 1110) so that 'no' will invert that to be 1.

All the signals I can see are consistent with xPlusY = 0 (outF, outNo, out and ng) so I don't think it's a display or computation problem in the simulator.

Since the first test is computing 0+0 = 0 and the second is comnputing -1 + -1 = 0, I'm thinking that there may be something wrong with your Add16.

Check that you have a functional Add16.hdl in the directory with your ALU.  One quick test would be to rename Add16.hdl to something like Add16.hdl.save so that the ALU will be forced to use the built-in Add16.

If you can't find anything, feel free to email me your ALU and Add16.

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

Re: Add16 problem in ALU

cadet1620
Administrator
In reply to this post by footballfan21
footballfan21 wrote
I had to restart my Hardware Simulator and after I did that my code worked.
Very strange...

I wonder if it somehow had the skeleton Add16.hdl cached.  Since the skeleton has nothing connected to out, it always outputs 0.

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

Re: Add16 problem in ALU

footballfan21
In reply to this post by cadet1620
Thank you for the reply. I started testing my Add16 and it failed the comparison test. I had previously ran that code in the simulator and it passed. I decided to close the program and then reopen it. Once I had finished doing that all of my code worked correctly.
Reply | Threaded
Open this post in threaded view
|

Re: Add16 problem in ALU

ivant
Unfortunately, the course simulators have such bugs. In my workflow, I ended up restarting them after each test.