Marvell

CPU Execution

As previously explained, software can be thought of as a long list of instructions, and all a CPU does is execute one instruction after another from that list. However, the act of executing a single instruction is a complicated process that can be broken down into 5 steps:

  1. Fetch
  2. Decode
  3. Issue
  4. Execute
  5. Write Back / Commit

Using the add r0, r1, r2 as an example; let's see how a CPU processes this instruction.

Fetch — In the first part of instruction execution, the CPU must be able to fetch the instruction. In other words, it must look within software (the long list of instructions) and pick out the right instruction to execute. There is a special register called the program counter, or "PC", contained within the CPU. The PC contains the address of the next instruction to execute. Based on the PC address, the CPU is then able to go out into memory, where the program is stored, and fetch the instruction and bring it back inside. In this case, our PC will be pointing to the add instruction.

Decode — Once an instruction has been fetched, the CPU must determine what to do with it. This process is called "decode." Even after the instruction has been fetched, it is in a raw data format. The decode portion of the CPU figures out what the instruction corresponds to. In this example, the decoder determines that the instruction is an "add" type instruction, and that it is supposed to take the contents of register 1 and register 2 and place the result into register 0.

Issue — After an instruction has been decoded, the CPU must issue the instruction into the execution units. The execution units, as will be described shortly, actually do the data processing. But before the execution units can begin their work, they must know what data to operate on. During the issue portion, the register values (register 1 and 2 in our example) are read from the register file. The register file is a fast, small piece of memory that contains all of the register data. After reading the values, the data is sent to the execution unit, along with a note telling the unit to add the value. For other types of instructions, the execution unit would be told to perform a different function.

Execute — This is the simplest part to explain. The execution portion simply takes the data that it receives and performs the function requested of it. While a CPU is often thought of a pure data processing engine, this breakdown of tasks shows that the actual "execution" of an instruction is only a small part of a CPU's function.

Write Back / Commit — After execution is complete, we still must copy the results into the destination register. In this case, we place the result into register 0. The act of writing the result into the register is also known as "commit." The reason for this terminology is because once the value is written back into the register; you have lost whatever may have been previously stored in that register. At this point, you have committed this instruction and there is no method to go back to the previous state. Finally, the PC (program counter) can be updated to reflect the next instruction in the long list of instructions.

Section 5: CPU Pipelining

Return to the top of the page


For additional product information please register for the Extranet or contact your local Sales Representative.