0% found this document useful (0 votes)
7 views17 pages

1 Codes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views17 pages

1 Codes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Codes

Digital Design. M. Morris Mano


Prof. Imane Aly Saroit Ismail 1 Logic Design
Binary Codes

• A binary code is defined as a coding system that


uses two binary digits (0,1), to represent a letter or a
number.
• Having n digits (each of 0,1), this n digits can code
2n different elements.

Prof. Imane Aly Saroit Ismail 2 Logic Design


Binary Coded Decimal (BCD)

• BCD Code uses 4 bits to


represent the 10 decimal
digits {0 to 9}
• 6 BCD codes are unused
{1010 – 1011 – 1100 –
1101 – 1110 – 1111}

Prof. Imane Aly Saroit Ismail 3 Logic Design


Binary Coded Decimal (BCD)
(Examples)
Examples:
(5463)10=( ?)BCD
From the previous table
5→
→0101 4→
→0100 6→
→0110 3→
→0011
So
(5463)10=(0101 0100 0110 0011)BCD

Prof. Imane Aly Saroit Ismail 4 Logic Design


Binary Coded Decimal (BCD)
(Examples)
• (1001 0111 0010.1000 0000 0010)BCD=( ?)10
• (1101 0111 0010.1000 0000 0010)BCD=( ?)10
Using the table
• (1001 0111 0010.1000 0000 0010)BCD=(972.802)10
• (1101 0111 0010.1000 0000 0010)BCD is not a BCD
number is 1101 does not represents a BCD code.

Prof. Imane Aly Saroit Ismail 5 Logic Design


Binary Coded Decimal (BCD)
(Addition)
• Adding two BCD numbers together with a carry of 1
may lead to result =19 (9+9+1).
• As BCD can represent only numbers from 0 to 9, so
when the resulting number of the addition is greater
than 9 (invalid number). In this case we should add 6
(0110) to the result.

Prof. Imane Aly Saroit Ismail 6 Logic Design


Binary Coded Decimal (BCD)
(Addition-Example)

Prof. Imane Aly Saroit Ismail 7 Logic Design


Binary Coded Decimal (BCD)
(Subtraction)
• (A)BCD - (B)BCD = (A)BCD + 9’s Comp(B)BCD + 1
• 9’s Complement of a BCD code is the number which
if added to the original code the sum will be 9.
• 9’s Comp(0101 0100 0110 0011)BCD
=(0100 0101 0011 0110)

Prof. Imane Aly Saroit Ismail 8 Logic Design


Binary Coded Decimal (BCD)
(Subtraction-Example)

Prof. Imane Aly Saroit Ismail 9 Logic Design


Binary Coded Decimal (BCD)
(Subtraction-Example)

Prof. Imane Aly Saroit Ismail 10 Logic Design


Other Decimal Codes (Gray Code)

• The Gray code is defined as an ordering of the


binary number system such that each incremental
value can only differ by one bit. Meaning that only
one bit in the code changes in going from one
number to the next.
• For example in BCD code from 7 (0111) to 8 (1000)
the whole four bits are changed, while in gray code
from 7 (0100) to 8 (1100), only one bit changes.
Prof. Imane Aly Saroit Ismail 11 Logic Design
Other Decimal Codes (Gray Code)

Prof. Imane Aly Saroit Ismail 12 Logic Design


Other Decimal Codes

Prof. Imane Aly Saroit Ismail 13 Logic Design


ASCII Code

• The American Standard Code for Information Interchange


(ASCII) code is a table or list containing all the letters of
the alphabet plus a variety of additional characters. In this
code, each character is represented by an order number,
which is always the same.

Prof. Imane Aly Saroit Ismail 14 Logic Design


ASCII Code

• It is composed of 7 bits (i.e. 27 = 128 characters)


• 94 printable, 34 non-printable (control)
• 2x26 English letters (A,…Z, a,…z)
• 10 decimal digits (0,1,…9)
• 32 special characters such as %, *, $, … etc.
• 34 control characters (with special uses).
• Usually stored as a byte, where the extra bit is used for
other purposes depending on the application..

Prof. Imane Aly Saroit Ismail 15 Logic Design


ASCII Code

Prof. Imane Aly Saroit Ismail 16 Logic Design


ASCII Code

Prof. Imane Aly Saroit Ismail 17 Logic Design

You might also like