Forum Discussion
Altera_Forum
Honored Contributor
11 years agoreaddata address for avalon slave interface
HI All, I had connected my own created component to the avalon switch fabric using avalon slave interface. The base address for the component was 0x5040. I wish to read out the data given o...
Altera_Forum
Honored Contributor
11 years agoI assume you are reading from it using Nios II. I would use this macro assuming it's a 32-bit slave port (and include io.h):
IORD_32DIRECT(BASE, OFFSET); The BASE would be 5040, but I would get that from system.h so that it's not hardcoded. The OFFSET field is a multiple of 4 since it's a 32-bit read macro. So if you have 32-bit registers in the component called A, B, C, D you would use offsets 0, 4, 8, and 12 to access them individually. The reason why you use macros like these is it ensures that Nios II data cache (if present) is bypassed and the access reaches the slave port. Even if you don't have a data cache I recommend using these macros so that your software is portable to Nios II CPUs that contain a data cache.