Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

How to build a BCD to 7-segment decoder from logic gates

A BCD to 7-segment decoder turns a 4-bit decimal digit D3 D2 D1 D0 (0000 to 1001) into the seven signals a to g that light the segments of a digit display, for example 0101 lights a, c, d, f and g to draw a 5.

Each of the seven outputs is its own Boolean function of the four inputs. Because BCD only uses the codes 0 to 9, the six codes 1010 to 1111 never occur and are treated as don't-cares, which is what lets each segment's K-map simplify to a short sum of products. This build is the common-cathode version, where 1 means "segment on". The live circuit starts at 0000, so a to f are on and g is off: the digit 0. Every digit 0 to 9 is checked against the standard segment patterns before the page is built.

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 →

What you need

Step by step

  1. Place the four BCD inputs D3 (8s), D2 (4s), D1 (2s), D0 (1s), and invert D2, D1 and D0.
  2. Write the truth table for one segment at a time (the table below), mark rows 10 to 15 as don't-cares, and minimize with a K-map. For segment a that gives a = D3 + D1 + D2 D0 + D2' D0'.
  3. Do the same for the other six: b = D2' + D1' D0' + D1 D0, c = D2 + D1' + D0, d = D3 + D2' D0' + D2' D1 + D1 D0' + D2 D1' D0, e = D2' D0' + D1 D0', f = D3 + D1' D0' + D2 D1' + D2 D0', g = D3 + D2' D1 + D2 D1' + D1 D0'.
  4. Build the product terms once and share them between segments (D2' D0' appears in a, d and e), then OR each segment's terms together.
  5. Probe the seven outputs a to g and count the inputs from 0000 to 1001: the lit outputs spell each digit.

BCD to 7-segment truth table

DigitD3 D2 D1 D0abcdefg
000001111110
100010110000
200101101101
300111111001
401000110011
501011011011
601101011111
701111110000
810001111111
910011111011

Segments are named clockwise from the top: a top, b upper right, c lower right, d bottom, e lower left, f upper left, and g the middle bar. This table draws 6 and 9 with their tails (a on for 6, d on for 9) and 7 with three segments; some decoder chips draw these digits differently. For a common-anode display, where 0 lights a segment, invert every output. The 7448 is a classic BCD to 7-segment decoder chip for common-cathode displays.

You can also read the full theory in the lesson on seven-segment displays. 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.

Build more parts from gates

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 BCD to 7-segment decoder in the lab →

Frequently asked

What does a BCD to 7-segment decoder do?

It converts a 4-bit binary-coded decimal digit (0 to 9) into seven outputs, one per segment of a seven-segment display, so the display shows that digit.

Why are inputs 10 to 15 don't-cares?

BCD only uses the codes 0000 to 1001 for the digits 0 to 9. The codes 1010 to 1111 never appear, so the decoder may output anything for them, and marking them as don't-cares lets the K-maps form bigger groups and simpler equations.

What is the Boolean expression for segment a?

With D3 D2 D1 D0 as the inputs and don't-cares for 10 to 15: a = D3 + D1 + D2 D0 + D2' D0'. Segment a is off only for the digits 1 and 4.

What is the difference between common-anode and common-cathode displays?

In a common-cathode display all segment LEDs share a ground connection, so a segment lights when its input is 1 (this page's convention). In a common-anode display they share the supply, so a segment lights when its input is 0, and the decoder outputs are inverted.