How the Central Processing Unit (CPU) Works
Computers and Society: How the Central Processing Unit (CPU) WorksThe Central Processing Unit, or CPU, is where a computer does calculations. The figure below shows a simplified diagram of a CPU.
The memory and monitor are outside of the CPU. The memory locations are numbered, starting at zero, so they can be addressed by the CPU. Both data and program instructions are stored in the memory. Inside the CPU are the following features:
- The Instruction Register (IR) is where the current program instruction is stored;
- The Program Counter (PC) is the memory location where the current program instruction is stored;
- The Accumulator (AC) is the place where the CPU processes data. The accumulator stores the results of calculations, and also has the hardware circuits to do addition, multiplication, and all of the other processing that the CPU is capable of;
- Not shown is the Program Logic Unit (PLU), which sequences the operation of the CPU.
- FETCH the instruction from the memory location pointed to by the PC, and copy it to the IR;
- INTERPRET the instruction in the IR by deciding which calculation circuits to use;
- INCREMENT the PC to point to the next memory location;
- EXECUTE the instruction in the IR, using the circuits selected in the INTERPRET step. In the case of a "Go To" or "If" statement, the value in the PC can be changed, causing the program to go to another memory location;
- If the instructions was not a STOP instruction, return to Step 1 and continue.
- The "Operation Code" or Op Code, a binary number which tells whether to add, subtract, divide, multiply, or some other operation;
- The memory location of the data to be used.
Here is an example of how all of these parts work together. In this example, the programmer has the computer add the two numbers in memory locations 10 and 11, and put the answer in location 12. The program starts at location 0, which is the first or lowest-numbered memory location; the memory location of the instruction is the left-most column.
- GET the number stored in memory location 10 and copy it to the AC;
- ADD the number stored in memory location 11 and add it to the AC;
- STORE the contents of the accumulator in memory location 12;
- STOP.
Comments: