Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

problem access meories !!

Altera_Forum
Honored Contributor II
1,474 Views

hi, 

i try implement a design that contain one NIOSII processor and three onchip meories. 

first memory is used for store program. 

the two others memories are used to store data. 

i use the connection matrix to connect the first memory to the data and instruction bus. 

the two others are connected to the data bus only. 

my problem is: 

when i try read and print data from the two data memories, i have a corrupted result like this: 

M0=6 M1=7 M2=5 M3=1 Resultat=2: first data memory 

M0=-1 M1=-1 M2=-1 M3=-1 Resultat=-1: second data memory 

 

For access both data memories,I use this boucle: 

z1=(unsigned int*)0x00002800; 

z2=(unsigned int*)0x00002800; 

for(k=1;k<3;k++) 

//M=0; 

printf("\n-------------------CPU%d--------------------\n",k); 

for(i=0;i<5;i++) 

B=IORD_32DIRECT(z1,0); 

if(i!=4) 

printf("M%d=%d\t", i,B); 

else 

printf("Resultat=%d\n",B); 

z1++;  

//M++;  

 

z2+=0x400; 

z1=z2; 

 

}  

can someone help me! 

best regards
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
554 Views

A couple of questions: 

 

Are the results from the first memory what you are expecting? 

 

Is your second memory at 0x2c00 or 0x3800? If it's at 0x2c00 then the pointer z2 need only be incremented by 0x100 (as it's a pointer to a 4-byte location).
0 Kudos
Altera_Forum
Honored Contributor II
554 Views

hi, 

thk for reply: 

0x2800 base adress for data memory 1 

0x2C00 base adress for data memory 2 

and i pass from memory 1 to memory 2 by adding 0x400. 

and i increment a pointer z1++ (4 bytes) into memory. 

BEST REGARDS
0 Kudos
Altera_Forum
Honored Contributor II
554 Views

I thought that might be the case. 

 

Since z2 is a pointer to int, adding 0x400 will jump to address 0x3800, not 0x2c00. 

 

Can you confirm whether you are reading the first memory correctly?
0 Kudos
Reply