CS101 Computer Basic
Hello Friends! In the previous post, “Introduction to Computer System”, I gave a brief introduction to the computer. That time I explained the working of a computer system with a simple block diagram. I also discussed its basic hardware and software components.
In this tutorial, we will discuss the Central Processing Unit or CPU. The CPU is the most important component of the computer. It is also called the brain of the computer. Although it mainly performs the processing of data, it also directed other components of the computer, such as memory, input-output devices, etc. We can also say that all the work done by a computer is directly or indirectly done by its CPU.
What is the Processor?
Nowadays, we have a lot of smart devices all around us. Starting with smartphones, now TV, Fridge, washing machine, AC, Light, Fan, speaker, car all have become smart. These devices have made our everyday life very easy and comfortable. Have you ever wondered, how is it possible? Actually, all these devices are controlled by some computer programs. The program executes and these devices complete their work automatically according to the device’s program.
To execute any type of program, a processor is required. It does not matter, whether the program is written for a computer system, or a smart device, or IoT. Wherever programming takes place, a processor is required to execute the program.
The processor is a very complicated electronic circuit, made on a small electronic chip.
Processor is an electronic circuit built in a small chip, responsible for the execution of programs.
Difference between CPU and Processor?
Typically, the term processor is used for the CPU itself. However, computers have many types of processors other than CPU. Of these, you must all know the Graphics Processing Unit or GPU. Also, modern peripheral devices, such as hard disks, keyboards, printers, monitors, etc. have small and low power processors. Using these, the CPU is freed from the additional processing load. Which allows the CPU to apply most of its power to more important tasks. Apart from this, peripheral devices are also able to work at very high speed using these processors.
Basic elements of CPU
The CPU itself is an internal component of the computer. Modern CPUs are small in size and square. One of its faces has multiple gold plated metal pins or connectors. The CPU is placed in a socket on the computer’s motherboard. It is placed in such a way that the CPU’s connectors can connect to the motherboard. Different motherboards have different sockets. Each socket supports some specific types of CPUs. CPUs heat up quickly due to their high speed, which can damage the electronic circuit of the CPU. To avoid overheating, a Heatsink assembly is placed over the CPU which also has a small fan. The electronic circuit consists of six parts:
- Arithmetic Logic Unit (ALU)
- Control Unit (CU)
- CPU Registers
- Cache Memory
For a better understanding of these parts, we will consider each one in detail.
1. Arithmetic Logic Unit (ALU)
The Arithmetic Logic Unit or ALU performs some basic operations according to the program. These include simple arithmetic operations such as addition, subtraction, multiplication, and division, etc., memory operations, such as store data, move data from one place to another, and logical operations such as test a condition, make a decision based on the results, etc.
A co-processor, Floating Point Unit (FPU) is also used with ALU. It is also called a math co-processor or numeric co-processor. The FPU is a specific type of processor that can perform arithmetic calculations at a much faster speed than ALU.
2. Control Unit (CU)
The Control unit or CU is an important part of the CPU. It acts as a nervous system for the computer. It establishes the coordination between all the components of the computer. It takes instructions from memory, decodes them, and executes them with the help of ALU and other units.
3. CPU Registers
CPU registers are extremely fast but low capacity memory storage. It holds the data expected during processing, such as memory address of current and next instruction, etc. It also provides operands of the current instruction to ALU and stores the results. Different CPUs use a variety of CPU registers for different tasks. Following are the most commonly used CPU registers found in almost every CPU:
- Accumulator (AC),
- Data Register (DR),
- Address Register (AR),
- Program Counter (PC),
- Memory Data Register (MDR),
- Index Register (IR),
- Memory Buffer Register (MBR) etc.
4. Cache Memory
Cache memory, like CPU registers, is low capacity and high-speed memory that is directly connected inside the CPU chip. Their capacity is more than CPU registers and less than RAM. Cache memory acts as a buffer between RAM and CPU. It stores the data and instructions used by the processor in advance and makes them available to the CPU immediately when needed. Because of its higher speed and being directly connected to the CPU, it significantly increases the processing speed of the CPU. Modern CPUs have more than one level of cache memory called L1, L2, L3 cache.
Buses are high-speed connection lines. Via these lines, CPU components and memory send data, instructions, and control signals to each other. Buses are mainly classified into the following three types:
a. Address Bus – Address bus carries addresses of the memory or input/output devices to store or fetch the data.
b. Data Bus – Databus carries the data to be processed or processed data between components.
c. Control Bus – Control bus carries the control signals to the components.
A clock is used to synchronize all CPU components. Unlike an ordinary clock, this clock propagates regular electric pulses or signals. The speed of this clock is measured in hertz by the frequency of signals propagated per second. These signals synchronize all components of the CPU, allowing all components to work together.
Primary functions of CPU
CPU has the following four primary functions:
1. Fetch – Fetch is the operation that receives an instruction of a program or data from the primary memory.
2. Decode – Instruction Decoder decodes the received instruction to understand which other components are needed to complete the operation.
3. Execute – After this, the control unit activates the required components and the execution of the operation is performed.
4. Store – After the execution of the operation, the obtained results are stored in the CPU register.
How CPU works
A computer program is a sequence of instructions that are stored in memory. These instructions are in binary or machine language, also known as operational code or Op-code. The record of instruction being processed in the CPU is maintained by a CPU register. This CPU register is called the program counter. It stores the memory address of the instruction being processed by the CPU. After the fetch operation of the instruction, it stores the address of the next instruction.
The functions of the CPU can be understood from its three steps. In the first step, instruction is fetched from memory. In the second step, instruction is decoded. It finds out, which operation to be performed for the execution of the instruction. In the third and final step, the instruction is executed by completing the operation according to the instruction. These three steps are called the instruction cycle of the CPU. This cycle is repeated until all the instructions of the program are executed.
CPU speed is measured in cycles per second or hertz. Modern CPU speeds are up to a few Gigahertz. For example, if the speed of a CPU is two Gigahertz, it can process two billion (2×109) instructions per second.
Types of CPU
AMD and Intel are the leading manufactures of CPUs. Both companies have many variants of CPUs with different specifications. CPUs are classified into the following two main categories:
This type of CPU has only one processor. All CPUs developed before 2005 were primarily single-core CPUs. The speed of these CPUs can be accelerated only by increasing their clock speed. But it also increases the amount of heat produced by the CPU. This was a major hurdle to continue the development of single-core processors. Also, single-core CPUs were unable to execute more than one task simultaneously as it had only one processor. So due to these reasons, single-core CPUs have been discontinued in newer computers.
Modern computers have multi-core CPUs. This type of CPU has more than one processor inside a single electronic chip called CPU cores. These CPUs are widely available after 2005. Typically multi-core CPUs have two, four, six, or eight cores but recently AMD launched its Ryzen Threadripper 3990X CPU which has 64 cores inside a single chip. Due to the high processing power requirement and the temperature constraint, multi-core CPUs are the only practical solution.