3.8 KiB
CPU
WORK IN PROGRESS
Central processing unit (CPU) is the main, most central part of a computer, the one that performs the computation by following the instructions of the main program; CPU can be seen as the computer's brain. It stands at the center of the computer design -- other parts, such as the main memory, hard disk and input/output devices like keyboard and monitor are present to serve the CPU, CPU is at the top and issues commands to everyone else. A CPU is normally composed of ALU (arithmetic logic unit, the circuit performing calculations), CU (control unit, the circuit that directs the CPU's operation), a relatively small amount of memory (e.g. its registers and cache, the main RAM memory is NOT part of a CPU!) and possibly some other parts. A specific model of CPU is characterized by its instruction set (ISA, e.g. x86 or Arm), which determines the machine code it will understand, then its transistor count (nowadays roughly billions), operation frequency or clock rate (defining how many instructions per second it can execute, nowadays typically billions; the frequency can also be increased with overclocking), number of cores (determining how many programs it can run in parallel) and also other parameters and "features" such as amount of cache memory, possible operation modes etcetc. We also often associate the CPU with some number of bits that's often connected to the data bus width and the CPU's native integer size, i.e. for example a 16 bit CPU will likely have 16 bit integer registers, it will see the memory as a sequence of 16 bit words etc. (note the CPU can still do higher bit operations but they'll typically have to be emulated so they'll be slower, will take more instructions etc.) -- nowadays most mainstream CPUs are 64 bit (to allow ungodly amounts of RAM), but 32 or even 16 and 8 bits is usually enough for good programs. CPU is not to be confused with microprocessor, a CPU that's physically a single small integrated circuit, and MCU, a small single board computer which is composed of a CPU and other parts.
CPU is meant for general purpose computations, i.e. it can execute anything reasonably fast but for some tasks, e.g. processing HD video, won't reach near optimum speed, which is why other specialized processing units such as GPUs (graphics processing unit) and sound cards exist. As a general algorithm executing unit CPU is made for executing linear programs, i.e. a series of instructions that go one after another; even though CPUs nowadays typically have multiple cores thanks to which they can run several linear programs in parallel, their level of parallelism is still low, not nearly as great as that of a GPU for example. However CPUs are good enough for most things and they are extremely fast nowadays, so a suckless/LRS program will likely choose to only rely on CPU, knowing CPU will be present in any computer and so that our program will be portable.
Designs of CPUs differ, some may aim for very high performance while other ones may prefer low power consumption or low transistor count -- remember, a more complex CPU will require more transistors and will be more expensive! Of course it will also be harder to design, debug etc., so it may be better to keep it simple when designing a CPU. For this reason many CPUs, e.g. those in embedded microcontrollers, intentionally lack cache, multiple cores or even a complex instruction pipeline.
TODO: parts, pipeline, diagrams, modes, transistor count history ...