Issue with Memory.hdl

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

Issue with Memory.hdl

setanjan123
Hi, I am new to this forum. So I am on Project 5 and am working on the Memory.hdl implementation. The thing is I wrote the HDL and I cannot find a fault with it. However the test always fails at Line 53. Now when I Googled it , I found a few other implementations on Github that were very similar to mine and it turned out they also failed the test. So after some digging around I found their test files are different and quite a bit shorter.

Is this a well known bug or something across the community? Did the tests just get updated in the past 2-3 years to cover more edge cases? Or did they just write their own test cases?

Here is my implementation for reference:

CHIP Memory {
    IN in[16], load, address[15];
    OUT out[16];

    PARTS:
    // Put your code here:
    DMux(in=load, sel=address[14], a=loadmemory, b=loadperi); // Check if normal RAM or peripherals

    DMux(in=loadperi, sel=address[13], a=loadscreen, b=loadkeeb); //Screen or Keyboard

    RAM16K(in=in, load=loadmemory, address=address[0..13], out=outram);
    Screen(in=in, load=loadscreen, address=address[0..12], out=outscreen);
    Keyboard(out=outkeeb);


    Mux16(a=outscreen, b=outkeeb, sel=address[13], out=out1);
    Mux16(a=outram, b=out1, sel=address[14], out=out);
}
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Memory.hdl

ivant
I just downloaded the nand2tetris.zip file from the site and compared the Memory.tst file with my older copy and they do differ.

The changes seem to be summed up in this comment:

// There is an interesting design error that has shown up in several students'
// Memory.hdl files that causes zeros to be written in the corresponding offset
// in the inactive memory segments to the actual write.  To detect this, the
// test must not only look for writes into the wrong segment, but changes.
// The following initialization writes a signal number into the memory where
// the bad writes may occur.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Memory.hdl

setanjan123
I see. That's informative. Did you get the comment from another thread? If so could you kindly link that thread here?
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Memory.hdl

ivant
The comment is from the new Memory.tst file. I just looked at the differences between it and the old one.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with Memory.hdl

setanjan123
Oh I see it. Thanks.