- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was trying to convert a large code base written for the NIOS I processor to NIOS II. My clever idea was to simply include the excalibur.h and compile for NIOS II. However, every time I read from a memory address through the old struct interface of NIOS I, the compiler uses a ldw assembly instruction. If I do the same memory-mapped read using the macros supplied with NIOS II, the compiler uses a ldwio. What gives? Did Altera hack their compiler to explicitly not support a struct-based interface for memory-mapped IO?
--JordanLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi 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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I didn't know about the compiler flag.
Thanks, that does help. --Jordan
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page