A CPU is like the brain of the computer – most calculations and systemic functions are controlled by it. A CPU consists of memory, RAM, registers, BUS, the control section, and ALU.
- Memory. Memory is the CPU’s way to store data. Let’s start from a 1-bit memory cell, because larger memory are just multiple 1-bit memory cells. A 1-bit memory cell has one input and an enable section. The input is binary (either 1 or 0) and the enable is on or off. When the enable is off, toggling the input will not change the value stored in the memory cell. However, when the enable is turned on, the input value will override whatever value was kept in the memory cell previously. I know what you are thinking: keeping one number in memory doesn’t seem so useful. Remember that all data in a computer are stored in binary. So 1-bit memory may not seem useful but we can stack memory to get 8-bits (or 1-byte) memory, or 16-bit memory, etc.
- Random Access Memory (RAM). RAM is a kind of temporary memory; it holds data that the CPU requires for the next instruction (code), and once the instruction is completed, the data is wiped. RAM contains multiple memory cells arranged in a lattice. RAM gets its name from being able to access a single cell of memory by knowing the column and row that intersect at that memory cell. This is in contrast to Sequential Access Memory (SAM), where it is necessary to go through each memory cell until the desired cell is reached. Being able to directly access random memory cells makes RAM much faster than most other types of memory, but also makes RAM much more power hungry which in turn generates heat. This is why there isn’t a lot of RAM on the CPU.
- Register. A register is like RAM in the sense that it also is temporary memory, but unlike RAM in the sense that it holds what the CPU needs for computing right now. The circuit consists of input(s) and an enable section similar to that in the memory. When the enable goes high (on), the input(s) are “written” to the register, which then passes the data on to another part of the CPU, probably the BUS. When the enable is low, toggling the input(s) doesn’t do anything. Registers are also scalable, meaning that we can add 1-bit registers to get 1-byte registers, etc.
- BUS. The BUS connects all parts of the CPU. The BUS is like a bus that picks up passengers (data), and transports them around the city (CPU). At certain stations, the bus drops the passengers and continues on. The wider the bus, the more passengers it can fit. So, a 256-bit BUS can carry more data than an 8-bit BUS, thus the bigger the BUS “width”, the faster the CPU is.
- Control Section. The control section is like the control tower of an airport, making sure things are working properly, taking in instructions (code) and distributing the instructions to different parts of the CPU.
- Arithmetic Logic Unit (ALU). The ALU does exactly what you think it does – it handles the arithmetic and logical operations of the CPU. The inputs to the ALU are operands (the numbers that operations will be performed on) and the operators.