Category Archives: CPU

Central Processing Unit

This is the brain of most modern devices: PCs, laptops, servers, phones, etc.

Image result for fetch decode execute cycle

Processing Cycle

The CPU is composed of an ALU (Arithmetic Logic Unit), CU (Control Unit), as well as memory (usually in the form of cache). As the main component of a computer system, the CPU processes various instructions; these would stored in the form of lines of code within an executable.

In order to process these instructions, the CPU has to gather information from storage (like a HDD) or memory (in the form of RAM); this process is also known as fetch. During this phase, the CPU may receive both instructions (assembly code) and data.

Next, the CU decodes these instructions and data into a form that  the ALU can understand; for example, the operation mov, which moves a value into a memory location, would equate to various parts in the CPU’s circuitry to be used. In order the figure what circuitry is needed, the CU would decode the operation mov into the corresponding circuitry.

Lastly, the ALU executes the operation requested; depending on the CPU’s architecture, such x86/x64 and ARM, this step may be carried out over one cycle or multiple cycles, respectively.

Here is an example of the processing cycle in action, when performing an addition of 2 numbers:

The CPU gets to a byte in RAM that contains the command ADD 1 2 The CPU might do this process in 3 distinct cycles:

  1. MOV 1 A – The CU would set the memory location A in cache to the value 1.
  2. MOV 2 B – The CU would set the memory location B in cache to the value 2.
  3. ADD A B – The CU connects the memory locations A and B to the inputs of the ALU (which is configured into addition mode). The ALU then executes this operation and outputs a singular result into memory.