# BCD to Seven Segment Decoder

The Binary Coded Decimal (BCD) encoding method uses binary patterns to encode each decimal value (from 0 to 9), generally of 4-bits.

In contrast, a seven-segment display is an electrical device that displays Hexadecimal digits using seven Light Emitting Diodes (LEDs) arranged in a specific pattern (common cathode or common anode type) (in this case, decimal numbers, as input, are BCD, i.e., 0-9).

7-Segment LED displays are of two types:

1. Common Cathode Type (CCT) - This form of the display works by connecting all seven of the LEDs' cathodes to ground or -Vcc (thus, common cathode), which causes the LEDs to display numbers when a "HIGH" signal is applied to each anode.
2. Common Anode Type (CAT) - The seven LEDs in this display have all seven of their anodes linked to a battery or +Vcc, and when a 'LOW' signal is applied to each individual cathode, the LEDs display numbers.

The separate LED segments of a seven-segment display are not directly powered. However, for it to function, we first convert our decimal number to its BCD equivalent signal, and then a BCD to seven-segment decoder converts that signal into the form supplied to the seven-segment display.

The seven-segment decoder, which has four input lines and seven output lines (a, b, c, d, e, f, and g), receives this BCD (A, B, C, and D) input. The output is provided to a seven-segment LED display that shows the decimal number depending on the inputs.

The truth table of Common Cathode Type BCD to the seven-segment decoder is given below:

Decimal Number INPUT Lines OUTPUT Lines
A B C D 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

Important points:

1. For a seven-segment LED display of the Common Anode type, all we need to do is swap all of the '0's and '1's on the output side, i.e., for a, b, c, d, e, f, and g, swap all of the '1's for '0's, and use k-map to solve.
2. In the above truth table, the combinations of inputs represent the digits from 0 to 1.
3. The range of BCD numbers is 0 to 9, and the rest of the inputs are invalid.

Let us now understand the few inputs:

For Decimal Number = 0

The input lines for Zero are A = 0, B = 0, C = 0, and D = 0 and in the output lines, a to f are 1 and only g = 0. So, the g LED display will not glow, and the rest of the LEDs will glow, and we get zero on display.

For Decimal Number = 2

The input lines for two are A = 0, B = 0, C = 1, and D = 0; in the output lines, a, b, d, e, and g are 1 and c and f are zero. So, only a, b, d, e, and g will glow, and we get two on display.