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.
12455 Discussions

NIOS software execution time using performance counter

Altera_Forum
Honored Contributor II
1,449 Views

I want to calculate my NIOS software execution time. My application need approx 3min(180 sec) to complete execution.(measured with a stopwatch) 

I am using performance counter. As per its specs, it returns a 64 bit value. I am using DE2 board with 50MHz crystal. 

 

So as per my expectation, the counter should return (180*50,000,000) at the end, but its returning something in the range (40*50,000,000). 

 

What could be the reason?? My expected value completely comes under the 64 bit return value, so no case of re-loop. 

I am using: 

 

int main() 

PERF_RESET(PERFORMANCE_COUNTER_0_BASE); 

PERF_START_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

PERF_BEGIN(PERFORMANCE_COUNTER_0_BASE,1); 

 

// Code Logic 

 

PERF_END(PERFORMANCE_COUNTER_0_BASE,1); 

PERF_STOP_MEASURING(PERFORMANCE_COUNTER_0_BASE); 

unsigned long long time; 

time = (unsigned long long)perf_get_section_time(performance_counter_0_base, 1); 

printf("\n\nTotal cycles consumed in FIR calculation = %llu cycles\n", time); 

 

Please suggest.. 

Is their any other way to calculate exact real time??
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
180 Views

Your problem sounds a little bit like your 64-bit value is being truncated to 32-bits due to a software bug; without exact expected/actual values it's hard to say. 

Your problem could also be something like the wrong clock supplied to the performance counter block. 

 

As far as other time measurements go, you can use alt_nticks() for coarse, and a 64-bit Interval Timer for fine granularity; but the performance counter block you are already using works well, I just think you have some bug which is not obvious from your snippet.
Altera_Forum
Honored Contributor II
180 Views

Hi ted, 

 

After a hard time finding the bug, i designed my own IP block in verilog to count the clocks. Now it has perfect 64 bit resolution. 

Thanks for your suggestions.
Reply