Forum Discussion
Altera_Forum
Honored Contributor
14 years agoInclude the io.h file which contains those macros like this:
# include "io.h" Here is the syntax for IORD and IOWR: IORD(base, offset) IOWR(base, offset, data) base is the base address of the peripheral you are accessing. Offset is the word offset of the register you are accessing in the peripheral. The word size is assumed to be 32-bit so offsets 0, 1, 2, 3, etc... map to byte offsets 0, 4, 8, 12, etc.... That said I recommend using the data size oriented version of these macros called: IORD_8DIRECT(base, offset) IORD_16DIRECT(base, offset) IORD_32DIRECT(base, offset) IOWR_8DIRECT(base, offset, data) IOWR_16DIRECT(base, offset, data) IOWR_32DIRECT(base, offset, data) The only difference is that 'offset' is in bytes and that the macro you choose dictates the width of the access. These give you more control over the access size since they access 1, 2, or 4 bytes at a time. This is important when you access a slave port that contains byte enables and has multiple values stored in a single wide register. These macros perform data cache bypassing. They are typically used for peripheral accesses so that the data doesn't become cached.