IB COMPUTER SCIENCE | A1.2.3 Logic Gates: Functions, Symbols and Uses

Lesson objective

Describe the purpose and use of logic gates, recognise their symbols and trace how connected gates apply Boolean rules to input states.

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.

ABX
AND | Two inputs in this lesson
ABX
NAND | Two inputs in this lesson

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

AX
NOT | 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.

AX = NOT A
01
10

05 | AND: BOTH CONDITIONS MUST BE TRUE

ABX
AND | Two inputs in this lesson

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.

ABX
000
010
100
111

06 | OR: AT LEAST ONE CONDITION IS TRUE

ABX
OR | Two inputs in this lesson

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.

ABX
000
011
101
111

07 | NAND AND NOR: INVERT THE RESULT

ABX
NAND | Two inputs in this lesson
ABX
NOR | Two inputs in this lesson

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.

ABANDNANDORNOR
000101
010110
100110
111010

08 | XOR AND XNOR: DIFFERENT OR THE SAME?

ABX
XOR | Two inputs in this lesson
ABX
XNOR | Two inputs in this lesson

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.

ABORXORXNOR
00001
01110
10110
11101

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.

Gate truth table

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.

Circuit for X equals A OR B, AND NOT CA and B enter an OR gate, producing P. C enters a NOT gate, producing Q. P and Q enter an AND gate producing X.ABCP = A OR BQ = NOT CX
Signals P and Q feed the final AND gate. The inversion bubble is on the C branch, not on the final output.
InputsP = A OR BQ = NOT CX = P AND Q
A = 0, B = 1, C = 0111
A = 1, B = 1, C = 1100
A = 0, B = 0, C = 0010

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

GateInputs used hereOutput is 1 when…Expression
NOTOneThe input is 0.X = NOT A
ANDTwoBoth inputs are 1.X = A AND B
ORTwoAt least one input is 1.X = A OR B
NANDTwoThe inputs are not both 1.X = NOT (A AND B)
NORTwoBoth inputs are 0.X = NOT (A OR B)
XORTwoThe inputs differ.X = A XOR B
XNORTwoThe 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

MATCH THE GATE TO ITS RULE

Terminology

Terminology

Logic gate

A digital circuit applying a Boolean rule to one or more inputs.

Boolean

Having two logical values, such as TRUE and FALSE.

Input

A logical state supplied to a gate or circuit.

Output

The logical result produced by a gate or circuit.

NOT

An operation giving the opposite of its single input.

AND

For two inputs, 1 only when both inputs are 1.

OR

For two inputs, 1 when at least one input is 1.

NAND

NOT of an AND result.

NOR

NOT of an OR result.

XOR

For two inputs, 1 when the inputs differ; exclusive OR.

XNOR

For two inputs, 1 when the inputs are equal; complement of XOR.

Inversion

Changing a logical 0 to 1 or a logical 1 to 0.

Inversion bubble

A small circle on a gate symbol indicating logical inversion.

Truth table

A table listing outputs for all combinations of the specified inputs.

Boolean expression

A notation describing logical operations and their grouping.

Intermediate signal

An output inside a circuit used by a later operation.

Inclusive OR

OR that includes the case when both inputs are true.

Exclusive OR

For two inputs, a rule true for one true input but not two.

Complement

The logical inverse of a value or function.

Combinational logic

Logic whose outputs are determined by its current input combination.

Half-adder

A circuit adding two bits to produce a sum bit and a carry bit.

Carry bit

An additional higher-place contribution from a binary addition.

ALU

Arithmetic logic unit containing circuits for arithmetic and logical operations.

Signal definition

The agreed meaning of 0 or 1 for a particular input or output.

Propagation delay

The time for an input change to affect a physical circuit’s output.

Gate symbol

A diagrammatic representation identifying a logic function and its connections.

Questions

Questions

CHECK YOUR UNDERSTANDING

Select all correct choices. Each exact set earns one point.

1. What is the purpose of a logic gate?
2. Which inputs make a two-input AND output 1?
3. Which input pairs make a two-input OR output 1?
4. Which statements about NOT are correct?
5. When does a two-input NAND output 0?
6. When does a two-input NOR output 1?
7. Which are correct for two-input XOR and XNOR?
8. Which symbol features matter?
9. For X = (A OR B) AND (NOT C), what follows when C = 1?
10. Which statements about using gates are accurate?

EXPLAIN AND COMPARE

Write your answers before revealing each sample.

1. Describe the purpose of a logic gate.

2. Describe AND using the lamp example.

3. Describe the difference between OR and XOR for two inputs.

4. Describe the effect of an output inversion bubble.

5. Describe NAND and NOR.

6. Describe XNOR and give a use.

7. Trace the combined expression for A = 0, B = 1, C = 0.

8. Explain why input definitions matter.

9. Describe a half-adder using gates.

10. Describe how to trace a multi-gate circuit accurately.

DESIGN IT | A MISMATCH INDICATOR

Two sensors produce single-bit flags A and B. Design an output X that is 1 when their states disagree. Name a suitable gate, draw its symbol and give its output for all four input pairs. Describe how you would change the design to indicate agreement instead.

Flashcards

Flashcards

Click to flip. Select the ideas you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    COMING SOON

    The workbook for A1.2.3 Logic Gates: Functions, Symbols and Uses is coming soon. Complete the matching task and written questions in your exercise book.