What digital electronics means
In a digital circuit every wire has only two levels. High voltage is 1. Low voltage is 0. Small noise does not matter, because 0.2 V and 0.1 V are both read as 0.
Two levels are easy to copy, store and send. That is why phones, computers and calculators are digital.
The building blocks are logic gates: NOT, AND, OR, NAND, NOR, XOR. Joined together they make circuits.
Combinational circuits: designing a logic circuit
In a combinational circuit the output depends only on the present inputs. It has no memory. Same inputs, same output, always.
Design in 4 steps:
- Write what the circuit must do as a truth table (2n rows for n inputs).
- For every row with output 1, write an AND term (a minterm). Use A for 1 and A′ for 0. Join the terms with OR. This is the sum of products.
- Simplify the expression so it needs fewer gates.
- Draw the gates and check every row.
Our example is F = A·B + C′. The circuit uses one AND gate, one NOT gate and one OR gate.
Truth table and sum of products
For F = A·B + C′ the rows with F = 1 are 000, 010, 100, 110 and 111. Writing a minterm for each one gives five terms: A′B′C′ + A′BC′ + AB′C′ + ABC′ + ABC. This is correct but long. Simplifying makes it short.
| A B C | F |
|---|---|
| 000 | 1 |
| 001 | 0 |
| 010 | 1 |
| 011 | 0 |
| 100 | 1 |
| 101 | 0 |
| 110 | 1 |
| 111 | 1 |
Simplifying with Karnaugh maps
A Karnaugh map (K-map) is the truth table drawn as a grid. Neighbouring cells differ in only one input, so we can join them.
Rules:
- Columns go in the order 00, 01, 11, 10 (only one bit changes each step, called Gray code).
- Circle groups of 1s. The group size must be 1, 2, 4 or 8.
- Make groups as big as possible. Groups may overlap. The map wraps round the edges.
- In each group, keep only the variables that do not change.
In our map the four cells with C = 0 form one group: only C′ stays fixed, so the term is C′. The cells 110 and 111 form a group of 2: A and B stay fixed, so the term is A·B.
Result: F = C′ + A·B. Five minterms became two small terms.
Sequential circuits and flip-flops
A sequential circuit has memory. Its output depends on the present inputs and on its stored past. A clock, a steady train of pulses, tells it when to update.
The basic memory cell is the flip-flop. A D flip-flop has input D, a clock and output Q. When the clock pulses, Q copies D. Between pulses Q keeps its value, even if D changes. One flip-flop stores one bit.
| Type | Output depends on | Example |
|---|---|---|
| Combinational | present inputs only | adder, decoder, F circuit |
| Sequential | inputs and past | counter, register, traffic light |
Counters and registers
Several flip-flops in a row make a register, which stores a whole number. A counter is a register that adds 1 on every clock pulse. A 3-bit counter counts 000, 001, 010, ... 111 and then goes back to 000. It has 23 = 8 states.
Digital clocks, timers and traffic lights all use counters. In the 3D, the counter bits feed the F circuit, so you can watch F change as the count goes up.
Testing in a simulator
A simulator is free software where you drag gates and flip-flops, join them with wires and press play. It lets you test every row of the truth table before you buy parts.
Good testing habits:
- Test all input rows, not only one.
- Compare the simulator output with your truth table.
- For sequential circuits, start from a known state using reset, then pulse the clock one step at a time.
- If a row fails, find the first gate whose output is wrong.
Key formulas and definitions
- Rows in a truth table = 2ⁿ
- Sum of products: add (OR) the minterms of rows where F = 1
- K-map group sizes: 1, 2, 4, 8
- Example: F = A·B + C′
- D flip-flop: Q(next) = D at the clock pulse
- Counter with n bits has 2ⁿ states
Worked examples
1. How many rows does a truth table for 4 inputs have?
2⁴ = 16 rows.
2. Find F = A·B + C′ when A = 1, B = 0, C = 1.
A·B = 0 and C′ = 0, so F = 0 + 0 = 0.
3. A circuit gives F = 1 only for the inputs 011 and 111 (A B C). Write F and simplify.
F = A′BC + ABC. Both terms contain BC. Take BC out: F = BC(A′ + A) = BC·1 = BC. In a K-map, the two 1s are neighbours and form one group of 2 where B and C stay fixed.
4. A D flip-flop has Q = 0. D is set to 1, then D is set to 0, and then the clock pulses. What is Q?
Q only reads D at the clock pulse. At that moment D = 0, so Q stays 0. The short time when D was 1 did not matter.
5. How many clock pulses bring a 3-bit counter from 101 back to 101?
It has 8 states, so 8 pulses return it to the same state.
6. Simplify with a K-map the function with ones at 000, 001, 100 and 101.
The four cells are A′B′C′, A′B′C, AB′C′, AB′C. B is 0 in all four, while A and C take both values. They form one group of 4 and only B′ stays fixed. F = B′.
Common mistakes
- Writing the K-map columns as 00, 01, 10, 11. The order must be 00, 01, 11, 10 so that neighbours differ by one bit.
- Making a group of 3 or 6 cells. Groups must be 1, 2, 4 or 8.
- Thinking a flip-flop output follows its input all the time. It changes only at the clock pulse.
- Calling a circuit with memory 'combinational'. If the output depends on the past, it is sequential.