Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

clock cycles consumed by NIOSII C code

Altera_Forum
Honored Contributor II
1,527 Views

Hello, 

 

I have a design implemented in NIOS processor. I am using DE1 board. 

I want to calculate the performance/clock cycles consumed by my C code from some specified instruction to some specified instruction. 

How can I do that. 

 

 

Please help.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
425 Views

Add a performance counter to your system, and instrument your code to acquire the measurements of the critical sections. 

 

http://www.altera.com/support/examples/nios2/exm-profiling-de.html 

 

You can also use the NIOS plugin within SignalTap to watch your code as it executes.
0 Kudos
Altera_Forum
Honored Contributor II
425 Views

Hi,  

 

Please verify my procedure. I added a Interval Timer in Qsys. Regenerated the system and burned the new compiled .sof file. 

In NIOSII, i enabled hal.enable_gprof, assigned hal.sys_clk_timer & hal.timestamp_timer to timer in Qsys.  

 

Included PERF_BEGIN(0x5020,1); & PERF_END(0x5020,1); before and after the part of code I want to examine. 

 

Built the project and Run as NIOS II Hardware. 

 

But I am not getting anything on my console window. It was built successfully but finally NIOSII console remain all blank. 

I need to urgently come out of this. 

Please help
0 Kudos
Altera_Forum
Honored Contributor II
425 Views

None of the changes you listed would have affected the console output. Are you able to single step through your code and see the printf()'s being executed?

0 Kudos
Altera_Forum
Honored Contributor II
425 Views

If the code and data is read from tightly coupled memory it is possible to calculate the number of cycles from the object code. 

Except the dynamic branch prediction causes significant randomisation. 

Any data or instruction cache tranfsers will cause significant variations - even if you are counting the actual clock cycles.
0 Kudos
Altera_Forum
Honored Contributor II
425 Views

Hello everyone, 

 

Thank a lot. With all your help and guidance, I successfully implemented my project design. 

I finally calculated the performance using performance counter in Qsys. 

 

Regards, 

Anuj Agrawal
0 Kudos
Reply