Computer Hardware and Logic Circuits: Question 1
Syllabus 3.2
A logic gate has two inputs, P and Q, and one output, R. The truth table for the gate is shown below.
| P | Q | R |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Which logic gate has this truth table?
Show worked solution Hide worked solution
Worked solution
Reading the truth table row by row
Compare the output R against the two inputs P and Q for every row of the table:
- P = 0, Q = 0 (the same as each other): R = 0
- P = 0, Q = 1 (different from each other): R = 1
- P = 1, Q = 0 (different from each other): R = 1
- P = 1, Q = 1 (the same as each other): R = 0
The output is 1 exactly when P and Q are different, and 0 exactly when P and Q are the same. This is the defining property of the XOR (“exclusive OR”) gate.
Why the other options are wrong
- A (OR): an OR gate outputs 1 whenever at least one input is 1. For P = 1, Q = 1, an OR gate would output 1, but the table gives R = 0 for that row, so the gate cannot be OR.
- C (NOR): a NOR gate outputs 1 only when both inputs are 0 (NOR is the inverse of OR). For P = 0, Q = 0, a NOR gate would output 1, but the table gives R = 0 for that row, so the gate cannot be NOR.
- D (AND): an AND gate outputs 1 only when both inputs are 1. For P = 0, Q = 1, an AND gate would output 0, but the table gives R = 1 for that row, so the gate cannot be AND.
As a memory aid for reading circuit diagrams: the AND gate symbol has a flat back and rounded (D-shaped) front, and the OR gate symbol has a curved back and pointed front. NAND and NOR use the same AND/OR shapes but with a small circle (“bubble”) added at the output to show the result is inverted. XOR is drawn like OR but with an extra curved line just before the two inputs.
Final answer
B. The gate is an XOR gate: output R = 1 only when inputs P and Q are different from each other.