10.2 The function of the six logic gates

← Topic 10.1 Standard logic gate symbolsComputer Science contentsTopic 10.3 Logic circuits, logic expressions, truth tables and problem statements →
Chapter 10 · Boolean logic

10.2 The function of the six logic gates

Each standard logic gate follows a precise rule for turning binary input values into a binary output. This topic covers the function, truth table and notation for all six gates: NOT, AND, OR, NAND, NOR and XOR.

NOTANDORNANDNORXORTruth tables

10.2.1 NOT gate

A NOT gate has one input. It reverses, or inverts, the input value.

Rule: the output X is 1 if input A is 0. Therefore, if A is 1, X is 0.
Figure 10.2 from the textbook showing the NOT gate symbol
Input AOutput X
01
10
Logic notation: X = NOT A
Boolean algebra: X = A

The NOT gate is the only one of the six standard gates in this topic with a single input. Its output is always the opposite binary value from its input.

Check the NOT gate.

10.2.2 AND gate

An AND gate has two inputs. Its output is 1 only when both inputs are 1.

Figure 10.3 from the textbook showing the AND gate symbol
Input AInput BOutput X
000
010
100
111
Logic notation: X = A AND B
Boolean algebra: X = A · B

A quick way to remember the rule is that an AND gate requires all its inputs to be 1 before the output can become 1.

Check the AND gate.

10.2.3 OR gate

An OR gate has two inputs. Its output is 1 when either input is 1, or both inputs are 1.

Figure 10.4 from the textbook showing the OR gate symbol
Input AInput BOutput X
000
011
101
111
Logic notation: X = A OR B
Boolean algebra: X = A + B

Only the input combination 0, 0 produces an output of 0. Every other two-input combination produces 1.

Check the OR gate.

10.2.4 NAND gate (NOT AND)

A NAND gate is the opposite of an AND gate. The name comes from NOT AND.

Rule: output X is 1 when inputs A and B are not both 1. It becomes 0 only when A = 1 and B = 1.
Figure 10.5 from the textbook showing the NAND gate symbol
Input AInput BOutput X
001
011
101
110
Logic notation: X = A NAND B
Boolean algebra: X = A · B

Compare this table with the AND table: every output has been inverted.

Check the NAND gate.

10.2.5 NOR gate (NOT OR)

A NOR gate is the opposite of an OR gate. The name comes from NOT OR.

Rule: output X is 1 only when neither input A nor input B is 1. In other words, both inputs must be 0.
Figure 10.6 from the textbook showing the NOR gate symbol
Input AInput BOutput X
001
010
100
110
Logic notation: X = A NOR B
Boolean algebra: X = A + B

Compare this with OR: each OR output is reversed. NOR gives 1 only for 0, 0.

Check the NOR gate.

10.2.6 XOR gate

An XOR gate has two inputs. Its output is 1 when the two input values are different.

Rule: X = 1 when A = 1 and B = 0, or when A = 0 and B = 1.
Figure 10.7 from the textbook showing the XOR gate symbol
Input AInput BOutput X
000
011
101
110
Logic notation: X = A XOR B
Boolean algebra: X = (A · B) + (A · B)
Alternative shown in the source: X = (A + B) · (A · B)

This gate differs from OR at the 1, 1 row. OR outputs 1 when both inputs are 1; XOR outputs 0 because XOR requires the two inputs to be different.

Activity 10.1 idea: two expressions for XOR

The source asks you to show that these two logic statements represent the same gate:

Both produce 1 for 0,1 and 1,0, and 0 for 0,0 and 1,1. They therefore have the same truth table as XOR.

ABFirst expressionSecond expression
0000
0111
1011
1100
Check the XOR gate and its equivalent expressions.

Logic notation and Boolean algebra symbols

The textbook also introduces three Boolean-algebra symbols used alongside the logic notation:

Boolean symbolMeaningExample
·ANDA · B
+ORA + B
ANOTA
Source note: Boolean-algebra notation is included for completeness and is optional at IGCSE. You should still be able to understand the logic-gate functions and truth tables themselves.

Topic 10.2 revision checklist

State the output rule for a NOT gate and complete its truth table.
State the output rule for an AND gate and complete its truth table.
State the output rule for an OR gate and complete its truth table.
Explain that NAND is NOT AND and complete its truth table.
Explain that NOR is NOT OR and complete its truth table.
Explain that XOR outputs 1 when its two inputs are different.
Recognise the logic notation for all six gates.
Recognise the Boolean symbols for AND, OR and NOT.
Distinguish OR from XOR when both inputs are 1.
Use a truth table to show when two logic expressions are equivalent.
Ready for a mixed Topic 10.2 check?
← Topic 10.1 Standard logic gate symbolsComputer Science contentsTopic 10.3 Logic circuits, logic expressions, truth tables and problem statements →