Forum Discussion
Altera_Forum
Honored Contributor
19 years agoHi Jordan,
> However, every time I read from a memory address through the old struct interface of NIOS I, > the compiler uses a ldw assembly instruction. This is correct behavior. > If I do the same memory-mapped read using the macros supplied with NIOS II, the compiler > uses a ldwio. If you're referring to the IORD/WR macros, this is correct. > What gives? The compiler doesn't know anything about your data cache. If you don't implement a data cache, then ldw/ldwio behave identically. However, if you do implement a data cache you need to do one of two things: 1. Use the IO macros, which will explicitly use ldxio, or, 2. Make your structs (describing registers) volatile, and use -mno-cache-volatile. The volatile keyword in no sufficient -- it only tells the compiler that it must perform memory read/write on each object reference (rather than storing it in a register). But it doesn't tell the compiler anything about _how_ to access the object -- that's where the compiler flag comes in :-) Hope this helps. Regards, --Scott