Hex to 7-segment decoder: 0 to F on a display, live
A hex to 7-segment decoder turns a 4-bit number, D3 to D0, into the seven segment signals a to g that draw its hexadecimal digit, 0 to 9 and then A, b, C, d, E and F. This live circuit computes every segment as a minimal sum of products and drives a real seven-segment display.
A BCD to 7-segment decoder only has to show 0 to 9, so inputs 10 to 15 are don't-cares and its equations come out short. A hex decoder has no spare rows: all 16 codes are digits. The letters use mixed case so that each looks different on seven segments: b and d are lowercase because uppercase B would look like 8 and D like 0, while A, C, E and F are uppercase. Segments a to g go clockwise from the top (a top, b upper right, c lower right, d bottom, e lower left, f upper left) with g in the middle, and 1 lights a segment, as on a common-cathode display. Each segment's column of 16 bits was minimized with the Quine-McCluskey method, the same one behind the Karnaugh map solver; segment e, for example, is D2'D0' + D1D0' + D3D1 + D3D2. Product terms that two segments share are built once.
Open this circuit in the lab →
What you need
- 4× NOT: D3', D2', D1' and D0'
- 38× AND (2-input): 28 distinct product terms, shared between segments
- 28× OR (2-input): one OR chain per segment, a to g
Step by step
- Place inputs
D3toD0, probesatogand a seven-segment display. - Write the truth table: for each code 0 to F, which of the seven segments are lit (the table below).
- Minimize each segment's column to a sum of products with a Karnaugh map or Quine-McCluskey, and build the product terms with AND gates, sharing the ones that repeat.
- OR each segment's terms together, wire the seven outputs to the display, and step D3 to D0 from 0000 to 1111: the display counts 0 to F.
Hex to 7-segment truth table
| Shows | D3 D2 D1 D0 | a | b | c | d | e | f | g |
|---|---|---|---|---|---|---|---|---|
| 0 | 0000 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
| 1 | 0001 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 2 | 0010 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |
| 3 | 0011 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
| 4 | 0100 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 5 | 0101 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
| 6 | 0110 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 7 | 0111 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 8 | 1000 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 9 | 1001 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| A | 1010 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| b | 1011 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
| C | 1100 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| d | 1101 | 0 | 1 | 1 | 1 | 1 | 0 | 1 |
| E | 1110 | 1 | 0 | 0 | 1 | 1 | 1 | 1 |
| F | 1111 | 1 | 0 | 0 | 0 | 1 | 1 | 1 |
All 16 rows of the live circuit are checked against this table before the page is built. 6 and 9 are drawn with tails (segment a on for 6, d on for 9), the usual hex style, so that 6 and b differ.
You can also read the full theory in the lesson on the seven-segment display. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Selecting, routing and decoding
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the Hex to 7-segment decoder in the lab →Frequently asked
What is a hex to 7-segment decoder?
A combinational circuit that takes a 4-bit value and outputs the seven segment signals that draw its hexadecimal digit, 0 to 9 and A to F, on a seven-segment display.
Why are b and d lowercase on a 7-segment display?
Because uppercase B would look exactly like 8 and uppercase D like 0. Lowercase b and d are distinct shapes, while A, C, E and F can stay uppercase.
What is the difference between a BCD and a hex 7-segment decoder?
A BCD decoder only needs to show 0 to 9, so codes 10 to 15 are don't-cares that simplify its logic. A hex decoder uses all 16 codes, adding A, b, C, d, E and F, so its equations are longer.
Is 1 on or off for a segment?
Here 1 lights a segment, which suits a common-cathode display. A common-anode display needs the inverted signals, as the 74LS47 driver provides with its active-low outputs.