Computer ScienceExam code: 0984

Boolean Logic and Expressions

Boolean Logic

Given a circuit, the safest method is to label each gate's output with its Boolean sub-expression, working from the inputs through to the final output.

Method. (1) Identify each gate and the signals feeding it. (2) Working left to right, write the output of each gate as a Boolean sub-expression using its input labels. (3) Use that sub-expression as the input to any gate it feeds. (4) The final gate's output is the expression for Q.

A circuit to work through: label the OR gate's output P, and the following NOT gate then gives the final output Q.

Logic circuit with inputs A and B feeding an OR gate whose output is labelled P, P then feeding a NOT gate whose output is labelled Q, illustrating how to label each gate's output while writing the expression for Q.
Source: Logic Expressions by Save My Exams

Common exam question

Writing a logic expression for a circuit

Question: Write a logic expression for the logic circuit shown, without simplifying it (3–4 marks).

Asked in 2 of the 17 papers, both on Paper 2. Work from the inputs to the output: write each gate's output as a sub-expression (in brackets for a two-input gate) and carry it into the gate it feeds. Write it in words (NOT, AND, OR, NAND, NOR, XOR), as both mark schemes do.

The marks build up with the expression: one for each piece as the gates join (such as the NOT on an input, then the gate that NOT feeds), and the last only for the complete expression. So copy the wiring gate for gate rather than simplifying it. One scheme accepted the two halves of the final OR either way round.

A NOT on a single input is just NOT A. A NOT after a two-input gate needs brackets, NOT (A AND B), because NOT A AND B inverts A alone.

Worked example

Writing the expression for a four-gate circuit

The logic circuit shown has inputs A, B and C and output Q. A NOT gate inverts B, and an XOR gate combines A with that NOT gate's output. An OR gate combines B and C. An AND gate combines the outputs of the XOR and OR gates to give Q. Write a logic expression for Q without simplifying it.

Logic circuit with inputs A, B and C on the left and output Q on the right. B branches at a junction dot: one line goes to a NOT gate, the other to an OR gate that also takes C. A and the NOT gate's output feed an XOR gate. The XOR gate and the OR gate feed an AND gate whose output is Q.

Solution:

  • Gate 1, the NOT gate on input B, gives NOT B. It inverts a single letter, so it needs no brackets.
  • Gate 2, the XOR gate, takes A and the output of gate 1: (A XOR NOT B)
  • Gate 3, the OR gate, takes B and C: (B OR C). B is drawn once on the left and branches to gates 1 and 3.
  • Gate 4, the AND gate, joins gates 2 and 3, so Q = (A XOR NOT B) AND (B OR C)

Four gates give four operators (NOT, XOR, OR and AND), a quick check that no gate has been missed.

Quick check

3 short questions on this note. See what has stuck, and where to look if something hasn't.

About 1 minute

Build on this topic