Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Digital Logic Design Week 2 Lecture 1

The document provides an overview of various binary coding methods, including Binary Coded Decimal (BCD), Excess-3 code, and Gray code, detailing their structures and applications. It explains the differences between conversion and coding, BCD addition rules, and characteristics of specific codes like the 2421 code and self-complementing properties. Additionally, it includes practical examples and references for further exploration of the topics discussed.

Uploaded by

sajib25yhoo.com
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Digital Logic Design Week 2 Lecture 1

The document provides an overview of various binary coding methods, including Binary Coded Decimal (BCD), Excess-3 code, and Gray code, detailing their structures and applications. It explains the differences between conversion and coding, BCD addition rules, and characteristics of specific codes like the 2421 code and self-complementing properties. Additionally, it includes practical examples and references for further exploration of the topics discussed.

Uploaded by

sajib25yhoo.com
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

CSE 1325: Digital Logic Design

Sidratul Tanzila Tasmi


Department of Computer Science and Engineering
United International University

1
Binary Coding
Codes

Non- Error Detection


Weighted Reflective Sequential Alphanumeric
Weighted And
Codes Code Code Code
Codes Correction Code
● 8421 ● Excess 3
● 2421 ● 2421 ● ASCII
● Parity
● EBCDIC
● Hamming

2
Binary Coded Decimal

● BCD code is an abbreviation for Binary coded Decimal codes.


● It is a numeric weighted code, in which each digit of a decimal number is
represented by a separate group of 4-bits.
● There are several BCD codes like 8421, 2421, 3321, 4221, 5211, 5311, 5421, etc.
● The most common and widely used BCD code is 8421 code. In 8421 code,
the weights associated with 4 bits are 8, 4, 2, 1 from MSB to LSB.

3
BCD Codes
Decimal BCD (8421)
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

4
BCD Codes
Decimal BCD (8421)
Invalid Codes!
0 0000
1 0001 Decimal BCD (8421)
2 0010 10 1010
3 0011 11 1011
4 0100 12 1100
5 0101 13 1101
6 0110 14 1110
7 0111 15 1111
8 1000
9 1001

5
BCD (Cont.)

Warning: Conversion or Coding?

• Do NOT mix up conversion of a decimal number to a binary


number with coding a decimal number with a BINARY CODE.
• 1310 = 11012 (This is conversion)
• 13 ⇔ 0001|0011 (This is coding)

6
BCD (Cont.)
Representation of a decimal number with Binary Coded Decimals

• (17) =>0001 0111


10

• (12) =>0001 0010


10

• (156) =>0001 0101 0110


10

7
Binary to BCD

BCD number to decimal number

• (1 0100)2 = (?)BCD
• (1001001)2 = (?)BCD

8
Binary to BCD

BCD number to decimal number

• (1 0100)2 = (14)BCD
• (1001001)2 = (49)BCD

9
BCD vs Binary
Tradeoffs between binary number and packed BCD (BCD coded
number)

• BCD takes more storage


• Addition takes additional steps
• Decimal to BCD does not take much time

10
BCD Addition Rules

Step 1 − Perform addition of two BCD numbers by following the rules of binary
addition.

Step 2 − If the result or sum is a 4-bit binary number which is less than or equal to 9,
then the sum is a valid BCD number.

Step 3 − If the sum is a 4-bit number that is greater than 9 or if a carry is generated,
then it is an invalid sum.

Step 4 − To obtain the corrected result/sum, add 6 (0110) to the 4-bit invalid sum. If a
carry is generated when 6 is added, then propagate and add this carry to the next 4-bit
group. This step is done to skip the six illegal BCD codes (i.e. 1010, 1011, 1100, 1101, 1110,
and 1111).

11
BCD Addition Example

12
BCD Addition Example 2

13
2421 Code

● The 2421 code, which is also known as the "Aiken code," is


another BCD code.
● It is a code that has been weighed.
● This is also a scheme for another BCD
● It is to be built using self complementing properties

14
2421 Code

15
How to determine if a coding method is self
complementing?

• 8 4 2 1 => 8+4+2+1=15 which is not equal to 9 – not self


complementing
• 2 4 2 1 => 2+4+2+1 =9, which is equal to 9 – self complementing

Find out yourself:


Are these coding methods self complementing?
• 3311
• 4311

16
Excess-3 Code

● In the excess-3 code, 3 is added to


each individual digit of a decimal
number, and then the binary
equivalent is written.
● For example, the code (278)10 in
excess-3 is represented by 0101101011.
● This code is not weighted.
● Because 3 is added, the decimal digit
"-3" equals "0000" in "Excess-3"

17
Excess 3 Code

18
Excess 3 Code Practice

Decimal to XS-3
• (24)10= (0101 0111)XS-3
• (658)10= (1001 1000 1011) XS-3

19
Is Excess-3 Self-Complementary?

20
Excess-3 Addition
• (984)10 + (599)10 in XS-3
• (27)10 + (39)10 in XS-3
Steps
For A+B in XS-3
1. Add each digit of A and B using binary addition
2. If carry then add it to the next bits and consider this bits as Invalid
3. Add 3 for Invalid bits and subtract 3 for others
4. If there is a carry in the end, simply write it as 0100

21
Gray Code

Discovered by Frank Gray

Unweighted code

Two successive values differ in only 1 bit

Binary numbers are converted to gray code, to


reduce switching operations

Also known as Unit distance code

22
Gray Code Table

23
Binary to Gray Code
• Step1 : Record the MSB as it is
• Step 2 : Add the MSB to the next bit, record the sum and neglect
the carry
• Step 3 : Repeat the process

24
Gray Code to Binary

Step 1: Record the MSB as it is


Step 2 : Add MSB to the next bit of Gray code, record the sum and
neglect the carry
Step3 : Repeat

25
Explore Yourself!

• BCD subtraction
• Excess 3 Subtraction
• Division of fractional numbers

Reference Link
Additional Link:
https://codescracker.com/computer-fundamental/bcd-excess-3-2421-gray-
code.htm

26
THANK YOU!
Reference:
Digital Logic and Computer Design. M. Morris Mano (1979).

27

You might also like