CIE AS & A Level Computer Science, section 3.2 (Logic gates and logic circuits)
Logic gates
A logic gate takes one or more binary inputs (0 or 1) and produces one output according to a rule. All gates except NOT have two inputs in this course.
The six gates
| Gate | Function | Output is 1 when |
|---|---|---|
| NOT | inverts the input | the input is 0 |
| AND | both inputs | both inputs are 1 |
| OR | either input | at least one input is 1 |
| NAND | NOT AND | not both inputs are 1 |
| NOR | NOT OR | both inputs are 0 |
| XOR (EOR) | exclusive OR | the inputs are different |
Truth tables
For two inputs and :
| AND | OR | NAND | NOR | XOR | ||
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
NOT: input 0 gives 1, and input 1 gives 0.
Symbols
The standard shapes are: AND has a flat back and rounded front, OR has a curved back and a pointed front, NOT is a triangle, and NAND, NOR and the NOT gate have a small circle (bubble) on the output. XOR is an OR shape with an extra curved line at the input side.
Writing gates in text
Boolean expressions use: or , or , and or .
Common mistake: mixing up XOR and OR. For the input 1, 1 the OR gate gives 1 but the XOR gate gives 0. Also, NAND and NOR are the opposite of AND and OR, not "AND with a different input".
Exam tip: learn all six truth tables. Complete a truth table row by row, and check each gate carefully. Draw the output bubble on NAND, NOR and NOT symbols.
Check yourself
What is the output of an XOR gate when both inputs are 1?
For which inputs does a NOR gate output 1?
Only when both inputs are 0.