FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-14-2004, 09:48 AM
Maxlim
Guest
 
Posts: n/a
Default nios-build debug option

Can anybody tell me what is the effect of debug option in nios-build
command to the original program? What's the usage of debug script that
generated in the command?

I'd connected my processor as a user defined peripheral to nios system
module through SOPC Builder. The system performs corectly only when I
use debug option during nios-build- to compile the C/C++ source code.
Without the debug option, the data that fetched from my processor will
be the data before I initiate the data transaction. I'm suspect that
is the timing problem. But the system works correctly only after the
debug option is used.
Reply With Quote
  #2 (permalink)  
Old 01-14-2004, 11:06 AM
David Brown
Guest
 
Posts: n/a
Default Re: nios-build debug option


"Maxlim" <[email protected]> wrote in message
news:[email protected] om...
> Can anybody tell me what is the effect of debug option in nios-build
> command to the original program? What's the usage of debug script that
> generated in the command?
>
> I'd connected my processor as a user defined peripheral to nios system
> module through SOPC Builder. The system performs corectly only when I
> use debug option during nios-build- to compile the C/C++ source code.
> Without the debug option, the data that fetched from my processor will
> be the data before I initiate the data transaction. I'm suspect that
> is the timing problem. But the system works correctly only after the
> debug option is used.


Turning on the debug option will do two things to the generated code - it
will include debug information in the object files (so that a debugger can
match up variables and addresses, and object code and source code), and it
will turn off (or at least lower) the optomisation levels, making the
generated code more debugger-friendly (trying to debug highly optomised code
can sometimes be very confusing). The chances are, therefore, that your
problem is that your code works with low optomisations and fails on high
optomisations. This means either the compiler's optomiser is broken
(possible, but unlikely), or your code is making unwarented assumptions
about the generated object code. Very often, this can be solved by correct
use of "volatile". For example, consider code such as:

void generateSquareWave(void) {
int i;

while (1) {
outputPort = 0xffff;
for (i = 0; i < 1000; i++) ; // Wait a bit
outputPort = 0x0000;
for (i = 0; i < 1000; i++); // Wait a bit
};
}

Many people would think that this generates a slow square wave. With
optomisation turned off, it probably will. But with high optomisation, the
compiler will notice that the for loops don't actually do anything useful -
they simply waste time, which is exactly what the optomiser is trying to
avoid. It will therefore simply drop them, giving you an extremly fast
square wave. The simple solution to this is to make "i" a "volatile int",
which tells the optomiser that you want to keep every read and write to the
variable, and thus the delays stay in.

Other typical effects are that the optomiser will often re-arrange code to
make it smaller or faster, even if that means changing the order in which
data is read or written (or even *if* it is read or written). Again,
"volatile" will help you enforce the correct order.



Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PLI tab file and misc option [email protected] Verilog 1 06-21-2007 03:35 PM
Icarus Verilog Build Problem Anthony Liu Verilog 1 10-11-2004 05:16 PM


All times are GMT +1. The time now is 08:23 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved