Binary and Decimal Codes: BCD, Gray, and ASCII, Slides of Digital Logic Design and Programming

An overview of various codes used to represent decimal and binary data, including binary coded decimal (bcd), gray codes, and american standard code for information interchange (ascii). It covers the concepts behind these codes, their representations, and their applications.

Typology: Slides

2012/2013

Uploaded on 05/07/2013

anjushree
anjushree 🇮🇳

4.4

(54)

147 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Codes
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Binary and Decimal Codes: BCD, Gray, and ASCII and more Slides Digital Logic Design and Programming in PDF only on Docsity!

Codes

Class 3 outline

  • Alphanumeric Codes
    • ASCII
    • Parity
  • Gray Codes
  • Material from sections 1-5 and 1-6 of text

Binary Codes

  • “An n -bit binary code is a group of n bits that

assume up to 2 n^ distinct combinations of 1s

and 0s, with each combination representing

one element of the set being coded”

  • For the 10 digits need a 4 bit code. One code

is called Binary Coded Decimal (BCD)

Decimal and BCD

  • The BCD is simply the 4

bit representation of the

decimal digit.

  • For multiple digit base 10

numbers, each symbol is

represented by its BCD

digit

  • What happened to 6

digits not used?

Another

  • A second example
    • 3 0 0 1 1
    • +3 0 0 1 1
    • Getting 6 or 0 1 1 0
    • And in range and a BCD digit representation

And now

  • Consider 5 + 5
  • 5 0 1 0 1
  • +5 0 1 0 1
  • giving 1 0 1 0 which is binary 10 but not

a BCD digit!

  • What to do?
  • Try adding 6??

Another carry example

  • Add 7 + 6
    • have 7 0 1 1 1
    • plus 6 0 1 1 0
    • Giving 1 1 0 1 and again out of range
    • Adding 6 0 1 1 0
    • Giving 1 0 0 1 1 so a 1 carries out to the next BCD digit
    • FINAL BCD answer 0001 0011 or 13 (^10)

Multibit BCD

  • • Add the BCD for 417 to
  • • Would expect to get
    • – – BCD setup - start with Least Significant Digit
    • – Adding
    • – Gives

Still Continuing multibit

  • Had a carry to the 3rd BCD digit position
    • 1
    • 0 1 0 0 done done
    • 0 0 0 1 0 0 0 1 0 0 1 0
    • 0 1 1 0
    • And answer is 0110 0001 0010 or the BCD for the base 10 number 612

Alphanumeric Codes

  • How do you handle alphanumeric data?
  • Easy answer!
  • Formulate a binary code to represent

characters! 

  • For the 26 letter of the alphabet would need

5 bit for representation.

  • But what about the upper case and lower

case, and the digits, and special characters

ASCII Code

  • Represents the numbers
    • All start 011 xxxx and the xxxx is the BCD for the digit
  • Represent the characters of the alphabet
    • Start with either 100, 101, 110, or 111
    • A few special characters are in this area
  • Start with 010 – space and !”#$%&’()*+.-,/
  • Start with 000 or 001 – control char like ESC

ASCII Example

  • Encoding of 123
    • 011 0001 011 0010 011 0011
  • Encoding of Joanne
    • 100 1010 110 1111 110 0001
    • 110 1110 110 1110 110 0101
  • Note that these are 7 bit codes

Example of Parity

  • Consider data 100 0001
    • Even Parity 0100 0001
    • Odd Parity 1100 0001
  • Consider data 1010100
    • Even Parity 1101 0100
    • Odd Parity 0101 0100
  • A parity code can be used for ASCII characters

and any binary data.

Other Character Codes

  • Once upon a time, a long, long time ago, there

existed cards, called punch cards!

  • And a code for those cards called Hollerith code. (patented in 1889)
  • The code told you what character was being represented in a column when there was a punch out in various rows of that column.
  • And another code for characters called EBCDIC

(Extended Binary Coded Decimal Interchange

Code) (1963, 1964 IBM) - similar to ASCII –

  • Digits are coded F0 through F9 in EBCDIC