Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21611 Discussions

Problem with Performance Counter Unit

Altera_Forum
Honored Contributor II
2,235 Views

Hi I am trying to measure the number of clock cycles in NIOS2-Eclipse for a C Code using the Performance Counter and I get number of clock cycles as "-1". 

I have used Altera's DE1-NIOS reference design and added the performance counter unit using SOPC builder. 

 

My Code is posted below, please tell me what I have done wrong. Thanks a lot..... 

 

Code : # include <stdio.h># include <system.h># include <altera_avalon_performance_counter.h> 

 

int main() 

PERF_RESET(PERFORMANCE_COUNTER_0_BASE); 

PERF_START_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

printf("HELLO WORLD!!\n"); 

PERF_STOP_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

perf_print_formatted_report ((void *)PERFORMANCE_COUNTER_0_BASE,ALT_CPU_FREQ,1,"FFT"); 

return 0; 

 

Output I get : 

HELLO WORLD!! 

--Performance Counter Report-- 

Total Time: 1.84467E+11 seconds (-1 clock-cycles) 

+---------------+-----+-----------+---------------+-----------+ 

| Section | % | Time (sec)| Time (clocks)|Occurrences| 

+---------------+-----+-----------+---------------+-----------+ 

|FFT | 100|184467440737.09552| -1| 100002| 

+---------------+-----+-----------+---------------+-----------+ 

 

Thanks.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
1,492 Views

Hi ,  

I am facing the same problem . Were you able to solve the problem?  

Can anyone tell me the cause of the problem if they have faced similar issue. 

 

thanks. 

 

 

 

 

--- Quote Start ---  

Hi I am trying to measure the number of clock cycles in NIOS2-Eclipse for a C Code using the Performance Counter and I get number of clock cycles as "-1". 

I have used Altera's DE1-NIOS reference design and added the performance counter unit using SOPC builder. 

 

My Code is posted below, please tell me what I have done wrong. Thanks a lot..... 

 

Code : # include <stdio.h># include <system.h># include <altera_avalon_performance_counter.h> 

 

int main() 

PERF_RESET(PERFORMANCE_COUNTER_0_BASE); 

PERF_START_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

printf("HELLO WORLD!!\n"); 

PERF_STOP_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

perf_print_formatted_report ((void *)PERFORMANCE_COUNTER_0_BASE,ALT_CPU_FREQ,1,"FFT"); 

return 0; 

 

Output I get : 

HELLO WORLD!! 

--Performance Counter Report-- 

Total Time: 1.84467E+11 seconds (-1 clock-cycles) 

+---------------+-----+-----------+---------------+-----------+ 

| Section | % | Time (sec)| Time (clocks)|Occurrences| 

+---------------+-----+-----------+---------------+-----------+ 

|FFT | 100|184467440737.09552| -1| 100002| 

+---------------+-----+-----------+---------------+-----------+ 

 

Thanks. 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,492 Views

Hi, 

 

Not actually but found a work around, i made a new design in the SOPC builder which just had NIOSII Processor, 20KB of On Chip-RAM, JTAG-UART, Performance Counter Unit. 

Then I enabled small C libraries in NIOSII-IDE and ran the same code and got the correct cycle count
0 Kudos
Reply