We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 23013

11.1 EDK - How can I measure the processor execution cycles in MicroBlaze?


Keywords: number, XPS, timer

How can I measure the number of clock cycles needed to execute a piece of my code?


You can use the PLB Timer Peripheral to measure the processor execution cycles. The PLB Timer is a free-running counter that can be controlled through software. In the software code running on MicroBlaze, you can use functions to initialize, set, reset, start, and stop the timer as follows:

1. Initialize the timer functions:
XTmrCtr_Initialize(&XPS_Timer, XPAR_XPS_TIMER_1_DEVICE_ID);

2. Set the timer reset value:
XTmrCtr_SetResetValue(&XPS_Timer, 0, 0x00000000);

3. Start the XPS Timer to measure the cycles needed to copy the buffer:

a. Reset the timer using the function:
XTmrCtr_Reset(&XPS_Timer, 0);

b. Start the timer to count the processor clock cycles:
XTmrCtr_Start(&XPS_Timer, 0);

4. Run the desired routines.

5. Stop the timer:
XTmrCtr_Stop(&XPS_Timer, 0);

6. Measure the consumed clock cycles:
cycles = XTmrCtr_GetValue(&XPS_Timer, 0);

AR# 23013
日期 04/25/2009
状态 Active
Type ??????