rdtsc equivalent on v4?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

rdtsc equivalent on v4?

959 次查看
klaus
Contributor I
Hi,

does anyone have an idea how to best get something equivalent to the x86 rdtsc instruction on a v4 core (mcf548x specifically) for reading out a cycle count?

I was considering using the second slice timer to count down from ffffffff, read the SCNT register  use the inverted value. The problem with that is that this is supposed to work from userspace, and the MBAR region is locked down to kernel accesses.

Thanks!
Klaus
标签 (1)
0 项奖励
回复
2 回复数

512 次查看
mon3al
Contributor I

Hi,

Did you ever come up with a solution to this. I'm trying measure CPU clock frequency. I was thinking of counting instructions in a loop and them using a timer to measure the time it took.

0 项奖励
回复

512 次查看
TomE
Specialist II

I program a spare DMA Timer to free-run at an appropriate rate, and use that for all "real time" measurements. Having it run at 1MHz is very convenient for the software as it doesn't involve any "human time to clock tick" conversions.

 

The following assumes that the timer is running:

 

/* * Define an architecture-neutral microsecond function. For * the mcf5329 CPU we're suing DMA Timer 1 to count * microseconds. */#define DEBUG_US()  (MCF_DTIM1_DTCN)

...
uint32_t nTimer = DEBUG_US();

... Do whatever ...

nTimer = DEBUG_US() - nTimer;
printf("Whatever took %dus\n", nTimer);

 Tom

 

0 项奖励
回复