The seven-segment decoder
A seven-segment decoder is a combinational circuit that turns a four-bit binary digit into the seven signals that light the bars of a display, so that 1001 shows as a 9. It is seven boolean functions of the same four inputs, each derived from a ten-row truth table, and the best everyday example of don't cares earning their keep.
Try it
Pick a code and the display is driven by the seven expressions derived further down, not by a lookup: what you see is what the circuit computes, including for the six codes above 9.
- Shows
- the digit 5
- Input
- B3=0B2=1B1=0B0=1
- Segments
- a=1b=0c=1d=1e=0f=1g=1
How it works
Lettered clockwise from the top, with g across the middle.
A seven-segment display is seven LEDs arranged as a figure eight. The bars are lettered a across the top, then b, c and d clockwise round to the bottom, e and f back up the left side, and g across the middle. Light the right subset and you get a digit: all but g for 0, only b and c for 1, and so on. The decoder's job is to turn the four bits of the digit into those seven on-or-off signals.
There is no clever trick in it, which is what makes it a good exercise. Each segment is its own boolean function of the four input bits, read straight off a truth table with one row per digit. Simplify each of the seven columns and you have seven small circuits sharing four inputs. The one refinement is that a BCD digit never exceeds 9, so the six input codes 10 to 15 never happen, and their rows can be marked as don't cares. That lets every Karnaugh map group grow, and each of the seven expressions comes out shorter than it would otherwise.
Truth table
One row per digit. The inputs are the four bits of the digit, most significant first; the outputs are the segments, 1 for lit.
| Digit | B3w | B2x | B1y | B0z | a | b | c | d | e | f | g | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | |
| 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | |
| 2 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | |
| 3 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | |
| 4 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | |
| 5 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | |
| 6 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | |
| 7 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | |
| 8 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |
| 9 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | |
| 10–15 | 1010 to 1111 | X | X | X | X | X | X | X | ||||
These are the textbook shapes: 6 with its top bar and 9 with its bottom bar lit. The 7447 leaves segment a dark on 6 and d dark on 9, which changes two rows and nothing else about the method.
The seven expressions
Each segment's column, simplified as a Karnaugh map with the don't cares used. Every one of these was generated by the same engine as the solver, and checked against the table above.
The inputs are called w x y z here for the bits 8, 4, 2 and 1. The solver labels them a b c d, which is the usual textbook naming; only the letters differ.
The circuit for segment a
One segment at a time, driven by the code chosen above. Pick another segment from the cards, or toggle the input, and the signal colours follow.
The full decoder is these seven circuits side by side, sharing the four inputs and the three inverters. The simulator's seven-segment example has it wired to a display node you can drive from four switches.
In real hardware
The decoder has been a standard part since around 1970: the TTL 7447 drives common anode displays with active-low outputs, the 7448 drives common cathode displays, and the CMOS 4511 adds a latch so the input can change while the display holds. All of them take a BCD input and add extras the pure logic does not need: a lamp test pin that lights every segment, a blanking input, and, on the 7447 and 7448, ripple blanking that suppresses leading zeros across several digits. In anything designed today the decoding is a few lines of code in a microcontroller or a lookup table in an FPGA, but the truth table is the same one as above.
Questions about seven-segment decoders
What is a seven-segment decoder?
A combinational circuit that takes a four-bit binary number, usually a BCD digit from 0 to 9, and produces seven outputs, one per bar of a seven-segment display, so that the bars light in the shape of that digit. It is seven separate boolean functions of the same four inputs, each derived from a truth table with ten rows.
What is the truth table for a BCD to seven-segment decoder?
Ten rows, one per digit, with four input columns for the BCD bits and seven output columns for segments a to g. Segment a, for instance, is lit for 0, 2, 3, 5, 6, 7, 8 and 9 and dark for 1 and 4. The six remaining input codes, 10 to 15, never occur with BCD input and are left as don't cares.
Why are codes 10 to 15 don't cares?
Because a BCD input never produces them, so whatever the decoder shows for them is never seen. Marking those rows as don't cares lets the Karnaugh map groups grow across them, which makes every one of the seven expressions shorter. The circuit on this page happens to show a real digit for five of the six spare codes and a meaningless shape for 10; the 7447 shows partial shapes for all six.
What is the difference between common anode and common cathode displays?
Which terminal the segments share. In a common cathode display all the segment cathodes are joined to ground and a segment lights when its input is driven high; in a common anode display the anodes share the supply and a segment lights when its input is pulled low. The logic is the same either way, with every output inverted for common anode, which is what the 7447 does compared with the 7448.
How many gates does a seven-segment decoder need?
With the don't cares used, the seven minimal expressions on this page have 25 terms between them, 16 of which need an AND gate, plus an OR per segment and 3 inverters: the 8s bit is never needed complemented. Sharing identical terms between segments, which a real design does, brings the count down further.
What chip is a seven-segment decoder?
The classic TTL parts are the 7447, which drives common anode displays with active-low outputs, and the 7448 for common cathode displays, both taking a BCD input. The CMOS 4511 does the same for common cathode displays and adds a latch on the inputs. Modern designs usually do the decoding in a microcontroller or an FPGA instead.