Progress pill
Hardware level

General hardware model

System Programming Fundamentals

General hardware model

So far we have described binary code as a (mostly) abstract model.
You can use binary code to store and manipulate data in your mind, but we usually delegate those operations to machines (computers), to do those tasks for us.
In order for the machines to be able to work on binary, we need to implement the abstract model into a physical form. This can be done in many ways: there's been some examples of hydraulic or mechanical computers; but the most efficient and scalable implementations we were able to produce so far are based on electricity and transistors.
You can think of a modern computer as a system through which many minuscule currents of electricity travel and intersect.
If a current has low voltage, we consider it as carrying a 0 value; if it has higher voltage, 1.
A transistor is a small physical component (made of silicon and other materials) that can alter the voltage of a current flow A based on the value of a current flow B.
There are two main types of transistors used for modern computers: NMOS transistors will let the value of current A be 1 if B is also 1
while PMOS transistors will make the value of A be 1 if B is 0.
By combining transistors, it's possible to build small circuits called logic gates, which operate as logical operators. For example, the AND logic gate will take two current flows as inputs and output a current flow with value 1 only if both of them have a value of 1.
By building larger congregations of transistors and logic gates, hardware manufacturers can build small hardware units that can carry more complex and particular operations on binary, like math operations (just like a software developer can combine the basic operations of a programming language to build more and more complex and particular functions for the various needs of a program). You can create a piece of hardware that is the physical manifestation of a program, and it's specialized to executed certain operations as fast as possible. GPUs for example were made as specialized processors for computing graphics (although nowadays a lot are used to run LLMs and mine Bitcoin).
In order to store data, certain transistors are put into memory cells, which are isolated. The electricity that you pass to these transistors gets stuck there unless you use another charge to overwrite it; it remains in the memory cell even when you turn off electricity from your computer. This is the most common way for hardware to store data.
SSDs use memory cells to store your data; but a lot of other hardware components have memory cells too, which are used to store firmware. Firmware is the most fundamental form of programming that a piece of hardware (for example, a GPU) can hold. It stands between hardware and regular software.
Firmware is the basic programming of a hardware component, and is usually distributed by the producer of the hardware. It allows it to be updated (to a degree), for example to fix security bugs by disallowing some functionalities that have been found out to be easily exploitable by attackers. Firmware makes modern hardware more flexible, because it decouples some of its functionality from its physical design: you can change some of the behavior of a piece of hardware without modifying the hardware itself, you just need to overwrite its firmware.
Most of the time firmware is written in C or C++, and executed by a microcontroller. A microcontroller is like a miniature computer inside the hardware component and it controls its various functionalities. Your GPU, your SSD, your wifi and bluetooth adapters, your sound card etc...they usually all have a MCU (MicroController Unit) each, and a piece of firmware that was written specifically for it.
All these hardware components are orchestrated by the CPU (Central Processing Unit), which we will look more deeply into in the next chapter. For now just imagine it as the heart of the computer, exchanging signals to the microcontrollers of the various other hardware components. There is a lot of little details and exceptions about this model, but it's ok as a general idea of the hardware system.
But how can all these components communicate with each other at a physical level? Well most of them are connected into a motherboard. A motherboard has slots to which you can plug in various pieces of hardware, and circuits to connect them all to the CPU (and in certain cases, to each other). This also allows you to substitute certain components of your PC (as long as they're compatible with your motherboard).