decoders

BCD to 7-Segment Decoder: From Numbers to Display

Denny Denny
10 min read
A glowing seven-segment display digit lit up by a BCD decoder block, individual segments rendered in cyan.

TL;DR: A BCD to 7-segment decoder takes a 4-bit binary-coded-decimal digit (0–9) and lights the right combination of segments a–g on a digital display. The mapping is defined by a 10-row truth table; each segment’s boolean expression is derived from the table and minimized using K-maps, then implemented in a chip like the 74LS47 (common anode) or 74LS48 (common cathode).

The seven-segment display is the most recognizable output device in digital electronics — clocks, microwaves, calculators, scoreboards, and old gas pumps all use it. Behind every digit on the screen is a small combinational circuit that turns a 4-bit number into a 7-bit pattern of which LEDs to light. That circuit is the BCD to 7-segment decoder, and it is one of the cleanest practical applications of Boolean algebra and Karnaugh maps.

This post defines BCD, lays out the segment-naming convention, builds the truth table, derives the boolean equations for each segment, contrasts common-anode with common-cathode wiring, and points to the 74LS47 / 74LS48 chips that implement the whole thing. The simulator templates referenced at the end let you wire one up by hand.

What Is BCD?

BCD — Binary-Coded Decimal — is an encoding that uses 4 bits to represent each decimal digit 0 through 9. Unlike straight binary, BCD wastes the codes 1010 through 1111 (decimal 10–15): they are simply not used.

Decimal digitBCD (4 bits)A B C D
000000 0 0 0
100010 0 0 1
200100 0 1 0
300110 0 1 1
401000 1 0 0
501010 1 0 1
601100 1 1 0
701110 1 1 1
810001 0 0 0
910011 0 0 1
10–151010–1111unused (don’t-cares)

The convention used in this post: A is the most-significant bit, D is the least. Some textbooks use the opposite order; the equations are identical with relabeling.

Why BCD instead of straight binary? Two answers: (1) decimal digits map directly to display segments, so converting binary to decimal for display is unnecessary; (2) financial and timekeeping arithmetic is exact in BCD because powers of ten are representable without rounding. The cost is about 17 % more bits per digit compared with packed binary.

The 6 unused codes — 1010 through 1111 — become don’t-care entries when minimizing the segment equations. Treating them as “either 0 or 1, whichever simplifies the gate count” is a major source of the savings that K-map analysis produces.

The Seven Segments

A standard 7-segment display has seven LEDs arranged like an 8, conventionally labeled a through g:

   ┌─── a ───┐
   │         │
   f         b
   │         │
   ├─── g ───┤
   │         │
   e         c
   │         │
   └─── d ───┘
  • a is the top horizontal bar.
  • b is the upper-right vertical.
  • c is the lower-right vertical.
  • d is the bottom horizontal.
  • e is the lower-left vertical.
  • f is the upper-left vertical.
  • g is the middle horizontal.

A decimal digit lights a specific subset:

DigitSegments lit
0a, b, c, d, e, f
1b, c
2a, b, d, e, g
3a, b, c, d, g
4b, c, f, g
5a, c, d, f, g
6a, c, d, e, f, g
7a, b, c
8a, b, c, d, e, f, g
9a, b, c, d, f, g

DigiSim’s SEVEN_SEGMENT_DISPLAY component takes seven inputs in this exact order; the DIGIT_DISPLAY is a higher-level abstraction that takes the 4-bit BCD input directly and handles decoding internally.

The Full Truth Table

Combining the BCD encoding with the segment mapping gives one table with 16 rows (10 valid + 6 don’t-cares) and 7 segment columns:

ABCDdigitabcdefg
000001111110
000110110000
001021101101
001131111001
010040110011
010151011011
011061011111
011171110000
100081111111
100191111011
1010×××××××
1011×××××××
1100×××××××
1101×××××××
1110×××××××
1111×××××××

The table assumes active-high segments — a 1 means the LED is lit. Real chips are split between active-high (common-cathode) and active-low (common-anode); the truth table is the same, the inverter is in the output stage.

Deriving the Segment Equations

Each segment column above is one Boolean function of four inputs. With 6 don’t-care rows, the K-map minimization gives much shorter expressions than a naive sum-of-products. The technique is the Sum of Products method with K-map reduction.

Segment a

Segment a is on for digits 0, 2, 3, 5, 6, 7, 8, 9 — and off for 1, 4. With the don’t-cares treated optimally, K-map minimization gives:

a=A+C+BD+BDa = A + C + B \cdot D + \overline{B} \cdot \overline{D}

(Here B\overline{B} means NOT B; some books write it BB'.) The term BD\overline{B} \cdot \overline{D} — both B and D are zero — covers the 0 and 2 cases efficiently; BDB \cdot D — both ones — covers 3, 5, 7, 9; AA alone covers 8 and 9 (and the don’t-cares 10–15); CC alone covers 2, 3, 6, 7.

This expression uses one AND per product term and a single OR to combine them. Two AND gates and one 4-input OR — a handful of transistors.

Segment b

Segment b is on for 0, 1, 2, 3, 4, 7, 8, 9 — off for 5, 6. K-map gives:

b=B+CD+CDb = \overline{B} + \overline{C} \cdot \overline{D} + C \cdot D

Segment c

Segment c is on for 0, 1, 3, 4, 5, 6, 7, 8, 9 — off only for 2. K-map gives:

c=B+C+Dc = B + \overline{C} + D

This is the simplest of all — only three terms because there is only one zero-output row and the don’t-cares fill the rest of the map.

Segment d

Segment d is on for 0, 2, 3, 5, 6, 8, 9 — off for 1, 4, 7. K-map gives:

d=BD+CD+BCD+BC+Ad = \overline{B} \cdot \overline{D} + C \cdot \overline{D} + B \cdot \overline{C} \cdot D + \overline{B} \cdot C + A

Segment e

Segment e is on for 0, 2, 6, 8 — off for 1, 3, 4, 5, 7, 9. K-map gives:

e=BD+CDe = \overline{B} \cdot \overline{D} + C \cdot \overline{D}

Note both terms share D\overline{D} — equivalently e=D(B+C)e = \overline{D} \cdot (\overline{B} + C). Even digits are necessary for e (segment e is off whenever D=1D = 1), but not sufficient: digit 4 has D=0D = 0 yet e is off because both B=0\overline{B} = 0 and C=0C = 0 for that input. The factored form uses only 2 AND gates plus one OR.

Segment f

Segment f is on for 0, 4, 5, 6, 8, 9 — off for 1, 2, 3, 7. K-map gives:

f=A+BC+CD+BDf = A + B \cdot \overline{C} + \overline{C} \cdot \overline{D} + B \cdot \overline{D}

Segment g

Segment g — the middle bar — is on for 2, 3, 4, 5, 6, 8, 9 — off for 0, 1, 7. K-map gives:

g=A+BC+CD+BCg = A + B \cdot \overline{C} + C \cdot \overline{D} + \overline{B} \cdot C

These seven boolean expressions are the canonical results that have appeared in textbook treatments and the actual silicon of the 74LS47/48 since the 1970s. Implementing them in DigiSim is a matter of dropping seven small AND/OR networks behind a 4-bit BCD input bus.

Common Anode vs Common Cathode

The 7-segment display itself comes in two physical wirings. They differ in which side of every LED is shared with a single common pin.

Common Cathode

All seven LED cathodes (negative terminals) are tied together to a single common pin connected to ground. Each anode is driven separately. To light a segment, drive its anode high.

  • Driver output: active-high — 1 lights the segment.
  • Truth table interpretation: matches the table above directly.
  • Companion chip: 74LS48 — outputs are active-high.

Common Anode

All seven LED anodes are tied together to a single common pin connected to V_CC. Each cathode is driven separately. To light a segment, pull its cathode low.

  • Driver output: active-low — 0 lights the segment.
  • Truth table interpretation: invert every output column.
  • Companion chip: 74LS47 — outputs are active-low (open-collector).

For the same boolean equations, the only thing that changes is whether you put an inverter at each output. Modern designs typically use common-cathode displays with active-high drivers because GPIO outputs source current more cleanly than they sink it.

The 74LS47 and 74LS48

The 74LS47 and 74LS48 are TTL chips from the 1970s that implement the entire BCD-to-7-segment function on a single piece of silicon. Pinout is identical between the two; only the output polarity differs.

ChipOutput polarityDisplay type
74LS47Active-low (open-collector)Common anode
74LS48Active-high (with internal pull-ups)Common cathode

Both chips also include three useful auxiliary inputs:

  • LT (Lamp Test): Pulled low to force all seven outputs on, regardless of the BCD input. Used to verify every LED is functional.
  • RBI (Ripple Blanking Input): Pulled low along with BCD input 0000 to blank the display instead of showing 0. Used to suppress leading zeros in multi-digit displays — 00073 becomes 73.
  • BI/RBO (Blanking Input / Ripple Blanking Output): Bidirectional — input function blanks the display when pulled low; output function asserts low when this digit is blanked, which then drives the next digit’s RBI to continue the leading-zero suppression chain.

Together those three pins enable cascading multiple decoder/display pairs into a multi-digit numeric display where leading zeros automatically vanish.

The behavior for invalid BCD inputs (1010–1111) is chip-defined and produces idiosyncratic non-digit segment patterns — useful as a debugging signal but not portable.

Real-World Applications

The BCD-to-7-segment decoder appears in nearly every device with a numeric display:

  • Digital clocks — six digits (HH:MM:SS), each driven by a decoder fed from a counter chain. The seconds counter is a modulo-60 counter built from cascaded BCD counters.
  • Calculators — eight to twelve digits multiplexed at high frequency. Only one decoder chip is needed because the BCD inputs are switched between digits 1000+ times per second; persistence of vision makes them all appear lit at once.
  • Multi-digit voltmeters and frequency counters — a counter feeds a BCD-encoded register, the register feeds the decoder, and the decoder lights the segments.
  • Score boards and odometers — same multiplexing trick, often with brighter LED arrays.

Build It in DigiSim

Open the DECODER component to see the general-purpose decoder building block. For the BCD-to-7-segment specific case, drop a DIGIT_DISPLAY — which has the conversion baked in — or build the decoder by hand and feed the seven outputs to a SEVEN_SEGMENT_DISPLAY.

Wire four input switches as A, B, C, D (most significant to least). Implement segment a first using the equation above:

  1. Two AND gates: one for BDB \cdot D, one for BD\overline{B} \cdot \overline{D}.
  2. One 4-input OR combining AA, CC, and the two AND outputs.

Toggle the switches through the BCD codes 0–9 and verify segment a lights in the correct cases. Then add segments b through g following the equations above.

The next post in the combinational track — BCD: Binary-Coded Decimal Fundamentals — covers BCD addition, the half-carry adjustment, and packed vs unpacked BCD storage. Read alongside Decoders and Encoders Driving a 7-Segment Display for the broader story of how a few binary inputs select one display pattern out of many.