RAM512, Comparison failure at line174

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

RAM512, Comparison failure at line174

Md. Al-Imran Abir
When I simulated RAM512 chip, the error message 'Comparison failure at line174' was shown. My hdl file is as follows. Can you please say, where is the mistake?

CHIP RAM512 {
    IN in[16], load, address[9];
    OUT out[16];

    PARTS:
    // Put your code here:
    RAM64(in = in, load = load, address = address[0..5], out = outRAM1);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM2);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM3);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM4);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM5);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM6);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM7);
    RAM64(in = in, load = load, address = address[0..5], out = outRAM8);

    Mux8Way16(a = outRAM1, b = outRAM2, c = outRAM3, d = outRAM4, e = outRAM5, f = outRAM6, g = outRAM7, h = outRAM8, sel = address[6..8], out = out);
}
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

WBahn
Administrator
Have you looked at line 174 in the comparison and output files?

When something is written to, say, address 42 in RAM, which of your RAM64 parts is it written to?

If that isn't enough reveal the problem, do the following:

Load the value 12345 into address 42.
Load the value 54321 into address 106.

What is the value stored in address 42?
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

Md. Al-Imran Abir
Here are how comparison and output files at line 174 look like: cmpFileValue.JPG outputValue.JPG

"What is the value stored in address 42?" - In both cases, the value stored in address 42 is 12345
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

WBahn
Administrator
In reply to this post by WBahn
Go into the hardware simulator and load your .hdl file.

Set the address to 42, the load pin to 1, and the data to 12345.

Then click the clock to perform a tick-tock cycle.

Does the value 12345 end up where it should -- and ONLY where it should?
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

Md. Al-Imran Abir
No, the value (12345) is loaded into all 42, 64+42, 2*64+42, ...., 7*64+42 registers.

On Sun, May 24, 2020 at 3:32 AM WBahn [via Nand2Tetris Questions and Answers Forum] <[hidden email]> wrote:
Go into the hardware simulator and load your .hdl file.

Set the address to 42, the load pin to 1, and the data to 12345.

Then click the clock to perform a tick-tock cycle.

Does the value 12345 end up where it should -- and ONLY where it should?



To unsubscribe from RAM512, Comparison failure at line174, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

Md. Al-Imran Abir
In reply to this post by WBahn
Thanks, I have understood the problem and been able to solve it.

While the input is supposed to be loaded into a particular register, it was in fact loaded into 8 registers. And this can be fixed using a demultiplexer.  
Reply | Threaded
Open this post in threaded view
|

Re: RAM512, Comparison failure at line174

WBahn
Administrator
Yep. Good job. Good luck as you move forward.