CPU Or Computer Processors are the most important part in the computer. CPU controls the overall remaining components of the computer such as Keyboard, Mouse, Monitor and others. The processor is an electronic circuit that executes computer programs.
Processors works in four basic phases:
Fetch: In this phase, the processor collects the bytes to execute from memory (which may be RAM or cache). Each instruction is saved in memory as one or more bytes called word. The more the word length, the more complexity and power consumption of the processor. Once the processor collects the bytes, then it is ready to decode it.
Decoding: In this phase, the processor takes the bytes read in the previous step and input them to the decoder. The decoder activates then the line corresponding to the instruction whose bytes equal to the bytes read from the fetching phase. Each instruction in the processor is mapped to a certain bits or bytes by the designer so that when the processor fetches these bits or bytes, it can understand them. The number of bits used to represent each instruction may vary according to the processor type. Note that this number of bits may not take the whole word in the memory. For example if the word is represented by 8 bits, then the first four bits can be assigned to the instruction part and the last four bits can be assigned to the data which is needed for the instruction to execute.
Executing: once the processor knows the meaning of the bits by the decoder, it goes then to the execute phase. In this phase, the processor makes the necessary operation as denoted by the decoder. This operation is done on the operand contained along with the instruction bits in the memory word. The operation can be addition, subtraction or mathematical or logical operation.
Write back: once the processor done the operation, it writes it back to the memory in the place denoted by the instruction. This result may be fed to other instructions in the same program. This processes repeated for each instruction until the whole program is executed