Forum Discussion
Altera_Forum
Honored Contributor
13 years agoMy preference (like most software people who write device drivers) is to use C structures to map device registers. It is generally much less error-prone than using constants for all the offsets.
I also like defined constant addresses for IO. Any software is likely to be written on completely different systems, and by different people than those writing the vhdl - so you don't want the addresses changing on the whim of some tool. On a Nios (without mmu, but with data cache) there are are two ways of bypassing the data cache: 1) Use the 'stio' and 'stio' forms of the instructions. 2) Set the msb of the physical address. Those Altera# defines with long names do the former, and might be multiplying offsets by 4 for good measure! We just cross compiler our code using gcc and make (etc) with our own carefully crafted linker script to put each section at the correct addresses.