Logic circuits and logic expressions

Computer Science · Boolean logic. 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 topics

The idea

A logic circuit is several gates joined together, where the output of one gate becomes an input of the next. A logic expression describes the same thing in writing, for example X = (A AND B) OR NOT C. You must be able to move between a problem statement, an expression, a circuit and a truth table.

From a problem statement, turn the words into operators: "and" gives AND, "or" gives OR, "not" gives NOT, "one or the other but not both" gives XOR. Use brackets to show which part is worked out first.

From a circuit, start at the inputs and write the output of each gate as you move towards the final output.

Rules to remember

Common mistake

Leaving out brackets changes the meaning: (A AND B) OR C is not the same as A AND (B OR C). Also check exactly what NOT applies to: NOT A OR B inverts only A, but NOT (A OR B) inverts the whole OR.

Worked example

A light L switches on (L = 1) when it is dark (D = 1) and either movement is detected (M = 1) or the manual switch is on (S = 1). Write the logic expression for L.

  1. "Movement or the manual switch" gives M OR S.
  2. This must be true together with darkness, so join it to D with AND.
  3. Brackets keep the OR part together: L = D AND (M OR S).
  4. Check: D = 0, M = 1, S = 1 gives 0 AND 1 = 0, so the light stays off in daylight, as required.

Answer: L = D AND (M OR S)

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

← Logic gatesTruth tables →Take a Computer Science test