Logic gates
logic gateCircuit components which take several inputs, compare the inputs with each other, and provide a single output based on logical functions such as AND, OR and NOT. are contained within an integrated circuit (IC)A small circuit that is packaged inside a chip case..
The IC:
- usually has 14 legs, or pinThe pins on an integrated circuit appear in two rows and are manufactured as dual in line (DIL) packages.
- is relatively cheap to buy
- works within a range of voltages, usually between 3 and 15 volts (V)
Logic gates are used to make decisions so that electrical outputs only ‘turn on’ when the correct logic sequenceThe way that logic gates are connected. has been applied. Each logic gate has a name that helps to describe how different inputThe place where a force enters a system. will determine the possible outputThe part of a circuit that acts, eg lights up or makes a sound.. To fully understand how a logic gate works, the table of logic possibilities needs to be studied. This table is called a truth tableA table to list the output for all possible input combinations into a logic gate. and is used when planning and designing which logic gates to use.
The three logic gates to learn about first are:
| ‘AND’ | If inputs A and B are high, output Q will be high |
| ‘OR’ | If inputs A or B, or A and B are high, output Q will be high |
| ‘NOT’ | If input A is ‘high’ then output Q will be ‘low’, and if input A is ‘low’ then output Q will be ‘high’ |
| ‘AND’ |
| If inputs A and B are high, output Q will be high |
| ‘OR’ |
| If inputs A or B, or A and B are high, output Q will be high |
| ‘NOT’ |
| If input A is ‘high’ then output Q will be ‘low’, and if input A is ‘low’ then output Q will be ‘high’ |
Truth table for an ‘AND’ gate:
A ‘1’ in a truth table represents where the input or output is ‘high’, eg where a switch is pressed or a lamp is lit. A ‘0’ represents the opposite, eg where a switch is not pressed or a lamp is not lit.
| A | B | Q |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| A | 0 |
|---|---|
| B | 0 |
| Q | 0 |
| A | 0 |
|---|---|
| B | 1 |
| Q | 0 |
| A | 1 |
|---|---|
| B | 0 |
| Q | 0 |
| A | 1 |
|---|---|
| B | 1 |
| Q | 1 |
Truth table for an ‘OR’ gate:
| A | B | Q |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
| A | 0 |
|---|---|
| B | 0 |
| Q | 0 |
| A | 0 |
|---|---|
| B | 1 |
| Q | 1 |
| A | 1 |
|---|---|
| B | 0 |
| Q | 1 |
| A | 1 |
|---|---|
| B | 1 |
| Q | 1 |
Truth table for a ‘NOT’ gate:
| A | Q |
| 0 | 1 |
| 1 | 0 |
| A | 0 |
|---|---|
| Q | 1 |
| A | 1 |
|---|---|
| Q | 0 |
These three can then be used to make others:
- ‘NAND’ - an ‘AND’ gate combined with a ‘NOT’ gate
- ‘NOR’ - an ‘OR’ gate combined with a ‘NOT’ gate
- ‘XOR’ (or ‘eXclusive OR’) - a variation on the ‘OR’ gate, if the two inputs to an ‘OR’ are both ‘high’ then their output from the ‘OR’ gate will be ‘high’ too, but with an ‘XOR’ gate the output would be low if both inputs are ‘high’
If a ‘NOT’ gate is added to the output of an ‘AND’ or ‘OR’ gate then the output of these new gates will be the opposite of the original ‘AND’ or ‘OR’ gate.
Logic gates can be combined in many ways. To work out what the final output will be, the truth tables must be used to track the outputs and inputs along the combination of logic gates, like working out a puzzle.