In my last article, I explained how the binary system is the underlying concept that brought computers to life. However, the binary system alone could not do the work of our microprocessors. We need a way to make logic out of the electric signals we receive through direct current.
In electronics, there are logic gate computer chips. When I was in school at Austin Peay State University, we built a small, basic computer. It was a calculator basically.
We used breadboards and resistors, capacitors, and other electronic stuff that I didn't understand. Our purpose was to learn the logic gates, so they basically told us which resistors and capacitors to use without explaining exactly why we had to use them.
That was fine with me because I was more interested in learning about how the computer processed information, rather than the underlying electronics which made it work when you plug it in. I knew I didn't want to build computers, I just wanted to learn how to control them.
I was interested in what was happening inside the computer chips, rather than the transistors and capacitors.
We had computer chips that were called 'logic gates'. We had the following logic gates available: AND, OR, NOT, and XOR.
These 'logic gates' were computer chips with little pins on them. We put the chips in the breadboard and then put wires at the correct 'pins' on the chip to provide the direct current to the chip (a 1 - on or a 0 - off).
The chips had input pins and output pins. By providing a wire (or more) for input then the pin(s) with the output would be 'hot' or on (1). If they weren't hot, they were off (0).
The magic that happened inside that computer chip (or logic gate) depends on what type of logic gate it was: AND, OR, NOT, or XOR.
To draw out these circuits on paper, we used symbols:
The AND logic gate has two inputs to the left and one output to the right. If BOTH of the inputs are 'hot' or 'on' (1's), then the output on the right will be on. If either of the inputs are off, then the output will be off.
The OR logic gate output will be on if either of the inputs are on. If both are on, the output will also be hot, because the gate only checks to make sure that one of them is on.
The NOT logic gate only has one input and the output just reverses whatever is coming in on the input. If the input is on, then the output is off. If the input is off, then the output is on.
The XOR is like the OR except it's an EXCLUSIVE OR, meaning that one or the other of the inputs must be on, but not both.
Using these gates together in a series, meaning that we put them one after the other, wiring the output from one to the input of another, allows us to process data.
The Central Processing Unit (CPU) on your computer is made up of many tiny logic gates, among other things, which allows it to process all the input and output from the computer.
Of course this is a very simplified version of what's going on, but it's enough to get us started.
Using these gates, we can define what we call 'truth tables' to show what will happen with the different data coming in. A truth table lists all possible inputs and shows the output of each combination.
The following is the truth table for the AND. The A and B columns are the inputs and the AB column is the resulting output. So, if both A and B are off, then AB will be off. If A is on but B is off, AB is off. AB will only be on if both are on.
The easy one is the NOT. It only has one input, so it only has two options, off and on. If A is on, the NOT A would be off. The truth table is below.
Maybe a good exercise would be to do the OR and XOR truth tables on your own. If you have trouble, let me know.
The best practice I had for learning these circuits was an old computer game called Robot Odyssey.
In the game, we were given robots that we had to wire to get through mazes. We had in our toolbox these logic gates. We also had different sensors to hook to the inputs on the gates. The sensors were things like on/off switches, magic items that produced enough electricity to turn on the 'rock sensor', motion sensors, etc.
So, if our robot went into a room where something was moving, then our motion sensor would be turned on which would send a signal to whichever gate we had it hooked up to giving the desired output.
The output could be connected to devices on our robot such as thrusters which would turn on or off based on the signal coming in. If the signal coming in was on, the thruster would turn on, moving our robot in the opposite direction. It propelled us in the direction the thruster was pushing us. As soon as the thruster was turned off, the robot stopped.
To turn in different directions, we had to turn on and off different thrusters. To get through the maze, we had to determine which sensors we could use and then wire them to the correct inputs, gates, and outputs.
I thoroughly enjoyed that game and learned a LOT from it. If you are interested, you can play it now here and experience what it was like to play a computer game in 1985.
I've now given you the fascinating introduction to logic gates, computer chips and truth tables. If you have questions or comments, please leave in the comment section below.