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

clock timing measurement

Altera_Forum
Honored Contributor II
1,138 Views

Hi, 

 

my aim is to see how many clock cycles it takes for my C code to execute. 

 

How can I do this?. 

 

I have no block design file, I'm using an verliog code as top level design, and a C code to download into processor and make the fucntion(verilog+c code) to work. 

 

It works perfectly, which I want. 

 

My question, is.. 

 

How can I know How many clock cycles it takes for my C code to execute the function(logic) which I want?. 

 

waiting for your reply guys. 

 

thanks, 

Ana
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
431 Views

If you're using NIOS 2 there is a profiler component (performance counter unit) you can add to your system. I've never used it myself so I don't know how it works. 

 

I guess you could make one of those yourself, a write to a sopc component would start a counter and then with another write stop it and read out the value. A start and stop of the timer would give you an estimate of the avalon overhead. 

 

You could also use a timer in your NIOS 2 core to see how long time the program takes to execute and then estimate the number of cycles. 

 

I hope this helps
0 Kudos
Altera_Forum
Honored Contributor II
431 Views

thanks, i will try it out.

0 Kudos
Altera_Forum
Honored Contributor II
431 Views

Hi, 

 

should I give the base address of PERFORMANCE_COUNTER_0_BASE, or wil it get it automatically from system.h,  

 

If I dont declare it gives me an error saying " first use of this function" PERFORMANCE_COUNTER_0_BASE 

 

If I declare this with its base address like. 

 

# define PERFORMANCE_COUNTER_0_BASE 0x00021000 

 

it builds and runs but I get an output where the output runs like : 

 

 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyy 

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 

 

 

why is this because of ?. 

 

waiting for your reply. 

 

thanks, 

Anand
0 Kudos
Altera_Forum
Honored Contributor II
431 Views

I don't know, as I said I never needed to use it. There should be some documentation for the component somewhere on Alteras homepage. If you don't need exact statistics you can try the other methods I suggested. 

 

//Ola
0 Kudos
Reply