2 ARM7 three-stage pipeline process

Source: Internet
Author: User
Tags processing instruction

Address: http://blog.csdn.net/enlaihe/article/details/7598941


See a lot of the Assembly on the return of the program and the return of the processing address are very special, think about the original pipeline effect. So, decided to summarize learning under arm pipeline.

The ARM7 processor uses a Class 3 pipeline to increase the speed of the processor instruction stream, providing 0.9mips/mhz instruction processing speed.

Ps:

MIPS (Million instruction per Second) indicates how many millions instructions per second. 0.9MIPS, for example, represents 900,000 instructions per second.

Mips/mhz indicates how many MIPS the CPU can perform at run per MHz, such as 0.9mips/mhz, if the CPU runs at a frequency of 1MHz and executes 900,000 instructions per second.

If the CPU runs at a frequency of 20MHz, it can run 18 million instructions per second. Mips/mhz can reflect the speed of the CPU very well.

Level 3 pipeline as shown above (PC as program counter), Pipelining uses 3 stages, so the instruction is executed in 3 stages.

⑴ refers to loading an instruction from memory

⑵ decoding to identify instructions to be executed

⑶ executes the processing instruction and writes the result to the Register

Previously learned 51 microcontroller, because it is relatively simple, so its processor can only complete one instruction read and execute, will execute the next instruction. This way, the PC always points to an instruction that is "executing".

For ARM7, because it is a 3-level pipeline, the processing of the instructions is divided into 3 stages described above.

So the process is actually like this: arm is executing the 1th instruction while decoding the 2nd instruction and removing the 3rd instruction from the memory.

Therefore, the ARM7 pipeline only when taking the 4th instruction, the 1th instruction is complete execution.

The following figure vividly illustrates the processing mechanism of the 3-level pipeline

The following sentence is critical: regardless of the state of the processor, the program counter R15 (PC) always points to the "fetching" instruction, rather than to the "executing" instruction or the "decoding" instruction.

It is customary to use an executing instruction as a reference point, that is, the current 1th instruction.

So, the PC always points to the 3rd instruction,

Or, the PC always points to the address of the currently executing instruction address plus 2 instructions.


When the processor is in arm state, each instruction is 4 bytes, so the PC value is the executing instruction address plus 8 bytes, that is:

PC value = Current program execution position + 8 bytes

When the processor is in a thumb state, each instruction is 2 bytes, so the PC value is the executing instruction address plus 4 bytes, which is:

PC value = Current program execution position + 4 bytes

The following example is a good illustration of this problem.

[plain] view plain copy 0x4000 addpc,pc, #4; the instruction being executed, the address value pc+4 written to the PC 0x4004 ...; The instruction being decoded 0x4008 ...; The instruction being taken, pc=0x4008 0x400c ...; pc+4=0x400c

Additional explanation is that according to the above description, the pipeline can only be filled by the command to maximize performance, that is, each clock cycle to complete the execution of an instruction (single-cycle instructions).

If the program jumps, the pipeline will be emptied, which will require several clocks to fill the pipeline again. Therefore, using the jump instruction as little as possible can improve the execution efficiency of the program.

The PC represents the program counter, the pipeline uses three stages, so the instruction is divided into three stages of execution: 1. Take a reference (load an instruction from memory), 2. Decode (Identify the command to be executed), 3. Execute (Process the instruction and write the result back to the register). The R15 (PC) always points to the "fetching" instruction instead of pointing to the "executing" instruction or the "decoding" instruction. In general, it is customary to contract the "executing instruction as a reference point", called the current first instruction, so that the PC always points to the third instruction. When the arm state, each instruction is 4 bytes long, so the PC always points to the instruction address plus 8 bytes of address, namely: PC value = Current program execution position +8;

ARM directive is a three-level pipeline, refers to, the implementation of the simultaneous execution, now the PC is pointing to the address being referred to, then the CPU is translating the instruction address is PC-4 (assuming that in arm state, an instruction accounted for 4 bytes), the CPU is executing the instruction address is PC-8, This means that the address pointed to by the PC is 8 different from the command address currently being executed.
When a sudden interruption occurs, the address of the PC is saved
So you know, if you return to the PC, then there is an instruction in the middle is not executed, so with sub pc Lr-irq #4.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.