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

perfomance counter clock cycle?.

Altera_Forum
Honored Contributor II
1,463 Views

Hi, 

 

this is my C code: 

 

# include <stdio.h> 

# include "alt_types.h" 

# include "system.h" 

# include "altera_avalon_performance_counter.h" 

 

int main() 

 

 

PERF_RESET(PERFORMANCE_COUNTER_BASE); 

PERF_START_MEASURING(PERFORMANCE_COUNTER_BASE); 

PERF_BEGIN(PERFORMANCE_COUNTER_BASE, 1); 

int x,y,z; 

x=10; 

y=10; 

z=x+y; 

 

PERF_END(PERFORMANCE_COUNTER_BASE, 1); 

PERF_STOP_MEASURING(PERFORMANCE_COUNTER_BASE); 

perf_print_formatted_report((void*)PERFORMANCE_COUNTER_BASE, ALT_CPU_FREQ,2, "total","time" ); 

 

// printf("value of c %d\n",c); 

return 0; 

 

 

I get the following output: from console: 

 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

--Performance Counter Report-- 

Total Time: 8.98E-06 seconds (449 clock-cycles) 

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

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

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

|total | 72.4| 0.00001| 325| 1| 

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

|time | 0| 0.00000| 0| 0| 

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

 

 

Is the total clock cycles shown correct; because for just addition operation , does the Nios II take these many clock cycles?. 

 

anyone pls help me whether I'm doing the right thing. 

 

Thanks, 

Anand
0 Kudos
0 Replies
Reply