Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “Hex to 7-segment decoder”, https://digiwleea.wleeaf.dev/tools/build/hex-to-7-segment/

What you need

Step by step

  1. Place inputs D3 to D0, probes a to g and a seven-segment display.
  2. Write the truth table: for each code 0 to F, which of the seven segments are lit (the table below).
  3. 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.
  4. 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

ShowsD3 D2 D1 D0abcdefg
000001111110
100010110000
200101101101
300111111001
401000110011
501011011011
601101011111
701111110000
810001111111
910011111011
A10101110111
b10110011111
C11001001110
d11010111101
E11101001111
F11111000111

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.