Altera_Forum
Honored Contributor
20 years agoProblem testing SRAM device
Hi
I made a Project in Quartus II, and in SOPC Builder, I added NIOS II cpu, AvalonTri-State Bridge to an external SRAM, Jtag UART and a on-chip RAM. The system generation and hardware configuration went fine. I made a simple memory test application, for the external SRAM. It writes a patern on on a specific adress then reads back from that adress, checks if the value is the same that was writen, then it increases the adress and so on. But it doesnt´seem to work http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif What am I doing wrong?? The memory is a 128KByte and is 65536 words by 16bits. The hardware part is ok. I know this becouse I downloaded some applications to the external memory. While Im doing this memory test Im using the onchip ram for prorgram drives and stack.#include <io.h># include <stdio.h># include "system.h"
int main(void)
{
unsigned int value = 0;
unsigned int pattern = 0x0000000F;
unsigned int i, memory_size;
// Adress size is 65536 = 0x8AD0
// EXT_SRAM_BASE is 0x00020000
memory_size = 0x8AD0;
for(i = 0; i< memory_size; i= i+4)
{
IOWR_32DIRECT((ONCHIP_RAM_BASE), i, pattern);
value = IORD_32DIRECT((ONCHIP_RAM_BASE), i);
printf("%d,%d\n", i,value);
if (value != pattern)
{
printf("ERROR!!\n");
}
}
return 0;
} I get the folowing output : 0,-1 ERROR!! 91964,-1 ERROR!! 91968,-1 ERROR!! 91972,-1 ERROR!! 90,15 4,15 8,15 12,15 16,15 20,15 24,15 28,15 32,15 36,15 40,15 44,15 48,15 52,15 56,15 60,15 64,15 68,15 72,15 76,15 80,15 84,15 88,15 92,15 96,15 100,15 104,15 108,15 112,15 116,15 120,15 124,15 128,15 132,15 136,268929082 ERROR!! 140,-528482025 ERROR!! 144,411041845 ERROR!! 148,-528481769 ERROR!! . . . Can someone please tell me what Im doing wrong.