Logic gates and logic circuits

Computer Science AS · Hardware. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science AS topics

The idea

A logic gate takes one or two binary inputs and gives one binary output. There are six gates to know: NOT, AND, OR, NAND, NOR and XOR. A truth table lists the output for every possible combination of inputs. With n inputs there are 2n rows.

The same logic can be shown in four ways: a problem statement in words, a logic expression, a logic circuit and a truth table. You must be able to change any one into another.

Work in small stages. Find the output of each bracket or each gate first, as an extra column, then combine these columns to get the final output.

In simpler words

A logic gate takes inputs of 0 or 1 and gives one output. AND gives 1 only if both inputs are 1. OR gives 1 if at least one is 1. NOT flips the input. A truth table lists every possible input and its output. With 2 inputs there are 4 rows. Work it out in small steps, one gate at a time.

An everyday comparison

An AND gate is like a car that starts only if the key is turned and the brake is pressed: both must be true. An OR gate is like a room light worked by two switches where either one turns it on. The comparison stops working because real switches can be half pressed or faulty, while a logic gate only ever deals with exactly 0 or 1, and gates such as XOR and NAND have no simple everyday match.

Rules to remember

Common mistake

Students apply NOT to the wrong part. NOT (A OR B) inverts the result of the OR, but NOT A OR B inverts only A. These give different truth tables.

In the exam

Draw the truth table with 2n rows, listing inputs in binary counting order so no combination is missed. Add a working column for each gate or bracket, then the final output column. When writing a logic expression from words, map 'and' to AND, 'or' to OR, 'not' to NOT, 'exactly one of' to XOR, and use brackets to show where NOT applies. For circuits, draw each gate with the correct symbol and label every input.

Worked example

In the eight-row truth table for X = (A AND NOT B) OR (B AND C), how many rows have X = 1?

  1. A AND NOT B is 1 when A = 1 and B = 0, with C either value: rows 1 0 0 and 1 0 1.
  2. B AND C is 1 when B = 1 and C = 1, with A either value: rows 0 1 1 and 1 1 1.
  3. No row is in both lists, because one needs B = 0 and the other B = 1, so the OR gives 2 + 2 = 4 rows.

Answer: Four rows have X = 1.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Computers and their componentsCentral Processing Unit (CPU) architecture →Take a Computer Science AS test