ARM具有流水线架构 . 每个时钟周期使流水线前进一步(例如,获取/解码/执行/读取......) . 由于管道连续馈电,执行每条指令的总时间可以接近1个周期,但是从“获取”到完成的单个指令的实际时间可以是3个周期 . ARM在他们的网站上有一个很好的解释:
内存延迟为这个想法增加了另一层复杂性 . ARM采用多级缓存系统,旨在以最少的周期提供最常用的数据 . 即使从最快(L0)缓存中读取也会涉及几个延迟周期 . 如果不立即使用数据,该管道包括允许稍后完成读取请求的工具 . 通过示例更容易理解:
LDR R0,[R1]
MOV R2,R3 // Allow time for memory read to occur
ADD R4,R4,#200 // by interleaving other instructions
CMP R0,#0 // before trying to use the value
// By trying to access the data immediately, this will cause a pipeline
// 'stall' and waste time waiting for the data to become available.
LDR R0,[R1]
CMP R0,#0 // Wastes at least 1 cycle due to pipeline not having the data
我们的想法是隐藏管道中的固有延迟,如果可以的话,通过延迟对寄存器的依赖性(也就是指令交错)来隐藏内存访问中的额外延迟 .