Forum Discussion
Altera_Forum
Honored Contributor
14 years agoPersonally I wouldn't use the IORD/IOWR defines that altera provide.
It is generally much easier to define a C structure that matches the device's registers and then allocate a C pointer to address the structure. In many cases (ie places where driver code is run) it is then save just dereference the pointer, sometimes access functions have to be used. The nios will need access functions (or# defines) in order to use ldio/stio instructions (since there use wasn't added as an 'attribute' in gcc). Accidental non-use of the access functions can be eliminated by using a 'struct' to contain the actual value, eg: struct io_uint32_t { volatile uint32_t io_value }; and only ever referencing the io_value from within the access functions.