Forum Discussion

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

Problem with Performance Counter Unit

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.

2 Replies

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

    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 ---

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

    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