There are basic building blocks to a computer, which, like Lego bricks, can be combined in billions of different ways to make loads of different things. But unlike Lego, these building blocks don’t have to look the same. They could be links on a chain or mechanical gears or pulses of electricity. What they have in common is that they respond to different inputs in different ways.
As you may know, computers take in and give out information in a code called binary. Binary form allows any number to be represented as an arrangement of just two signals which we call 0 and 1. Different types of computers represent 0s and 1s differently: modern computers use a strong electrical pulse for 1 and a weaker one for zero. A billiard ball computer would use a billiard ball as a 1 and the absence of a ball as a zero. However it is represented, each digit within a binary number is called a ‘binary digit’ or ‘bit’.
These blocks are called gates. They take in bits as input, compare them, and output others. This seems very simple – and it is! The complexity and amazing ability of computers comes from combining them.
With a single bit, there are only two things you can do – you can leave it alone, or you can change it into the other one. Leaving it alone is easy: changing it to the opposite, or inverting it, is the most basic operation that can be performed. This is done by an operator called a NOT gate, because it outputs what 1 is NOT.
Other gates compare two input bits.
- One outputs a 1 only if the first is 1, and the second is 1. This is called an AND gate.
- Another will produce a 1 if either the first or the second is a 1. This is called an OR gate.
- The last basic gate will produce a 1 if either of the outputs is a 1, but not if they both are – it responds only to the OR situation, not the AND as well. This is called a XOR (exclusive or) gate.
These simple operators are called logic gates – they encode basic logical relationships, such as two things needing to both being true (AND gate) or only one of two things being possibly true (XOR gate).
Though they may seem too simple to be useful for much – just like Lego bricks – logic gates can be combined to make virtually anything.
Stepping up the difficulty
For example, one of the simplest arrangements allows you to add two binary numbers together. If one of those numbers represents where a computer game character is now, and the other one represents how many steps you want it to move forward, the answer will be the new location of your character!
To do more complicated things requires millions of gates with signals looping between them. But at the bottom, it’s just xors, ors, nots and ands. All computer programmers and scientists need to know about this, to know their subject from the bottom up. Some are even using these ideas to try and make completely new types of computer – ones that will use single molecules as logic gates, or ones that will be completely made of light.
You can see what happens when you connect up different logic gates here: http://logic.ly/demo/