What are logic gates? How do you record the results? And what is Boolean logic?
The NOT gate
The NOT gate is the most simple, only requiring one input for it to work.
Truth Tables
The results from a gate are represented in a Truth table:
A | Q |
0 | 1 |
1 | 0 |
A NOT gate produces the opposite outcome when applied. So when A is 0, the outcome (Q) is 1 and vice versa.
The AND gate
The AND gate is the second most simple gate.
A | B | Q |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
For an AND gate to produce an outcome of 1, both A AND B must be 1.
The NAND gate
The NAND gate is the opposite of an AND gate.
A | B | Q |
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Each output will be the opposite of the AND gate.
The OR gate
The OR gate will produce an output of 1 if A OR B is 1.
A | B | Q |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
The output is 0 only when A AND B are 0.
The NOR gate
The NOR gate is the opposite of the OR gate.
A | B | Q |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
The only output to be 1 is when A AND B are 0.
The XOR gate
XOR means ‘Exclusive OR’.
A | B | Q |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
The XOR will only produce an output of 1 when A OR B are 1 NOT when A AND B are 1.
The XNOR gate
The XNOR gate is the opposite of the XOR gate.
A | B | Q |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
The XNOR gate has similar results to an AND gate except for when A AND B are 0 the output is 1.
Boolean Logic
Boolean logic is practically binary; with two results: True or False.
Some examples:
Is ABC an integer?
The answer would be False.
Is 123 an integer?
The answer would be True.
A more practical use for this can be seen in programming codes like python:
Basically this is asking a simple question: Is a <= 10?
If yes, then print the value of a and add 1
If no, then end the code.
This is using a simple True and False scheme. So while a is smaller than 10, the result is ‘True’ and when a is larger than 10 the result is ‘False’
If you want to test any logic gates simply go to logic.ly and use their software! I’d recommend using this if you get confused by all the truth tables!