Forum Discussion

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

Incorrect read data from sdram in NIOS using IORD_16Direct

Hello, i have a problem with reading data from sdram in nios using IORD_16direct. There is my code of sending data to sdram.

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

int chromosome[30] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 };

int randomFirstPoint = onGetRandom(0, 29);

int randomSecondPoint = onGetRandom(0, 29);

int buff = chromosome[randomFirstPoint];

chromosome[randomFirstPoint] = chromosome[randomSecondPoint];

chromosome[randomSecondPoint] = buff;

for (j = 0; j < 30; j++) {

IOWR_16DIRECT(DRAM_BASE + count, 0, chromosome[j]);

count++;

}

}

and there is my code of redaing from sdram

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

int value = IORD_16DIRECT(DRAM_BASE + i, 0);

printf("read value = %d %d\n", value, i);

}

output is

read value = 1

read value = 0 -- incorrect value instead of this would be 2

read value = 3

read value = 16128 -- incorrect value instead of this would be 4

read value = 5

read value = 0 -- incorrect value instead of this would be 6

read value = 7

read value = 16128 -- incorrect value instead of this would be 8

read value = 9

read value = 0 -- incorrect value instead of this would be 10

and so on...

2 Replies

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

    Hi Nurbek,

    Debug the code using following steps.

    1.Print the write and read address and verify.

    2.Or instead of for loop can try something much simpler(write to two address and read from the two without loop) if u succeed try with loop.

    Best Regards,

    Anand Raj Shankar

    (This message was posted on behalf of Intel Corporation)