The logic gates are the basic building blocks of digital systems. They provide the most simple operations on binary signals. With a combination of multiple logic gates, you can build complex circuits e.g. adders, comparators, encoders/decoders, timers, multiplexers, etc. Here are the logic gates that we are going to work with (you can see the schematic diagrams of the gates and their truth table) :
The NOT gate
The most simple logic gate, the inverter will flip the value of the bit at the input pin (left pin on the picture above). Imagine you have a light connected to a N.O. (Normally Open) push button, when you press the button, the light will turn on. If you connect the light to a N.C. (Normally Closed) push button, the light will always be on unless you press the button. With an inverting gate, you could easily change the behavior of an N.O. contact into a N.C contact and vice versa.These gates are used to make logical equations. For the AND gate, all the inputs have to be on for the output to come on. Example : if button A is pressed AND button B is pressed, the LED will light up. For the OR gate, one of the inputs have to be on for the output to come on. Example : if button A is pressed OR button B is pressed, the LED will light up.
The AND - OR gate
The XOR gate
The XOR logic gate serve a special purpose : when you look at it's truth table you realize that the output is on only when the inputs bits are not the same. This gate is then used to detect if there is an inequality of the input bits. The XOR gate is also used to compute the sum (S) of a one-bit adder. S being the sum, C being the carry bit :
0 + 0 : S = 0, C = 0
0 + 1 : S = 1, C = 0
1 + 0 : S = 1, C = 0
1 + 1 : S = 0, C = 1
From the following equations can you see that S = A XOR B and C = A AND B? Here is the schematic of the one-bit adder.
In the second part of this tutorial, we're going too see how simple logic gates can be made with Bipolar Junction Transistors (BJTs).