Fetch–Decode–Execute Cycle
In the fetch stage ("fetch" is a synonym of "bring",) the CPU copies an instruction from main memory in the following manner:
- The program counter (PC) register of the CPU's control unit stores the address (location) in RAM of the next instruction that should be fetched.
- The CPU sends a signal to main memory over the control line to indicate that the CPU wants to read data from main memory. The CPU then also sends the address (i.e., the value of the program counter) over the address line.
- Once receiving that electric signal, main memory responds by sending the content of that address (which is the instruction the CPU is looking for) to the CPU over the data line.
- After the CPU receives the instruction, it increments the program counter to point to the next instruction in memory.
This process ensures that instructions are fetched in the correct order, allowing the program to run smoothly.
The fetched instruction is temporarily stored in another register, called the Instruction Register (IR), which is also located inside the CPU's control unit.