Altera_Forum
Honored Contributor
12 years agoNios2 memory mapped slave - addressing issue
Dear community,
I need your help. I implemented an component -> a wrapper for a single-port ram with a 32-bit width for each memory cell. I am trying to understand the addressing schema. In C I am using the following code
for(int i = 0; i < length; i+=1)
{
temp = temp | (((alt_u8)CURRENT_BYTE) << 24);
read_byte();
temp = temp | (((alt_u8)CURRENT_BYTE) << 16);
read_byte();
temp = temp | (((alt_u8)CURRENT_BYTE) << 8);
read_byte();
temp = temp | ((alt_u8)CURRENT_BYTE);
read_byte();
IOWR_32DIRECT(storagePtr, i, temp);
temp = 0;
} But after reading a few times back with the following code:
for(int i = 0; i < 80; i+=4)
{
printf("address: %x; readback: %x\n", i, IORD_32DIRECT(storagePtr, i));
}
the pattern is changing after 4 calls, but it should change after each call! In my component I'm shifting the address I'm getting from nios2 by 2 (in order to devide by 4). Can anybody explain the addressing schema? Thx.