How does a CPU work?

The Central Processing Unit (CPU) , also known as the microprocessor is the heart and/or brain of a computer. However, instead of actually thinking, it moves data through the system in a manner defined by computer programmers. Accept input, process data, and deliver results. These are critical to the operation of any computer system.

Two main components of a processor:

  • Control unit — CU
  • Arithmetic and logical unit — ALU

Control Unit — CU

The CU control unit is the part of the CPU that helps orchestrate the execution of instructions. It Indicates what to do. According to the instructions, it helps to activate the cables that connect the CPU to other parts of the computer, including the ALU. The control unit is the first component of the CPU to receive the processing instruction.
There are two types of control unit:
  • hardwired control units.
  • microprogrammable (microprogrammed) control units.
Hardwired control units are the hardware and needs the change in hardware to add modify it’s working where as microprogrammable control unit can be programmed to change its behavior. Hardwired CU are faster in processing instruction whereas microprogrammable as more flexible.

Arithmetic and logical unit — ALU

The ALU receives interpreted instructions from the CU and performs all math and logic calculations using logic gates (which depend on transistors) to receive binary input (ones and zeros) and return the appropriate output (e.g. the sum of an addition problem).
As you can imagine, even the simplest processes carried out by a computer require a large number of logic gates. These groups of logic gates are called registers. Although there are different types of registers, the main function of each register is to store data and make it easily accessible to other components of the computer, such as memory. 
Data from the ALU is transmitted to other parts of the CPU over electrical paths known as the internal bus. Based on our brain analogy, the internal bus works like the dendrites in our brain, receiving and transmitting data to other parts of the brain. 
The internal bus (like all other bus types) consists of two main parts: a data bus and an address bus. These two buses work together to deliver actual data to a specific destination. This transfer occurs when electrical signals are sent over RD (read) or WR (write) lines to a computer’s random access memory (RAM), which itself is an example of thousands of registers compacted together to store a large amount of data in a volatile way (it stops storing the data when you turn off your computer).

What are Instructions?

Instruction is the granular level computation a computer can perform. There are various types of instruction a CPU can process.
Instructions include:

  • Arithmetic such as add and subtract
  • Logic instructions such as and, or, and not
  • Data instructions such as move, input, output, load, and store
  • Control Flow instructions such as goto, if … goto, call, and return
  • Notify CPU that the program has ended Halt

Instruction are provided to computer using assembly language or are generated by compiler or are interpreted in some high level languages. A group of instructions a computer can perform is called an instruction set.

CPU clock (Clock cycle):

Not all CPUs send these signals at the same rate, however. Clock cycle is used to measure the speed of instruction sets sent from a CPU’s bus to the computer’s RAM. 
Measured in gigahertz (gHz), a CPU’s clock cycle speed tells us how many billions (10⁹) of instructions can be handled per second. The faster the clock cycle, the more instructions the CPU can execute. 
Clock cycle = 1/clock rate CPU Time = number of clock cycle / clock rate
This means to improve CPU time we can increase clock rate or decrease number of clock cycle by optimizing the instruction we provide to CPU.
Some processor provide the ability to increase the clock cycle but since it is physical changes there might be over heating and even smokes/fires.
sources:

Leave a Reply

Your email address will not be published. Required fields are marked *