Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
18 years ago

clock timing measurement

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

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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