Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

Simple question regarding memory, just curious.

Altera_Forum
Honored Contributor II
948 Views

Hello everyone! I have a 32bits /2k onchip memory. This means i have 64 adresses 

When i use IOWR32DIRECT(1) at the adress 0x00, the adresses 0x01 0x02 and 0x03 recieve the value 1 also. 

 

I understand that hexadecimal system is represented by 4 bits, therefore i need 8 hexadecilmal chars to represent the 32bits of memory. 

 

What if i write in the adress 0x01 instead of 0x00, will the 0x02 0x03 and 0x04 adress become 1? Is this the way it's supposed to be? 

 

is 0x00000001 adress different from 0x01? I am kinda confused
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
257 Views

It sounds like the function you are using is using byte addressing, but only really supports word addressing: 

 

IE If you write 0x33221100 to address 0x00 

but read back address 0x01 the data still looks like: 

0x33221100 

 

Because the lower to bits of the address do not matter as far as the system is concerned, and it's up to you to pick the correct byte out of the 32 bit word. 

 

Pete
0 Kudos
Altera_Forum
Honored Contributor II
257 Views

So you are telling me that the real adresses are  

10 

100 

1000 

10000 

etc? And that the lower bits doesnt matter?
0 Kudos
Altera_Forum
Honored Contributor II
257 Views

What anakha mean is that Nios/Avalon system is based on byte addressing; then a 32bit word at address A is actually the same as 4 bytes at addresses A+0, A+1, A+2, A+3. 

During 32bit memory accesses, the lower two bits of address are discarded and the 32bit word is aligned on multiple of 4 addresses. So you get distinct data for addresses 0, 4, 8, 12, 16 etc. While if you read back at 1, 2, 3 you get the same as address 0, like in your case. 

On the other hand, if you use the IORD and IOWR macros, the native width of the bus is considered: for a 32bit memory device IORD_32DIRECT at address A is equivalent to IORD at address A/4. 

For more comprehensive information refer to the Nios software developer handbook, ch. 9.
0 Kudos
Reply