CPU (Central Processing Unit) to a computer system is like what a brain is for humans. The CPU oversees running programs on a computer since it contains all the circuitry needed to process input, store data, and create output. The CPU always follows the instructions that guide it about which data to process and how. The central processing unit of a computer has a complex circuit. Every function performed must mandatorily go through the circuit to get the arithmetic, control, or logical work done through the microprocessor. In the early years of the evolution of computers, a CPU could perform only one task at a time. This failed the entire purpose of easy and time-efficient performance but the modern CPUs perform numerous tasks at once, but it is also economical and even fits your pockets. The modern-day CPU refers to the processor package on a conventional motherboard.
Fig. Link: https://qphs.fs.quoracdn.net/main-qimg-fce5327749a04a46f6a9232ecbfc489d-c
The processor package may be seen in the image above. The processor package is a chip that contains the processor and is placed on a small printed circuit (PC) board. This package is placed on a motherboard into the CPU socket and secured. Since the CPU is the brain of a computer system and runs many processes, its temperature tends to rise; the CPU cooler is then attached to the processor package to control the temperature.
CPU Working
Fig. Link: https://cdn.britannica.com/44/7744-050-6E0A2699/organization-computer.jpg
The above figure is a conceptual diagram of a hypothetical CPU for the ease of visualization of components easily.
Arithmetic Logic Unit: This unit is in command to fulfill the requirements that involve mathematics and other logical operations. The specific instructions are stored in the instruction registers. Logical operations can test three conditions:
- Equal-to Condition: It compares the values to see if they are equal in a test for this condition.
- Less than Condition: The computer compares numbers to see if one is less than the other to check for this condition.
- Greater than Condition: The computer decides if one value is greater than the other in this sort of comparison.
A computer can multitask and single-handedly execute more than one condition. Relational operators are symbols that allow you to specify the sort of comparison you wish the computer to make.
Instruction registers and pointer: The instruction pointer directs to the memory location to proceed to the next command. Once the CPU has finished executing the directions, the instruction pointer refers to the memory location where the next command will be stored.
Cache: A cache is storage that enables the user to acquire information faster by saving its memory in a storage layer rather than returning to the primary storage location. It provides high-speed to procure data for future requests. Caching allows you to quickly reuse data that has already been previously obtained or calculated. The data in a cache is often stored in fast access hardware such as RAM (Random-access memory), but it may also be used with a software component. The primary goal is to enhance the data procurement process by avoiding any visit to the slower storage layer maintained a quick service. It trades capacity for speed and often stores a portion of data transiently, unlike databases, which store entire and persistent data.
Control Unit: All the CPU components must be synchronized. The control unit performs this duty at a pace determined by standard clock speed, and it supervises the other units’ actions via timing signals that run throughout the CPU.
Working:
The CPU cycle is managed by the control unit and is coordinated with the CPU clock. This cycle is known as the CPU instruction cycle, and it is made up of fetch, decode, and execute components. The instruction is fetched and put into the instruction register, including static data or references to changeable data. Post-processing of the commands, a data register is utilized to record all the data. On towards any instruction will perform based on data registered in the data register. Gradually, the result is saved in the accumulator.
The primary CPU instruction:
Fetch | Decode | Execute | Fetch | Decode | Execute |
Let us understand how the CPU executes program instructions. Before execution, program instructions and data must be loaded into memory from an input device or a storage medium. The process is further complicated because, as we noted earlier, the data will make a temporary stop in a register.
When the data and instructions are in memory, the CPU performs some steps for each instruction:
- The control unit from memory fetches the instruction.
- The control unit then decodes the instruction and controls the movement of the needed data from memory to the arithmetic or logical unit. These two steps are together known as instruction time.
- The control is subsequently sent to the ALU, which then executes the appropriate action on the data.
- The outcome of the operation is then stored in memory or a register by the arithmetic or logic unit. Steps 3 and 4 are collectively referred to as execution time.
Finally, the control unit tells the memory to send the result to an output or secondary storage device. The time is taken by the system to execute (execution cycle) a pe of particular information (instruction cycle) constituents of the machine cycle. Each central processing unit having an internal clock that emits pulses at a predetermined rate to keep the processes synchronized. A single machine-cycle instruction can contain numerous sub-instructions, each of which must complete in at least one clock cycle. The instruction set is a collection of instructions that each central processing unit is designed to comprehend.
How does the control unit locate them all by itself?
Each instruction and piece of data has an address that identifies its position in memory. The instructions and data may defer, but the address numbers of the location remain the same. A memory location can only contain a certain amount of data, and each address can only hold a certain number of bytes, usually two in a modern computer.