Forum Discussion
Altera_Forum
Honored Contributor
16 years agoWhere can i find IOR/IOW macros ?
Hi,
1)Where can I find IOR/IOW macros for component i build with sopc component editor? (i mean "user logic" component). Is there any file containing macros list that i can use for my component? 2)Where can I find macros for IRQs handling? thanks in advance4 Replies
- Altera_Forum
Honored Contributor
Include the following files:
Bill#include <sys/alt_irq.h># include <altera_avalon_pio_regs.h> - Altera_Forum
Honored Contributor
SoPC builder does not automatically create macros for your custom user component. You must do this yourself.
Look at one of the existing <component>_regs.h file as an example. Typically you include the <io.h> header file in your header file to gain access to the IOWR and IORD macros. All the information you need to access your component is compiled into the "system.h" file in your BSP or syslib software project. This will have things like the base address of your component on the NIOS' bus. As for as irq handling, the functions for working with interrupts are indicated in the HAL API reference document http://www.altera.com/literature/hb/nios2/n2sw_nii52010.pdf Again, macros you need that tell you which IRQ number your component is using are in the "system.h" file. Jake - Altera_Forum
Honored Contributor
Alternatively define a C struct that maps your device registers.
Define an 'extern' variable of that type. Use the linker to place the variable at the correct address - setting the high address bit if you have the data cache enabled. You either need to make the structure members 'volatile', or put 'asm volatile("" ::: "memory")' in the C source at appropriate points to ensure gcc doesn't have any values cached in registers. Note that gcc generates additional instrctions for 8 and 16 bit volatile data. - Altera_Forum
Honored Contributor
Thank you all for your answers and information :)
I'm not sure i understand exactly the meaning of 'volatile'. I guess i have to do some more reading in order to make things right in the system i'm building.