ARM Cortex-m3(特别是 LPC1343)上的指令时序
我希望在 LPC1343 上编写一些对时序非常敏感的代码,我需要计算精确的时钟周期。有两个问题:-
我读到,从内部闪存执行的代码并不总是能够以完整的 72Mhz 运行,并且可能会引入等待状态。但我找不到任何关于此的“官方”文件。我看到一个地方建议将时间敏感的函数复制到内存中...我正在寻找明确地告诉我这种情况不会发生,或者寻找有关它如何影响计时的信息。
分支指令需要多长时间?我读到这个核心有分支预测,所以时序可能会有所不同。这是正确的吗?如果是的话,有什么方法可以预测它的行为方式,或者禁用它(因为准确的时序比为我节省几个时钟周期更重要) .
I'm looking to write some very timing sensitive code on an LPC1343 where I need to count exact clock cycles. There are two issues :-
I've read that code executing from the internal flash memory isn't always able to run at the full 72Mhz and wait states might be introduced. But I can't find any "official" document about this. I saw one place recommending to copy time sensitive functions into ram... I'm looking for either to be be told definitively that this doesn't happen, or for information on how it affects the timing.
How long do branch instructions take? I read this core has branch prediction so timings might vary.. Is this correct, and if so is there any way to predict how it will behave, or disable that (as exact timing is more important than saving a few clock cycles for me).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Cortex-M3 的指令时序可从 arm.com 获取:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337g/BABBCJII.html
还有管道操作,所以指令计数有点繁琐。
The instruction timing for Cortex-M3 is available from arm.com:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337g/BABBCJII.html
There are also pipeline operations, so instruction counting is a bit fiddly.
以下是 LPC11xx 和 LPC13xx 的一些现实调查:
http://knowledgebase.nxp.com/showthread.php?t=460
简而言之,没有“正确”的答案,结果可能取决于闪存加速器设置、内存对齐、总线架构(诺伊曼与哈佛)、32 位与 16 位指令等。
Here's some real world investigation for LPC11xx and LPC13xx:
http://knowledgebase.nxp.com/showthread.php?t=460
In short, there is no "right" answer, the results might depends on flash accelerator settings, memory alignment, bus architecture (neumann vs. harvard), 32-bit vs. 16-bit instructions and so on.