在ARM平台上工作有段时间了,由于工作的需要,对ARM的体系结构进行了学习,虽然由于项目进度原因,学习的较为肤浅,但是在实践中,还是有一点小小的总结。以下是从一些资料中总结而来,多是从编程角度的考虑。另外,这些都是平时随手写的,所以非常的乱。
嵌入式处理器设计的要求:High Performance, Small Space, Low Power
难点:这些要求是互相冲突的,必须找到一个平衡点。
ARM的
1.Thumb Instruction Set: Multiple Instruction Set
1).16 bit Instruction Set provice small code size(High Code Density) and low power. But It's performance is low.
2).22% Code size reduction, But 25% Performance loss
3).Two implementation approachs on ARM ISA.
Mix Thumb/ARM Instruction is a better method for trade-off between code size and
performance. Thumb Set are commonly used at those codes which run only once or few times.
2.banked register
Register的设计对函数调用性能,中断处理延迟等context switch影响很大。比较有特
色的是:
1).Sun SPARC的register windows:以空间换时间的做法
每个程序可以访问的registers包括:global registers, local registers, in registers, out
registers. 当前的Routine的registers称为: Current Window Pointer(CWP). 并且当前的
Out registers和下一个函数(子函数)的in registers重合(Overlapping),这样,函数调用
开销有效减小。
2).ARM banked register
ARM可以利用不同的操作模式分辨不同的中断类型,即ARM中存在不同的中断处理模
式。
每种模式都有自己local register.仅对该模式可见,从而无需进行太多的register save.
可达到在发生Interupt和Exception时,快速的Context Switch.
3.64bit Multiply-Accumulate Operation
ARM: 16 Register: need 4 bits to designate one register
MISP: 32 Register: need 5 bits
但是ARM指令长度仅仅32bit,要进行复杂的操作,势必需要多个寄存器,但是又有指令长度的限制。
One Instruction only support 4 register operation.
所以ARM的64 bit乘累加操作使用了4个register,有两个既是source register又是destinationi register.(ARM Patent)
Compiler很少能够编译出来此指令
4.Conditional Execution
提高性能:
1).提高时钟频率
2).降低每个Instruction的clock: Pipeline, Superscalar
Pipeline将一个指令分成不同的Stage,每个stage的执行时间较短,通过连续的流水,降
低了每个Instruction的执行时间。
但是一旦发生分支跳转(branch)的时候,Pipeline就会被清空(Flush).
因此Branch Prediction被采用。
但是,ARM中采用了Conditional Execution的方式。(这种方式并不是ARM独创,之前
在Alpha和MIPS中都有,并且这种技术在Intel等处理器中皆有使用,在DSP中也有大量
使用)