Computer ScienceExam code: 0984

Logic Gates and Circuits

Boolean Logic

For longer questions the examiner gives a logic expression or a circuit and asks for the truth table for every input combination. The cleanest method is to add one column per gate in the order the signals flow, then fill in the table row by row.

Method. (1) Write down every input combination (2ⁿ rows). (2) In the working space beside the table, add an intermediate column for each internal gate, named after its sub-expression (A AND B) or numbered (Gate 1, Gate 2). (3) Fill in each intermediate column by applying the gate's rule to its input columns, row by row. (4) The final-output column Q is built from whatever feeds the last gate, using its rule.

Common exam question

Completing a truth table

Question: Complete the truth table for a given logic expression, logic circuit or worded problem with three inputs (4 marks).

Asked in 8 of the 17 papers, always for 4 marks: five times from an expression, twice from a circuit, once from a worded problem. The eight input rows are printed in binary order (beside a working space, except in the worded problem), and only the output column is marked: eight correct outputs earn 4, six or seven 3, four or five 2, two or three 1. Intermediate columns earn nothing, so keep them in the working space to stop slips.

When the table follows a part asking you to draw the circuit or write the expression, work from what the question printed, not from your own answer. For a worded problem, read each input's 0 and 1 from the key: an input goes through a NOT only when the condition needs it to be 0 (off, or not happening).

Worked example

Completing the truth table for a multi-gate circuit

The logic circuit shown has three inputs, A, B and C, and one output, Q. An AND gate combines A and B, a NOT gate inverts C, and an OR gate combines those two results to give Q. Complete the truth table.

Logic circuit with inputs A, B and C on the left: A and B feed an AND gate, C feeds a NOT gate, and the outputs of the AND gate and the NOT gate feed an OR gate whose output is labelled Q on the right.

Solution:

In the working space, add one column per gate (A AND B and NOT C), then work out Q row by row.

ABCA AND BNOT CQ
000011
001000
010011
011000
100011
101000
110111
111101
  • A AND B is 1 only in the final two rows, where both A and B are 1.
  • NOT C is 1 whenever C is 0 (rows 1, 3, 5 and 7) and 0 whenever C is 1.
  • Q is 1 whenever at least one of those two values is 1, and 0 only where both are 0.
  • So Q is 0 in rows 2, 4 and 6 and 1 in the other five rows.

Only the Q column is marked, so copy it into the printed table and leave the working columns in the working space.

Worked example

Completing a truth table from a problem statement

A garden sprinkler S comes on when the soil is dry and it is not raining, or whenever the manual override is switched on. The signals are coded like this:

Signal01
Soil Dmoistdry
Rain Rnot rainingraining
Override Moffon
Sprinkler Soffon

Complete the truth table for this problem.

Solution:

  • Turn each condition into a value from the key: soil dry is D = 1, not raining is R = 0 (so R goes through a NOT), and override on is M = 1.
  • That gives S = (D AND NOT R) OR M, worked with one extra column for the bracket.
DRMD AND NOT RS
00000
00101
01000
01101
10011
10111
11000
11101
  • Every row with M = 1 gives S = 1; when M = 0, S is 1 only where D = 1 and R = 0.
  • So S is 1 in rows 2, 4, 5, 6 and 8 and 0 in rows 1, 3 and 7.

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