12.07.2015 Views

Nios Software Tutorial - Faculty.lasierra.edu

Nios Software Tutorial - Faculty.lasierra.edu

Nios Software Tutorial - Faculty.lasierra.edu

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix—Other Board Communication & Debug <strong>Nios</strong> <strong>Software</strong> Development <strong>Tutorial</strong>Changing Gprof SettingsIn some instances, the Gprof settings are not suitable to profile user code.You can manipulate the sampling rate and code chunk size parameters byediting nios_gprof.c in the /sdk/lib directory.The sampling rate is set by the constant TIMER_SAMPLE_RATE (default is10,000) in interrupts per second. If the interrupt rate is too fast (i.e.,causing counters to overflow), decrease the sampling rate. If the interruptrate is too slow (i.e., causing non- repeatable, coarse results), increase thesampling rate.Each timer interrupt increments one of many buckets, which representranges of code memory (code chunk size), defined by HISTFRACTION.■■The default for a 32-bit <strong>Nios</strong> system is 2 bytes for a code chunk size(i.e., HISTFRACTION is 2), which is a single <strong>Nios</strong> instruction. Thissetting increases your data memory footprint by 100% of your codesize.The default for a 16-bit <strong>Nios</strong> system is 8 bytes (due to memoryrestrictions) for a code chunk size, which is four <strong>Nios</strong> instructions.This setting causes the counter buffer to equal 25% of code size.You can use a larger code chunk size (i.e., set HISTFRACTION to 16);however, the negative effect is that the profile occasionally attributes asample to a different function than the program counter was actually in.However, using a larger code chunk size has the positive effect ofr<strong>edu</strong>cing the amount of required memory.To implement these changes, edit the sdk/lib/nios_gprof.c file, andre-create the library by typing make all r in the lib directory.1 You can exclude code from profiling by compiling differentmodules with or without the -pg option. For example, if aprogram consists of my_main.c, mod_1.c, and mod_2.c, and thecritical elements to profile are in mod_1.c, compile the modulesmy_main.c and mod_2.c without the -pg option, and compilemod_1.c with the -pg option.ReferencesReference documents for this appendix include:■■GNU Gprof Profiler Manual, Rev.Debugging with GDB: The GNU Source-Level Debugger48 Altera Corporation

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!