HW Sim says my memory fails, but compare file says otherwise

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

HW Sim says my memory fails, but compare file says otherwise

tuzmusic
I've implemented the memory. The great nand2tetris VS Code plugin that I use to run most of my tests stalls as it waits for keyboard input, so I've run it on the HW simulator.

When I comment out the compare line from the test file, I'm able to run all the way to the end. I see the two lines on the screen, and unless I'm mistaken, my output file matches the test file.

When I uncomment the compare line, though, the HW sim says it fails (at line 41).

I'm assuming my implementation is correct, but I'd like to know what's causing this conflict?
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

WBahn
Administrator
You haven't given us anything to really work with.

About all we know is that your Memory part fails to output the expected results for line 41.

By far, the most likely cause is that your implementation is NOT correct. But unless you give us more information, that's about as far as we can go.

Have you looked at what the compare file and your output file have for line 41 (and perhaps the line or two before and after it)? Where is the difference? Have you worked though the specification to determine if agree that the compare file's contents is correct? If you don't agree, then the most likely situation is that you don't quite understand the specification fully. See if you can understand why the compare file's output is in line with the specifications. If you do agree that the compare file is correct, then go through the logic you implemented and see if you can determine why it is outputting what it is.
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

tuzmusic
This post was updated on .
I will look again when I’m back at my computer, but I believe I said that
the compare file and the output file were indeed idéntica, which is why I
consider my implementation correct.
--

--
*Jonathan Tuzman*

MOD NOTE: Signature items removed.
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

WBahn
Administrator
I removed your links and such from your post. If we allow them, then that will be detected by bots that scour the internet looking for forums where it is allowed and they will then direct spam bots to us. Since I'm the sole maintainer of the site right now and I have to do it in my spare time, it wouldn't take much of an increase in our spam traffic to overwhelm me.

I hope you understand.
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

WBahn
Administrator
In reply to this post by tuzmusic
One thing to look at is whether you are looking at the right files. Most of the tests have a "*-external.cmp" as well as a normal one. They are slightly different since one set includes the internal registers and the other doesn't. Although I don't think that the Memory part has this issue.

When you get a chance, post the relevant lines from both files, and for added assurance, include the name of the file the lines are coming from.

If necessary, you can post your code here as well. We'll just be sure to remove it once the issue is resolved.
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

Lozminda
My 10 cents worth...

Lots of times I thought there was a bug in the simulators or other such stuff, but in the end it was me. I'm not saying that you haven't found something exceptional but there's usually a simpler cause (user error of some sort).

Good luck.

ps I hope you've found something interesting !!
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

tuzmusic
This post was updated on .
@WBahn sorry about the links, they must have been because I was replying via email.

So here's my code for Memory.hdl
MOD NOTE: Code removed -- no longer needed for discussion.

Running Memory.tst, with the "compare-to Memory.cmp" commented out, gives this Memory.out. After pasting, I added the "last line" indication:
|   in   |load |     address     |  out   |
|     -1 |  1  | 000000000000000 |      0 |
|     -1 |  1  | 000000000000000 |     -1 |
|   9999 |  0  | 000000000000000 |     -1 |
|   9999 |  0  | 000000000000000 |     -1 |
|   9999 |  0  | 010000000000000 |      0 |
|   9999 |  0  | 100000000000000 |      0 |
|   2222 |  1  | 010000000000000 |      0 |
|   2222 |  1  | 010000000000000 |   2222 |
|   9999 |  0  | 010000000000000 |   2222 |
|   9999 |  0  | 010000000000000 |   2222 |
|   9999 |  0  | 000000000000000 |     -1 |
|   9999 |  0  | 100000000000000 |      0 |
|   9999 |  0  | 000000000000001 |      0 |
|   9999 |  0  | 000000000000010 |      0 |
|   9999 |  0  | 000000000000100 |      0 |
|   9999 |  0  | 000000000001000 |      0 |
|   9999 |  0  | 000000000010000 |      0 |
|   9999 |  0  | 000000000100000 |      0 |
|   9999 |  0  | 000000001000000 |      0 |
|   9999 |  0  | 000000010000000 |      0 |
|   9999 |  0  | 000000100000000 |      0 |
|   9999 |  0  | 000001000000000 |      0 |
|   9999 |  0  | 000010000000000 |      0 |
|   9999 |  0  | 000100000000000 |      0 |
|   9999 |  0  | 001000000000000 |      0 |
|   9999 |  0  | 010000000000000 |   2222 |
|   1234 |  1  | 001001000110100 |      0 |
|   1234 |  1  | 001001000110100 |   1234 |
|   1234 |  0  | 010001000110100 |      0 |
|   1234 |  0  | 110001000110100 |      0 |
|   2345 |  1  | 010001101000101 |      0 |
|   2345 |  1  | 010001101000101 |   2345 |
|   2345 |  0  | 000001101000101 |      0 |
|   2345 |  0  | 100001101000101 |      0 |
|   2345 |  0  | 110000000000000 |     75 |
|     -1 |  1  | 100111111001111 |     -1 |
|     -1 |  1  | 101000001001111 |     -1 |
|     -1 |  1  | 000111111001111 |      0 |
|     -1 |  1  | 010111111001111 |      0 |
|     -1 |  0  | 100111111001110 |      0 |     <<<<< last line
|     -1 |  0  | 100111111001101 |      0 | 
|     -1 |  0  | 100111111001011 |      0 |
|     -1 |  0  | 100111111000111 |      0 |
|     -1 |  0  | 100111111011111 |      0 |
|     -1 |  0  | 100111111101111 |      0 |
|     -1 |  0  | 100111110001111 |      0 |
|     -1 |  0  | 100111101001111 |      0 |
|     -1 |  0  | 100111011001111 |      0 |
|     -1 |  0  | 100110111001111 |      0 |
|     -1 |  0  | 100101111001111 |      0 |
|     -1 |  0  | 100011111001111 |      0 |
|     -1 |  0  | 101111111001111 |      0 |
|     -1 |  0  | 110000000000000 |     89 |

Using VSCode to compare this with Memory.cmp shows no differences. They are identical.

When I uncomment the compare-to lines, the line I've indicated is the last line that gets written to the out file.

i think this is all the info I can possibly give! Thanks for all your help, you people on this forum are great! :)
Reply | Threaded
Open this post in threaded view
|

Re: HW Sim says my memory fails, but compare file says otherwise

WBahn
Administrator
I don't see a problem with your implementation.

I copied it into a file and ran it on my machine and it passes with no problems.

One possibility is that your .cmp file has gotten corrupted with a hidden character. Try pulling that file from your original download and see if that does the trick.