Digital Logic Design Lec04
Digital Logic Design Lec04
( 6) ( 13)
(11111010 11110011)
• Example: (11111010 + 00001101)
00000111 (+ 7)
Signed Binary Numbers
Binary Codes
• BCD Code
• A number with k decimal digits will require 4k bits in BCD.
• Decimal 396 is represented in BCD with 12bits as 0011 1001
0110, with each group of 4 bits representing one decimal digit.
• A decimal number in BCD is the same as its equivalent binary
number only when the number is between 0 and 9.
• The binary combinations 1010 through 1111 are not used and
have no meaning in BCD.
• Examples are digital wrist watches, calculators, voltmeter etc.
Binary Codes
Binary Codes
• BCD addition
• Step 1: Add the two BCD numbers, using the rules for binary
addition
• Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD
number.
• Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit
group is generated,
• it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the
six invalid states and return the code to 8421.
• If a carry results when 6 is added, simply add the carry to the next 4-bit
group.
Binary Codes
• Example:
• Consider decimal 185 and its corresponding value in BCD and
binary:
• BCD addition
Binary Codes
• Example:
• Consider the addition of 184 + 576 = 760 in BCD:
Binary Codes
Add the following numbers in BCD:
• 3+4
• 23+15
• 86+13
• 450+917
Binary Codes
• Other Decimal Codes
Binary Codes
Gray Code
The advantage is that only one bit in the code group
changes in going from one number to the next.
Applications
• Rotary Encoder
• Karnaugh Map
• Error correction in digital communication
Binary Codes
Binary-to-Gray Code Conversion:
1. The most significant bit (left-most) in the Gray code is the same as the
corresponding MSB in the binary number.
2. Going from left to right, add each adjacent pair of binary code bits to get
the next Gray code bit. Discard carries.
Least significant
bit
e.g., ‘a’ = 1100001
95 Graphic codes
33 Control codes
Alphabetic codes
Numeric codes
Punctuation, etc.