Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
1,147 Views

clock cycles consumed by NIOSII C code

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 I
45 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.
Altera_Forum
Honored Contributor I
45 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
Altera_Forum
Honored Contributor I
45 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?

Altera_Forum
Honored Contributor I
45 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.
Altera_Forum
Honored Contributor I
45 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
Reply