Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

External SSRAM reading/writing problem

Hello everyone,

I want to connect nios core (cyclone ii) to external sram memory (cy7c1380d) but I'm experiencing a problem while reading/writing to/from the memory. For 2MB (data width 32 bits) memory I need 19 address bit, but the memory has 21 address bits. SOPC buider user guide says that Avalon-MM address[0] and address[1] should be left unconnected, but I don't know how to do that.

When I run an ssram test program, read and written data don't match.

unsigned int i;

alt_u32 *buffer = (alt_u32 *)SSRAM_BASE;

for(i=0; i<100; i++) {

buffer = (i+1000000);

}

for(i=0; i<100; i++) {

if(buffer != (i+1000000)) errors++;

}

So instead of this, I tried to do somthing like this:

buffer[0] = 0;

buffer[1] = 1;

...

buffer[50] = 50;

alt_printf("%x ", buffer[0]);

alt_printf("0x%x ", buffer[1]);

...

alt_printf("0x%x ", buffer[50]);

And here is what is printed:

0x30 0x31 0x32 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f 0x30 0x31 0x32 0x23 0x24 0x25 0x26 0x27 0x28 0x29 etc.

So, apparently, the address 0, 16, 32 are overwritten with what I want to write to the address 48, address 3 with 35, etc... At first I thought that it could be a timing issue and I added a delay of -2ns (also tried -3ns, -5ns, 180deg) to the pll (25MHz) that is driving my external ssram, but it didn't solve the problem. There may be a problem with the address pins, and I'm not sure if SOPC builder left-alignes the address bits or I need to do that.

Thanks,

Nikola

14 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    One more question regarding external ssram :)

    My nios is running at 50MHz and I drive ssram with the same speed. Does it make sense to run external memory at clk higher than nios clk?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't think it would give any performance increase. Even if the Nios' data and instruction masters were trying to access the SSRAM simultaneously, I'm not sure the SOPC builder fabric would be able to blend those two together and take advantage on the increased speed. Also any clock crossing domain will add some latency, so you may end up with a slower system.

    It could make sense if you had a fast DMA in your system though. For example a SSRAM and DMA running at 100Mhz, and the Nios kept at 50MHz (if you really don't want to run it at 100 MHz).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If Nios is your only Avalon master, I don't know if using higher ssram frequency makes any sense.

    Probably it'd rather worsen the timing, because of higher frequency signals and more

    logic resources are required (a clock adapter needs to be inserted between nios and ssram).

    You could have some advantage if your ssram requires multicycles or waitstates to perform some

    operations; it this case a higher ssram frequency could avoid Nios stalls and improve performance.

    This is useful with SDRAMs, where you have latencies due to precharge, refresh and row selection delays,

    but with ssram you don't have this intrinsic delays. However, I know this kind of ssram

    use some level of pipelining, so I believe it can lead to multicycle bus stalls if you frequently

    use random access rather than burst or sequential accesses.

    You must browse the datasheet for this information and define the optimal design

    on the basis of the way your application uses the ssram device.

    My advice is testing both configurations with some benchmark and find out which one gives you better results.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for the advice! Since my application is not time-critical, for now I'll keep it running at the same speed.