How do logic gates combine digital inputs to make decisions, and how do you work out the output of a combinational logic circuit?
The logic gates AND, OR, NOT, NAND and NOR with their truth tables, and analysing combinational logic circuits that combine several gates.
An SQA Higher Engineering Science answer on the logic gates AND, OR, NOT, NAND and NOR with their truth tables, and how to analyse combinational logic circuits that combine several gates to make a decision.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this key area is asking
The SQA wants you to know the logic gates AND, OR, NOT, NAND and NOR, recall their truth tables, and analyse combinational logic circuits in which several gates are connected so the output depends only on the present combination of inputs. Logic gates are the digital processing of this course, making yes/no decisions from two-state inputs.
The basic gates
The three basic gates and their two inverted forms:
- AND - output is 1 only when all inputs are 1 (think "this and that"). Output 1 in the all-high row only.
- OR - output is 1 when any input is 1 (think "this or that"). Output 0 only in the all-low row.
- NOT (inverter) - one input; output is the opposite of the input (1 becomes 0, 0 becomes 1).
- NAND - Not-AND: an AND followed by a NOT. Output is 1 except when all inputs are 1.
- NOR - Not-OR: an OR followed by a NOT. Output is 1 only when all inputs are 0.
Truth tables
For two inputs A and B there are four combinations. The table below gives all five gates (NOT acts on A alone):
| A | B | AND | OR | NAND | NOR | NOT A |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Notice the inverted columns are exactly the opposite of their base gate: NAND is the inverse of AND, and NOR is the inverse of OR. Learning AND and OR plus the rule "N means invert the output" gives you all five.
Combinational logic
You analyse a combinational circuit by working through it gate by gate: evaluate the gates nearest the inputs first, then feed their outputs into the next gates, until you reach the final output. Equivalently, write the Boolean expression for the output and substitute the input values.
Examples in context
A washing machine will only spin if the door is closed and the water has drained: that is an AND of two sensor inputs. A burglar alarm sounds if the front door or a window or the back door is opened: an OR of several inputs. A safety interlock on a machine guard often uses a NAND or combination so that the machine runs only when every guard is in place, stopping the moment any one is removed. In each case the control logic is built from a handful of gates wired as a combinational circuit, and the truth table (or Boolean expression) is the precise statement of when the output acts.
Try this
Q1. State the only input combination for which a two-input AND gate outputs 1. [1 mark]
- Cue. Both inputs high: A = 1 and B = 1.
Q2. A two-input NOR gate has inputs A = 0 and B = 0. State its output. [1 mark]
- Cue. Output 1 (NOR outputs 1 only when all inputs are 0).
Q3. Write the Boolean expression for an OR gate fed by C and by the output of an AND gate fed by A and B. [1 mark]
- Cue. Output = (A AND B) OR C.
Exam-style practice questions
Practice questions written in the style of SQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
SQA Higher (specimen)4 marksA machine should sound an alarm only when its guard is open (input A = 1) AND the motor is running (input B = 1). State which single gate is needed, give its truth table, and name the gate that gives the opposite output.Show worked answer →
The condition "A and B both 1" is an AND gate.
Truth table for a two-input AND gate (output 1 only when both inputs are 1):
A=0, B=0 gives 0; A=0, B=1 gives 0; A=1, B=0 gives 0; A=1, B=1 gives 1.
The gate giving the opposite (inverted) output is a NAND gate: its output is 1 except when both inputs are 1, where it is 0.
Markers reward identifying the AND gate, a correct four-row truth table with the single 1 in the both-inputs-high row, and naming NAND as the inverted-output gate.
SQA Higher (specimen)4 marksA combinational logic circuit has the output of an AND gate (fed by inputs A and B) connected to one input of an OR gate, whose other input is C. Work out the output for the input combination A = 1, B = 0, C = 1, and state the condition for the final output to be 1.Show worked answer →
Work through the circuit gate by gate.
AND gate: inputs A = 1 and B = 0, so the AND output is 0 (an AND gate needs both inputs 1).
OR gate: its inputs are the AND output (0) and C (1). An OR gate outputs 1 if either input is 1, so the final output is 1.
Condition for the final output to be 1: either C = 1, or both A = 1 and B = 1 (which makes the AND output 1). In Boolean form, output = (A AND B) OR C.
Markers reward correctly evaluating the AND stage first, feeding it into the OR stage, the final output of 1, and a correct statement of the overall condition.
Related dot points
- Modelling electronic devices with the input, process and output system model, and distinguishing analogue from digital signals.
An SQA Higher Engineering Science answer on modelling electronic devices with the input, process and output system model, and on the difference between analogue and digital signals with examples of each.
- The operational amplifier as an inverting amplifier with gain set by feedback resistors, as a difference amplifier, and as a comparator producing a switching output.
An SQA Higher Engineering Science answer on the operational amplifier as an inverting amplifier with gain set by feedback resistors, as a difference amplifier, and as a comparator that produces a switching output for control.
- Output devices such as LEDs, buzzers, motors and solenoids, interfacing them to a control circuit, and calculating the series resistor needed to protect an LED.
An SQA Higher Engineering Science answer on output devices such as LEDs, buzzers, motors and solenoids, how they are interfaced to a control circuit, and how to calculate the series resistor that protects an LED.
- The universal system model of input, process and output, the use of block diagrams to represent systems and sub-systems, and the difference between open-loop and closed-loop control with feedback.
An SQA Higher Engineering Science answer on the universal system model of input, process and output, representing systems with block diagrams, and the difference between open-loop and closed-loop control using feedback.
Sources & how we know this
- SQA Higher Engineering Science Course Specification — SQA (2019)
- Higher Engineering Science Course Specification (PDF) — SQA (2019)