From elementary class, we learned that computers are electronic devices that store and process data. And they instructions in 1s and 0s. But how do they do these? How do we actually write 1s and 0s into the computer? The definition is apt but it leaves so many questions unanswered. Unfortunately, opening up a computer and taking a look at the metals doesn’t do much help (well except you have a good knowledge of electronics). But on this page, your mystery will be removed as I unravel all the happenings hidden under the hood.
Before we go deeper, how do you think we communicate with computers? Did you just mention a keyboard, touchscreen, mouse or other input devices? Well, it’s easier to imagine that communication with computers occurs via these devices and not 1s and 0s but you know easiness doesn’t always translate to being correct right?
We actually communicate with our computers using 1s and 0s. We use the concept of abstraction to take a relatively complex system and simplify it for use. We use abstraction to make complex problems easier to think about. This is done by breaking problems into simpler ideas that describe simple concepts or individual jobs that need to be done and then stack them into layers. The principle of abstraction is implemented in most of the stuff around us. Take for example a fan. If you’ve ever used a hand fan you will know that to increase the rate air is circulated you’ll have to move the fan faster. The same thing happens with electrical fans. But in electrical fans all these processes are abstracted. You just need to turn the regulator knob and enjoy the air circulation without having to know the speed of the blades and the energy required to move at that speed. Other examples include driving a car, using a coffee machine, microphone, etc. This same thing happens in computers albeit in a much more complex way.
Now that you know what abstraction is, the next question will be how is abstraction implemented in computers. I bet you can’t wait to know. Well, you don’t have to wait any longer. The basic way abstraction is implemented in computers is through character encoding.
Character encoding
This is the representation of human-readable characters in binary form. One of the foremost character encoding standards is the American Standard for Code and Information Interchange or ASCII. ASCII utilizes a table in converting numbers, alphabets and some symbols to binary. ASCII converts supported symbols, characters and numbers to a decimal whole number. For instance, in the picture of the ASCII conversion table below uppercase letter "A" is represented as 65 while the lowercase letter "a" is represented as 97. This decimal can further be converted to binary.
The great thing with ASCII is that we only need 127 values of the possible 256. Okay, let me explain this. ASCII uses 1 byte of memory space to store a character. From elementary class, we know 1 byte equals 8 bits. A bit is the smallest unit of memory and takes up two possible values, 1 or 0. In the same vein, 1 byte will take up possible values of 2 to the 8th power (256) values. So, out of the 1 byte for character representation You can see ASCII representations takes less memory space. It’s a great thing yeah?
For a long time, we used ASCII but it has its deficiency and eventually, we agreed it was just not good enough. Some of its deficiencies are that not enough symbols, characters and languages are covered. The most prevalent character encoding today is the Unicode UTF-8. UTF-8 allows characters to be stored in more than 1 byte. This gives more possibilities and allows more characters, symbols, languages and even emoji to be represented.
So character encoding allows us to communicate with computers in 1s and 0s while we use our keyboards and mice as whatever we entered is converted to a series of 1s and 0s. But why do we have to communicate in 1s and 0s? What exactly do we mean by 1s and 0s? Do you have any of these questions in mind? Let’s get to it right away then.
It is important to convert instructions to 1s and 0s (binary). Remember the computer is an electronic device and it consists of electronic components. One of which is called a transistor. The word 'transistor' is coined from transfer and resistance. Transistors help the computer to pass and receive current flow within its components. A computer has billions of transistors for this purpose. Instructions sent into the computer are broken down into either sending voltage or not sending voltage it. This is represented as 1 or 0 respectively. This makes it easy to communicate with computers. Using ASCII for example, we can convert instructions to binary and the computer takes this instruction and determine whether to send voltage or not and where to send it. This is how it works in its simplest form but computers deal with more complex instructions requiring them to send lots of voltage across billions of transistors at once. This can become chaotic if not properly managed. Thanks to logic gates, computers can manage this.
Logic gates allow transistors to do more complex tasks like deciding where to send electrical signals depending on logical conditions. The output of the gates is the result of applying the conditions to the input. Logic gates usually work at two levels of voltage - positive level (1) and zero level (0) i.e. ON and OFF respectively. The ON state ranges from 3.5v - 5v while the OFF state, you already know is 0. The common types of logic gates include AND logic gate, OR logic gate, NOT logic gate, etc. You can read more on logic gates here.
Now that we know how computers take instructions and how the instructions get translated into the language computers understand (ON and OFF). Let's go further to knowing how these instructions get executed. I will like us to begin with how power gets into the computer in the first place, power supplies.
To get our computers to work, we give them power. Computers have a power supply component that converts electricity from the wall into a form the computer can use. Let me explain, there are two forms of electricity, DC or direct current which flows in a single direction and AC or alternating current which constantly changes direction. Computers use DC, so it has to first convert the AC from our walls into a low voltage DC power that can be transmitted throughout the computer. The power supply connects to the motherboard. The motherboard is the foundation that holds the computer together. It routes power from the power supply and allows different parts of the computer to communicate with each other. So instructions are sent around the computer motherboard by transistors and logic gates. The CPU communicating heavily with the RAM is constantly taking instructions and executing them. I know you're itching to know how instructions move around components like RAM, CPU, etc. Let's get to it right away then.
Let me introduce you to what is called EDB or External Data Bus. It's not exactly a bus obviously. It's a row wire that interconnects parts of the computer. When voltage is sent to one of the wires, the state of the wire is ON and otherwise OFF. Can you recall what helps to send the voltage? You're right transistors. Transistors in the motherboard send voltage (bits) around the computer. EDB comes in different sizes 8bits, 16bits, 32bits and 64bits. Imagine having 64 wires running this transportation. It will be super fast right?
Inside the CPU, we have what are called registers. Registers let us store data that our CPU works with. Programs are copied into the RAM for the CPU to read. RAM is randomly accessed which allows the CPU to read data from RAM as quickly as any other part.
Important to know that we don't actually send data from RAM via EDB. There will be far too much data that can overwhelm EDB. We can only send one line of data through EDB at a time. We need the help of a component called Memory Controller Chip (MCC). MCC is a bridge between RAM and CPU. Think of it as a nerve in the brain connecting memories. MCC takes the data and sends it through the EDB to the CPU. There is another bus called Address Bus which connects the CPU to the MCC. It takes the address and looks for the data and then the data is sent over the EDB. It's important to note that RAM isn't actually the fastest way the CPU gets data for processing. The CPU also uses what's called cache. Cache is smaller than RAM but it lets us store copies of data frequently used, thereby reducing the average cost (time or energy) required to access data from main memory or RAM. Cache is located closer to the processor core.
We have known how data moves around for execution. But something is amiss. How does the CPU know when a set of instructions ends and new ones begin? CPU has an internal clock that keeps operation in SYNC. It connects to a special wire called a clockwire. When you send or receive data, the internal clock sends a voltage to that clockwire to let the CPU knows it can start doing calculations. Think of clockwire as a ticking clock. For every tick, the CPU does one cycle of operation which is referred to as a clock cycle. Every instruction sent to the CPU is broken down into billions of small instructions that the CPU has in its instructions set like addition, subtraction, etc. CPUs can run billions of cycles in a second. Instruction sets are pieces of code hard-coded into the CPU. It's the list of instructions the CPU can run. Applications as big as Facebook or Google are just billions of instructions simple enough to be run by the CPU instruction set.
We can now see how the CPU handles execution using its hard-coded instruction set. With that, we have virtually gone through how instructions get into the computer in form of voltage and how they are executed by discussing the hardware involved. There's a software that's worthy of discussion, the operating system.
The operating system or OS is the whole package that manages our computer resources and lets us interact with them. There are two main parts of an OS, the kernel and the user space. The kernel is the main core of an OS. It has three main functions; file storage and file management, process management, and memory management. User space allows us to interact with our computers. When we interact with our OS, we want to do things like create files and folders, open applications, delete items and so on. We interact with OS through a shell. A shell is a program that exposes to a user(s) or another program (s). There are two kinds of shell, graphical user interface (GUI) and command line interface. GUI is easier to use and popular as it's adopted by popular operating systems like Microsoft Windows. CLI is similar to GUI but uses text commands to send instructions to the OS. Below is a picture of a Windows GUI.
And here we have a picture of a typical CLI environment.
I hope you find this interesting. If you do, comment and bookmark this page. I write about computers and engineering and you don't want to miss out.