As some of you know, my day job is being a lead software engineer. I’ve discussed a lot of science on this site, but I’ve never actually discussed how computers work, even though I have most experience in that area. Time to change that.
So, let’s start at the bare bones of the computer. If you go down to the smallest unit of a computer, you end up at the transistor level.
Transistors are basically switches. They have three connections. Depending on the input on the first connection, power can or cannot flow from the second to the third connection. In other words, a transistor is a kind of switch. It can be ‘on’ (or 1) and ‘off’ (or 0) – and yes, that’s where the association between computers and 1s and 0s comes from.
Things become interesting when you start connecting transistors together. With two transistors you can create a so-called logic gate. For example, if you connect the output of one transistor to the input of a second, you end up with an AND gate. The output signal will be 1 only when the base signal on both transistors is 1 – in other words, if both transistors are on. With different wiring you can create OR gates (output is 1 if one of the two transistors is on), NOR gates, and so on.
If you start combining these gates, you can start to create mathematical operations. I’ll not go into detail here, but you can start performing addition, multiplication, etc.
Put enough gates together and you can create a CPU.
The central part of a computer is the so-called CPU or Central Processing Unit. The CPU is in some ways the computer. As stated, it contains a large number of transistors in the form of logic gates. And by large number, I mean hundreds of millions of transistors.
The gates I described above are interesting, of course, but essentially they only transform input into output. You enter a lot of 1s and 0s (input signals) on one side, and a lot of 0s and 1s pop out (as output signals). This is still true at the CPU level. The thing is that the CPU does this tricks millions of times per second, and uses some of the output of each step as input for the step after. This changes the CPU from a simple input-output scheme to a so-called state machine.
Add memory and I/O
When I say that the CPU uses some of its output of one step as input for the next step, you have part of the story. This input and output is stored in the so-called ‘registers’ of the CPU.
Some of the commands that the CPU executes allow it to communicate with other parts of the computer. These other parts of the computer are things like memory, hard disks, graphics cards, sound cards, etc.
What happens is that the CPU issues a command (using its transistors) such as ‘put this data (a set of 1s and 0s) at this location (another set of 1s and 0s.)’. The location that the data is sent to can be memory, a hard disk, or some other peripheral device.
This allows the CPU to get and put data, and then use it to execute commands. This includes things like ‘get this color data from memory’ and ‘put this color data in the video memory’. The peripheral device has its own processing unit, using that data and doing whatever it is designed to do, like showing color data on a screen, or picking up input from a keyboard.
Putting it all together
All these building blocks together create what we know of as a computer. When you turn it on, it starts with the ‘bootstrap’ command (named for the Baron von Munchausen, coincidentally), which starts the state machine that is the computer. This state machine then loads data from a specific part of the hard disk to memory and into the CPU, which then starts the operating system (OSX, Linux, Windows,…) and continues from there.
A computer is in essence a machine executing an gigantic extremely complex flowchart to create what we know as desktop computers, laptops, smartphones, ATMs and Tesla cars. And at the base of all of these are simple transistors that have two inputs and one output and process 1s and 0s.
I hope that gives you some insight into the devices that make the world go round these days.