- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am having trouble with the optimizing level settings of my design which uses Nios II embedded system as a camera controller and transfering bulk image data to PC by UDP. Now the fastest speed I ever got is about 9Mbit/s ( 1.1MByte/s) but that is far from satisfactory. So I am trying to apply the compiler optimization options to improve the performance. The problem is that whenever I use any compiler optimize level other than -O0, the entire system stops functioning and no data is transferred at all. It must be compiled with -O0 level in order to work. My testing environment is Cyclone 1c20 FPGA chip on a custom borad (which is very similar to the Nios II evaluation board), 50MHz Nios II/f cpu, Lan91c111 MAC. I am using lwIP 1.1 and uC/OS II and the project was biuld with Quartus II 6.0 and Nios IDE 6.0 software. Does anybody have any idea about this problem? Thank you!! MasonLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Never had this problem, but I think the optimization put all the instructions in a slightly different order to optimize the performance throughput. As a result, it may unknowingly messed up some instructions in your program that have to be carried out in an exact order.
There should be some instructions that you can use to prevent sections of your code from being optimised. If there is, you can use them to find out the sections of your code that can't be optimized. Hope this helps. Tony- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
only a remark,
I have not much experience with optimization, but you must e.g. tell the compiler sometimes not to optimize, e.g. volatile variables. perhaps without optiomisation you can omit volatile, but you need it when optimization is switched on.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for you suggestions!! Yes, I think the "volatile" definition do play some role. But I am not quite sure in what cases should I use this keyword.
And in the uC/OS-II there are OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() macros that protects certain critical code from being interrupted. I again do not know where I should use them. Is there any rules about the usage of these items?? Thank you!!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by heavenscape@Aug 26 2006, 04:35 AM ... i am not quite sure in what cases should i use this keyword. --- Quote End --- heavenscape, a volatile variable can change its value by intervention of an event. For example, if you write a wait function, that waits until a port bit is going low:
while ( *((unsigned short *)PORT_BASE) & 0x0001 )
{
; // wait until not set
}
Optimized code reads from PORT_BASE only once and then checks bit 0, which will never change. You have to declare this value to be volatile in order to force the software always to reread the value before checking it: while ( *((volatile unsigned short *)PORT_BASE) & 0x0001 )
{
; // wait until not set
}
If you use a variable that could be changed while it is being processed (e.g. by an interrupt handler), this variable also is volatile, it must always be reread before checked. Mike

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