GCSE Computer Science/Logic gates
Logic gates are the basic building blocks of any digital system. It is a circuit having one or more than one input and only one output. There are four main types of gate; NOT, AND, OR and XOR. There are also three gates which are the inverse of one of the main gates; NAND, NOR and XNOR. These inverse gates are the equivalent of the main gate type followed by a NOT.
Truth Tables
[edit | edit source]
Specification link - Draw truth tables and recognise a logic gate from its truth table |
A truth table shows all of the possible inputs and outputs for a logic circuit. The example below is for a NOT gate. It shows that if the input is a 1 then the output is a 0 and vice-versa.
IN | OUT |
---|---|
0 | 1 |
1 | 0 |
Gate Types
[edit | edit source]
Specification link - Understand and define the functions of NOT, AND, OR, NAND, NOR and XOR (EOR) gates, including the binary output produced from all the possible binary inputs |
NOT
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Logic-gate-inv-us.png/220px-Logic-gate-inv-us.png)
A NOT gate will invert, or flip, any input. If the input is a 1 then it will output a 0 and vice-versa.
A | Y |
---|---|
0 | 1 |
1 | 0 |
AND
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Logic-gate-and-us.png/220px-Logic-gate-and-us.png)
An AND gate will return a 1 if, and only if, both of the inputs were a 1. If either, or both, inputs are a 0 then the output will also be 0.
A | B | Y |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
OR
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Logic-gate-or-us.png/220px-Logic-gate-or-us.png)
An OR gate will return a 1 if either, or both, of the inputs are a 1. It will only return a 0 if both inputs were a 0.
A | B | Y |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
XOR
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Logic-gate-xor-us.png/220px-Logic-gate-xor-us.png)
The XOR gate will return a 1 if either, but not both, of the inputs are a 1. If both, or neither, input is a 1 then it will return 0.
A | B | Y |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
NAND
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Logic-gate-nand-us.png/220px-Logic-gate-nand-us.png)
The NAND gate is the opposite of an AND gate.
A | B | Y |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
NOR
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/1/15/Logic-gate-nor-us.png/220px-Logic-gate-nor-us.png)
The NOR gate is the same as an OR followed by a NOT, so is the inverse of an OR gate.
A | B | Y |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
XNOR
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Logic-gate-xnor-us.png/220px-Logic-gate-xnor-us.png)
The XNOR gate is the same as an XOR followed by a NOT, so is the inverse of an XOR gate.
A | B | Y |
---|---|---|
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Logic Circuits
[edit | edit source]
Specification link - use logic gates to create electronic circuits |
A logic circuit is an electronic circuit which includes one or more logic gates. Below is an example of a logic circuit together with its logic table:
![](http://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/254px_3gate_XOR.jpg/220px-254px_3gate_XOR.jpg)
A | B | A AND B | A OR B | Q |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 0 |
1 | 0 | 0 | 1 | 0 |
1 | 1 | 1 | 1 | 1 |