Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12436 Discussions

clock cycles consumed by NIOSII C code

Altera_Forum
Honored Contributor II
1,214 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
112 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 II
112 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 II
112 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 II
112 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 II
112 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