Logic gates are devices that take in one or more binary values as inputs and produces a single binary value as output.
They can be connected together to construct more complex devices such as:
Inputs | Output | |
---|---|---|
A | B | C |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Now let's begin with the most popular gate, the AND gate. you've most likely heard about it before, and maybe wondered, why is it called an AND gate? well, you probably didn't wonder about that, but assuming you did. it's called that because it outputs a 1 only when both its inputs are a 1. in other words, C will be 1 if and only if both A and B are 1.
For further information consider reading the AND gate wikipage
Inputs | Output | |
---|---|---|
A | B | C |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Now that we're done with the AND gate, it follows that there an OR gate. Okay, so why is it called an OR gate? yep you've guessed it, because it outputs a 1 when either its inputs are a 1. in other words, C will be 1 if either A or B are 1.
For further information consider reading the OR gate wikipage
Inputs | Output | |
---|---|---|
A | B | C |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Alright now we're upping the difficulty a bit, but don't get cold feet yet. Now, let's talk about the XOR gate. which is like OR gate's cousin, its truth table differs from OR gate's by a single row, it outputs a 1 when either its inputs are a 1. in other words, C will be 1 if and only if either A or B are 1 but not both.
For further information consider reading the XOR gate wikipage