The CPU (Central Processing Unit)
Home ComputersIntroduction
At the heart of any computer system lies the Central Processing Unit (CPU), also known as the processor. The CPU is the brain of your computer, responsible for executing most instructions that your device receives. It's essentially the "control center" where all computations take place. In simple terms, the CPU's primary function is to read and execute a series of instructions called machine code, which are stored in the computer's memory (RAM).
If you are completely in the dark about computers, it might be worth reading the "what are the components of a computer page first" and then you can deep dive into each of the components such as this page "RAM", "Storage", "what is an OS" etc.
What
What is a CPU -- maybe this should be a comment
A CPU is a simple item that takes in a list of instructions and based on the instructions at hand passes the instruction on to its own internal subcomponents which are optimized to handle the instruction in question. Each of the components are very simple, they can do only one thing, but they can do them very well and blazingly fast. The components of the CPU are:- Control Unit - reads/parses the instruction and decides where it goes. It itself doesnt actually perform any operations, it only delegates
- Bus management Unit - interacts with the other components of the computer, most importantly the memory unit (RAM) and the I/O unit (data storage)
- Arithmetic Logic Unit (ALU) - Handles the addition, subtraction, multiplication and division of integer numbers
- Floating-point unit - sames as the ALU, but for floating point numbers (originally cpus didnt have this component or it was optional in the early days, but as computations became more and more about decimal arithmetics this unit has become an integral component as it is highly optimized to performing these operations for floating point numbers
- Registers - holds temporary values close to the cpu for blazingly fast access to variables and computed results
- Memory Unit (MMU) - Handles the reading and writing to/from Memory to cache
- Cache - essentially RAM, but much smaller, much closer to where the action happens and much faster
- Instruction register and pointer - which instruction is being executed now and which is next
- Clock - Measures electric pulse frequencies in Herz (Hz) at regular intervals to be able to sync with other components and keep things aligned and coordinated
How
How does the CPU work -- maybe this should be a comment
The CPU follows a looping mechanism in order to process the instructions it receives, the order of these instructions is:- Fetch - The CPU retrieves an instruction from memory
- Decode - The CPU decodes the instruction to determine what operation needs to be performed.
- Execute: The CPU carries out the instruction, which may involve performing arithmetic operations, accessing memory, or communicating with I/O devices
- Store: The CPU stores any results or intermediate values in memory.
Note!
All of the above assumes we are talking about a modern simple microprocessor - but these have evolved over time into this. If you want to know more about where they came from here is: The Eniac - The univac - The Bomba / Alan Turings Computer What is a Transistor On the other side of this we have where they evolved to from this Single-core vs Dual-core / multi-core processors TPU - Tensor Processing Unit Cryptographic processors GPU - Graphics Processing Unit Processor architecture: 8-bit to 64-bit, arm vs x86 vs mips, risc vs cisc (https://en.wikipedia.org/wiki/Comparison_of_instruction_set_architectures#Instruction_formats)