PC comparison problem

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

PC comparison problem

lonelyjohner
This post was updated on .
I have successfully loaded my PC.hdl into the program. However, the result is not what I expected:
| time |   in   |reset|load | inc |  out   |
| 1+   |      0 |  0  |  0  |  1  |      0 |
| 2    |      0 |  0  |  0  |  1  |      0 |

the out should be 1 since the inc is set to 1. I have checked my codes but couldn't figure out.



   
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PC comparison problem

cadet1620
Administrator
Your code is logically correct.

You don't need to build you own 0 and 1 constants using Xor, Not and Xor16. There are keywords that you can use for 0 and 1 that automatically adjust for the width of the input they are connected to. Read Appendix A.

Since I don't have your Xor16, I commented out that line and used the keyword in the final Mux16 line. I successfully loaded and tested your part with this change.

This tells me that there is a problem with one of your underlying parts: Xor16, Register, or something Register uses.

If, after you remove Xor16 from your PC, it still fais, you can find the bad part by copying just PC.hdl and its .tst and .cmp files into a subdirectory so that the Hardware Simulator will use the built-in Register. It should then pass. Then add your Register.hdl and see if it still passes. Do this adding one file at a time until you find the error.

[After you get your problem solved, please edit your post to remove the details of your code. We don't want working code remaining on the forum.]

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re:Re: PC comparison problem

lonelyjohner

Thanks, I figured it out! It looks like I forgot to build the Inc16 before and the program must mistakenly loaded the original one..
The rest of my chips are fine and BTW my Xor16 works well because I have created tst and cmp to check it before. Thanks again and I have also edited my posts on the site. 




At 2014-01-05 22:20:14,"cadet1620 [via Nand2Tetris Questions and Answers Forum]" <[hidden email]> wrote:
Your code is logically correct.

You don't need to build you own 0 and 1 constants using Xor, Not and Xor16. There are keywords that you can use for 0 and 1 that automatically adjust for the width of the input they are connected to. Read Appendix A.

Since I don't have your Xor16, I commented out that line and used the keyword in the final Mux16 line. I successfully loaded and tested your part with this change.

This tells me that there is a problem with one of your underlying parts: Xor16, Register, or something Register uses.

If, after you remove Xor16 from your PC, it still fais, you can find the bad part by copying just PC.hdl and its .tst and .cmp files into a subdirectory so that the Hardware Simulator will use the built-in Register. It should then pass. Then add your Register.hdl and see if it still passes. Do this adding one file at a time until you find the error.

[After you get your problem solved, please edit your post to remove the details of your code. We don't want working code remaining on the forum.]

--Mark


If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/PC-comparison-problem-tp4027594p4027595.html
To unsubscribe from PC comparison problem, click here.
NAML


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re:Re: PC comparison problem

lonelyjohner
In reply to this post by cadet1620
Thanks, I figured it out! It looks like I forgot to build the Inc16 before and the program must mistakenly loaded the original one..
The rest of my chips are fine and my Xor16 works well because I have created tst and cmp to check it before. Thanks again and I have also edited my posts on the site.

BTW, are you a teacher or a student in MIT? I think you spend too much time on the forum..

At 2014-01-05 22:20:14,"cadet1620 [via Nand2Tetris Questions and Answers Forum]" <[hidden email]> wrote:
Your code is logically correct.

You don't need to build you own 0 and 1 constants using Xor, Not and Xor16. There are keywords that you can use for 0 and 1 that automatically adjust for the width of the input they are connected to. Read Appendix A.

Since I don't have your Xor16, I commented out that line and used the keyword in the final Mux16 line. I successfully loaded and tested your part with this change.

This tells me that there is a problem with one of your underlying parts: Xor16, Register, or something Register uses.

If, after you remove Xor16 from your PC, it still fais, you can find the bad part by copying just PC.hdl and its .tst and .cmp files into a subdirectory so that the Hardware Simulator will use the built-in Register. It should then pass. Then add your Register.hdl and see if it still passes. Do this adding one file at a time until you find the error.

[After you get your problem solved, please edit your post to remove the details of your code. We don't want working code remaining on the forum.]

--Mark


If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/PC-comparison-problem-tp4027594p4027595.html
To unsubscribe from PC comparison problem, click here.
NAML


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re:Re: PC comparison problem

lonelyjohner
In reply to this post by cadet1620

BTW, are you a teacher or a student in MIT? I think you spend too much time on the forum..





At 2014-01-05 22:20:14,"cadet1620 [via Nand2Tetris Questions and Answers Forum]" <[hidden email]> wrote:
Your code is logically correct.

You don't need to build you own 0 and 1 constants using Xor, Not and Xor16. There are keywords that you can use for 0 and 1 that automatically adjust for the width of the input they are connected to. Read Appendix A.

Since I don't have your Xor16, I commented out that line and used the keyword in the final Mux16 line. I successfully loaded and tested your part with this change.

This tells me that there is a problem with one of your underlying parts: Xor16, Register, or something Register uses.

If, after you remove Xor16 from your PC, it still fais, you can find the bad part by copying just PC.hdl and its .tst and .cmp files into a subdirectory so that the Hardware Simulator will use the built-in Register. It should then pass. Then add your Register.hdl and see if it still passes. Do this adding one file at a time until you find the error.

[After you get your problem solved, please edit your post to remove the details of your code. We don't want working code remaining on the forum.]

--Mark


If you reply to this email, your message will be added to the discussion below:
http://nand2tetris-questions-and-answers-forum.32033.n3.nabble.com/PC-comparison-problem-tp4027594p4027595.html
To unsubscribe from PC comparison problem, click here.
NAML


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re:Re: PC comparison problem

cadet1620
Administrator
lonelyjohner wrote
BTW, are you a teacher or a student in MIT? I think you spend too much time on the forum..
I'm not associated with MIT. I'm a contracting Firmware/Embedded systems engineer with 35+ years in the industry. See my bio.

I've become the forum admin and major answer guy as a a way to repay the more experienced people who helped me along in my early career.

--Mark
Loading...