Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12453 Discussions

Simple question regarding memory, just curious.

Honored Contributor II

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
Honored Contributor II

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: 



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. 


Honored Contributor II

So you are telling me that the real adresses are  





etc? And that the lower bits doesnt matter?
Honored Contributor II

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.