Learn
A1.2.3 | PURPOSE AND USE OF LOGIC GATES
01 | HARDWARE CAN APPLY A SIMPLE RULE
A lamp should switch on when movement is detected and the room is dark. A status light should show whether two input flags disagree. Both examples need a rule that turns input states into an output state.
A logic gate is a digital circuit that applies a Boolean operation to its input or inputs and produces an output. Boolean logic has two values, commonly represented as 0 and 1, or FALSE and TRUE.
A physical circuit uses voltage ranges interpreted as logical states. A logic 1 is not a universal fixed voltage for every technology, and 0 does not mean there is no electricity anywhere in the computer.
Logic gates provide building blocks for larger digital circuits, including arithmetic and control functions. This lesson introduces NOT, AND, OR, NAND, NOR, XOR and XNOR, using one-input NOT and two-input versions of the other gates.
02 | DEFINE WHAT EACH INPUT MEANS
Let A mean “movement detected” and B mean “room is dark”. A = 1 means movement is detected; B = 0 means the room is not dark. A 1 is not automatically “safe” or “correct”: its meaning comes from the definition.
Let X be the output command, with X = 1 meaning “turn the lamp on”. Choosing X = A AND B connects the situation to a precise logical rule.
A gate does not understand movement or darkness. Other circuitry supplies the input states, and the gate combines them according to its function. The interpretation belongs to the system design.
Before tracing a circuit, write down the inputs and output. That stops you accidentally treating an obstacle-detected signal as if 1 meant no obstacle.
03 | READ THE SYMBOL BEFORE THE TABLE
In the diagrams here, signals enter from the left and output X leaves on the right. A wire carries a logical state between components. The shape identifies the operation; a small circle, often called an inversion bubble, means the signal is inverted at that point.
A triangle followed by an output bubble represents NOT. A D-shaped body represents AND. A curved OR body represents OR. An extra curved line at the input side distinguishes XOR from OR. Adding an output bubble gives the complemented form.
Different symbol conventions exist, including rectangular IEC symbols. This page consistently uses the distinctive gate shapes so you can learn to recognise the features. The Boolean function, not the drawing’s decorative size or colour, determines the result.
Compare AND and NAND above: the output bubble changes the result. It is not an extra input or a decorative dot.
04 | NOT: REVERSE ONE INPUT
NOT has one input and gives its opposite. If A = 0, X = 1. If A = 1, X = 0. This is also called inversion.
If A means “door open”, NOT A means “door not open”. The gate reverses the truth of the input proposition; it does not physically close the door.
Write the relationship as X = NOT A or X = ¬A. There is no second input B for this gate.
| A | X = NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
05 | AND: BOTH CONDITIONS MUST BE TRUE
For a two-input AND gate, the output is 1 only when both inputs are 1. One true condition on its own is not enough.
For the movement-and-darkness lamp, A = 1 and B = 0 gives X = 0. There is movement, but the room is not dark. Only A = 1 and B = 1 produces an on command.
Write X = A AND B, or X = A ∧ B. Some notation uses a dot for AND. Treat it as a Boolean operation, not a general claim about adding numerical values.
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
06 | OR: AT LEAST ONE CONDITION IS TRUE
A two-input OR gate outputs 1 if either input is 1, including when both are 1. This is inclusive OR. It is false only when both inputs are 0.
A simple indicator might turn on if either of two sensors reports an active condition. If both report it, the OR output remains 1. It does not turn off merely because there are two true inputs.
Write X = A OR B, or X = A ∨ B. Some Boolean notation uses +, but 1 OR 1 is 1, not the arithmetic result 2.
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
07 | NAND AND NOR: INVERT THE RESULT
NAND means NOT of the AND result: X = NOT (A AND B). Work out AND first, then invert its output. The only input pair giving NAND = 0 is 1,1.
NOR means NOT of the OR result: X = NOT (A OR B). Work out OR first, then invert. NOR = 1 only when both inputs are 0.
The parentheses show the group being inverted. NOT (A AND B) is not the same expression as (NOT A) AND B. An output bubble on the gate applies to its whole result.
NAND and NOR are also useful building blocks: with suitable connections, either type can be used to construct other Boolean functions. You do not need every gate type as a separate component to build all combinational functions.
| A | B | AND | NAND | OR | NOR |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 | 0 |
08 | XOR AND XNOR: DIFFERENT OR THE SAME?
A two-input XOR gate gives 1 when the inputs differ. That means exactly one input is 1. Unlike OR, XOR gives 0 when both inputs are 1. XOR is exclusive OR and may also be called EOR.
A two-input XNOR gate is the complement of XOR. It gives 1 when the inputs are equal: both 0 or both 1. Equality here does not mean they must both be true.
XOR can indicate a mismatch between two single-bit flags. XNOR can indicate a match. XOR is also used as part of an addition circuit: for two single-bit inputs, it produces the sum bit while AND produces the carry bit.
For 1 + 1, the sum bit is 0 and the carry bit is 1, giving binary 10. That illustrates how gates contribute to arithmetic without claiming XOR alone is a complete multi-bit adder.
| A | B | OR | XOR | XNOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 1 | 0 | 1 |
The “exactly one” rule here is for two inputs. Wider XOR arrangements have parity behaviour, so do not extend the two-input wording to every possible number of inputs without checking the definition.
09 | TEST A GATE AND FOLLOW THE ACTIVE ROW
Choose a gate, then click the input buttons. Read the rule, predict the output, and check the highlighted truth-table row. A truth table records the output for each possible input combination.
NOT ignores no hidden second condition: it has only one input. The B button is disabled and its column removed when NOT is selected. Other gates here have two inputs.
10 | CONNECTING GATES: NAME THE INTERMEDIATE OUTPUTS
A gate’s output can become an input to another gate. To trace a combined circuit, label each intermediate result and evaluate it before using it in the next operation.
Consider X = (A OR B) AND (NOT C). Let A mean “room is dark”, B mean “manual lamp request” and C mean “lamp disabled”. The lamp is requested by either A or B, but the final command is permitted only when C is false.
Call the OR result P and the NOT result Q. First calculate P = A OR B. Then Q = NOT C. Finally calculate X = P AND Q. The brackets and connections specify the intended grouping.
| Inputs | P = A OR B | Q = NOT C | X = P AND Q |
|---|---|---|---|
| A = 0, B = 1, C = 0 | 1 | 1 | 1 |
| A = 1, B = 1, C = 1 | 1 | 0 | 0 |
| A = 0, B = 0, C = 0 | 0 | 1 | 0 |
11 | TRY THE COMBINED LAMP RULE
Change the three input states and follow both intermediate outputs. C = 1 must make Q = 0, so the final AND output is 0 even if A or B is 1.
This is an ideal Boolean teaching model. It does not model electrical timing, analogue thresholds or the hardware required to drive a lamp.
12 | HOW GATES CONTRIBUTE TO COMPUTING
Combining gates creates circuits for functions such as comparing bit patterns, selecting between data inputs and performing arithmetic. The ALU studied earlier contains circuits that implement arithmetic and logical operations.
For example, a two-bit-input sum needs both a sum bit and a carry bit. XOR and AND provide those outputs in a simple half-adder. Handling an incoming carry requires further logic; larger additions combine suitable circuits.
Circuits that combine current inputs to determine outputs are called combinational logic. Storage and sequential circuits add state, so not every digital circuit can be fully described as depending only on its current external inputs.
In a physical implementation, outputs take time to settle after an input changes. The truth tables here describe the intended logical relationships, not an assertion that every real gate responds with zero delay.
13 | GATE RULES AT A GLANCE
| Gate | Inputs used here | Output is 1 when… | Expression |
|---|---|---|---|
| NOT | One | The input is 0. | X = NOT A |
| AND | Two | Both inputs are 1. | X = A AND B |
| OR | Two | At least one input is 1. | X = A OR B |
| NAND | Two | The inputs are not both 1. | X = NOT (A AND B) |
| NOR | Two | Both inputs are 0. | X = NOT (A OR B) |
| XOR | Two | The inputs differ. | X = A XOR B |
| XNOR | Two | The inputs are equal. | X = NOT (A XOR B) |
A useful comparison is the 1,1 input pair: OR gives 1, XOR gives 0, AND gives 1 and NAND gives 0. For 0,0, XNOR gives 1 even though neither input is true.
These comparisons test the rule more effectively than memorising “this gate means yes”. The bit values need input definitions and the operator needs its precise Boolean meaning.
14 | DESCRIBE THE PURPOSE, THEN USE THE RULE
For describe the purpose and use of a logic gate, identify the Boolean operation, say when it produces each output and connect it to an example. Include the symbol or an expression when helpful.
For AND: “The gate gives 1 only when both input conditions are true, so it can combine a movement signal and a darkness signal for a lamp command.” For XOR: “It gives 1 when the two bits differ, so it can indicate a mismatch.”
Common mistakes are treating OR as exclusive, saying XNOR needs both inputs to be 1, overlooking an inversion bubble or applying NOT to the wrong group. Evaluate intermediate signals rather than trying to guess a whole circuit at once.
The next lesson develops constructing and analysing truth tables. You already have the gate rules needed to list and interpret those combinations.
Further reading: physical logic gate families · Gate functions and circuit examples