Both binary-coded decimal (BCD) and binary numbers are used in many digital applications. Both have their advantages and disadvantages. BCD is commonly used when decimal numbers must be represented in hardware, as each 4-bit BCD number maps directly to a decimal number. Binary is more efficient for arithmetic, memory storage, and transmitting information, but is less human-readable.

Contrast the difference between BCD and binary coding.

```
Binary Hexadecimal Decimal
63 in Binary: 0011 1111 8'h3F 32 + 16 + 8 + 4 + 2 + 1
63 in BCD: 0110 0011 8'h63 60 + 3
597 in Binary: 0010 0101 0101 12'h255 512 + 64 + 16 + 4 + 1
597 in BCD: 0101 1001 0111 12'h597 500 + 90 + 7
```

Binary numbers can represent 2 states per bit, as every bit can be a 1 or a 0. A 4-bit binary number can represent 2^4 = 16 states, an 8-bit binary number can represent 2^8 = 256 states, and a 32-bit binary number can represent 2^32 = 4,294,967,296 states.

BCD numbers use 4 bits to represent one decimal digit. That means that a 4-bit BCD number can represent ten states (0-9). An 8-bit BCD number can represent 10^(8/4) = 100 states, and a 32-bit BCD number can represent 10^(32/4) = 100,000,000 states.

BCD numbers encode less information than binary numbers with the same number of bits, as 6 of 16 possible states are not used for each 4-bit BCD number. Mathematically, each BCD “bit” only encodes 10^(1/4) = 1.778 states, while each binary bit encodes 2 states. So, the larger the BCD number, the more bits BCD coding wastes.

Example: If you were to make a counter that counts from 0 to 9999 (as you will with Project 9) with a binary counter, you would need 14 bits (2^14 = 16,384 > 10,000). Using a BCD counter would require 16 bits.

When should you use one or the other? This is entirely application dependent. If you want to display decimal number on a seven-segment display, using a BCD counter would be easier, as you would not need to convert from binary to BCD before passing each digit into your seven-segment display controller. Numerical calculations in Verilog use binary numbers. Sometimes, a system will need to convert between BCD and binary numbers. This can be accomplished through a look-up table, software, or conversion algorithm. The latter is covered in project 12.