UPGRADE YOUR BROWSER

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!

使用MPSoC 自己的Global Timer来计量时间的例子

回复
Highlighted
Xilinx Employee
发帖数: 55
注册日期: ‎02-16-2012

使用MPSoC 自己的Global Timer来计量时间的例子

建议使用MPSoC 自己的Global Timer来计量时间,开销小,精度高。
下面是一个的例子。

/* Global Timer is always clocked at half of the CPU frequency */
// #define XPAR_CPU_CORTEXA53_0_TIMESTAMP_CLK_FREQ 99990000
#define COUNTS_PER_USECOND ( (COUNTS_PER_SECOND + 1000000/2 - 1 ) / 1000000 )
#define COUNTS_PER_MSECOND ( (COUNTS_PER_SECOND + 1000/2 - 1 ) / 1000 )


XTime xtTimeBegin, xtTimeEnd;
u64 u64_sleep_cycles;
u64 u64_sleep_ms_passed=0;

XTime_GetTime( &xtTimeBegin );
soft_operation_to_be_measured( );
XTime_GetTime( &xtTimeEnd );
u64_sleep_cycles = xtTimeEnd - xtTimeBegin;
u64_sleep_ms_passed = u64_sleep_cycles/(COUNTS_PER_MSECOND);
xil_printf( "soft_operation_to_be_measured takes %d cycles, equal to %d ms at global time %d.%d second.\n",
u64_sleep_cycles, u64_sleep_ms_passed,
xtTimeEnd/COUNTS_PER_SECOND, xtTimeEnd%COUNTS_PER_SECOND);