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++
12605 Discussions

Where can i find IOR/IOW macros ?

Altera_Forum
Honored Contributor II
1,453 Views

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 advance
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
526 Views

Include the following files: 

 

#include <sys/alt_irq.h># include <altera_avalon_pio_regs.h>Bill
0 Kudos
Altera_Forum
Honored Contributor II
526 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
526 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
526 Views

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.
0 Kudos
Reply