#### What is BCD code?

In computing and electronic systems,

**binary-coded decimal (BCD)**is used to encode decimal numbers (base-10 numbers) in a binary form where each decimal digit is represented by a nibble (4 bits).

For instance decimal number 5 is represented as 0101 in BCD as **5 = 4 + 1**

8 | 4 | 2 | 1 |

0 | 1 | 0 | 1 |

The 10 digits in BCD:

Decimal Digit | BCD Nibble |

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |

8 | 1000 |

9 | 1001 |

Numbers larger than 9, having two or more digits in the decimal system, are expressed one digit at a time using on nibble per digit. For example, the decimal number **365** is encoded as:

*0011 0110 0101*

#### 7-Segment Display

A lot of electronic devices use 7-segment displays (Watch, alarm clock, calculator etc.).

Typically 7-segment displays consist of seven individual coloured LED’s (called the segments). Each segment can be turned on or off to create a unique pattern/combination. Each segment is identified using a letter between A to G as follows:

The 10 descimal digits can be displayed on a seven-segment display as follows:

#### BCD to 7-Segment Display: Truth Tables & Karnaugh Maps

We will use four inputs A,B,C and D to represent the four BCD digits as ABCD (A is the most significant digit, D is the least significant digit). When creating an electronic circuit we could use 4 switches to represent these 4 inputs.

We will need 7 outputs one for each segment. So let’s investigate each segment one at a time.

**Segment A**should be

**on**for the following values:

BCD: 0000 | BCD: 0010 | BCD: 0011 | BCD: 0101 |

BCD: 0110 | BCD: 0111 | BCD: 1000 | BCD: 1001 |

**Segment A** should be **off** for the following values:

BCD: 0001 | BCD: 0100 |

**Segment A** should also be **off** for the following BCD values which are not used to represent decimal digits values from 0 to 9:

- 1010
- 1011
- 1100
- 1101
- 1110
- 1111

Note that these values could be used to represent hexadecimal values A to F (10 to 15). Here we will not display anything instead.

Hence the **Truth Table** for **Segment A** is as follows:

Inputs | Output | |||

A | B | C | D | Segment A |

0 |
0 |
0 |
0 |
1 |

0 |
0 |
0 |
1 |
0 |

0 |
0 |
1 |
0 |
1 |

0 |
0 |
1 |
1 |
1 |

0 |
1 |
0 |
0 |
0 |

0 |
1 |
0 |
1 |
1 |

0 |
1 |
1 |
0 |
1 |

0 |
1 |
1 |
1 |
1 |

1 |
0 |
0 |
0 |
1 |

1 |
0 |
0 |
1 |
1 |

1 |
0 |
1 |
0 |
0 |

1 |
0 |
1 |
1 |
0 |

1 |
1 |
0 |
0 |
0 |

1 |
1 |
0 |
1 |
0 |

1 |
1 |
1 |
0 |
0 |

1 |
1 |
1 |
1 |
0 |

This Truth table can be represented using a **Karnaugh Map**:

**Truth Table**and

**Karnaugh Map**of the B segment:

**Truth Table**and

**Karnaugh Map**of the C segment:

**Truth Table**and

**Karnaugh Map**of the D segment:

**Truth Table**and

**Karnaugh Map**of the E segment:

**Truth Table**and

**Karnaugh Map**of the F segment:

**Truth Table**and

**Karnaugh Map**of the G segment:

#### BCD to 7-Segment Display: Boolean Expressions

The Karnaugh maps will help us define the Boolean Expressions associated with each of the 7 segments.

**Karnaugh Map:**

**Boolean Expression:**

**Boolean Expression**of the B segment.

**Boolean Expression**of the C segment.

**Boolean Expression**of the D segment.

**Boolean Expression**of the E segment.

**Boolean Expression**of the F segment.

**Boolean Expression**of the G segment.

#### BCD to 7-Segment Display: Logic Gates Diagrams

We can now convert each Boolean expression into a Logic Gates circuit to link our 4 inputs (switches) to our 7-segment display using a range of logic gates.

**Boolean Expression:**

**Logic Gates Diagram:**

**logic gates diagram**required to control the LED of the B segment.

**logic gates diagram**required to control the LED of the C segment.

**logic gates diagram**required to control the LED of the D segment.

**logic gates diagram**required to control the LED of the E segment.

**logic gates diagram**required to control the LED of the F segment.

**logic gates diagram**required to control the LED of the G segment.

#### Testing

You can now recreate your logic gates circuit using logic.ly to test if it behaves as expected for all 16 BCD entries.

e.g. For Segment A:

#### BCD to 7-Segment Display Integrated Circuit

All these 7 logic gates diagrams can all be integrated into

**one single integrated circuit**: The CD74HCT4511E is a CMOS logic high-speed BCD to 7-segment Latch/Decoder/Driver with four inputs and is used to use these 4 inputs (BCD nibble) to control the display of a 7-segment display.

#### Hex/BCD to 7-Segment Display Integrated Circuit

A very similar approach can be used to display hexadecimal digits as these are also based on a nibble per digit.

The extra values that we discarded previously (BCD: 1010, 1011, 1100, 1101, 1110, 1111) can be used to represent the extra 6 digits available in hexadecimal: