Chapter 4 Computer Codes
Chapter 4 Computer Codes
Chapter 4 Computer Codes
Chapter 4
Computer Codes
• BCD addition
11/9/22 3
Digital Logic Design Ch1-3
Binary Code
• Example:
– Consider the addition of 184 + 576 = 760 in BCD:
11/9/22 4
Digital Logic Design Ch1-4
Binary Codes
• Other Decimal Codes
11/9/22 5
Digital Logic Design Ch1-5
Binary Codes)
• Gray Code
– The advantage is that only bit in the
code group changes in going from one
number to the next.
• Error detection.
• Representation of analog data.
• Low power design.
000 001
010 011
100 101
110 111
11/9/22
1-1 and onto!! 6
Digital Logic Design Ch1-6
Binary Codes
American Standard Code for Information Interchange (ASCII) Character Code
11/9/22 7
Digital Logic Design Ch1-7
Binary Codes
• ASCII Character Code
11/9/22 8
Digital Logic Design Ch1-8
ASCII Character Codes
• A popular code used to represent information sent as
character-based data.
• It uses 7-bits to represent:
– 94 Graphic printing characters.
– 34 Non-printing characters.
• Some non-printing characters are used for text format
(e.g. BS = Backspace, CR = carriage return).
• Other non-printing characters are used for record
marking and flow control (e.g. STX and ETX start and
end text areas).
11/9/22 9
Digital Logic Design Ch1-9
ASCII Properties
• ASCII has some interesting properties:
– Digits 0 to 9 span Hexadecimal values 3016 to 3916
– Upper case A-Z span 4116 to 5A16
– Lower case a-z span 6116 to 7A16
• Lower to upper case translation (and vice versa) occurs
by flipping bit 6.
11/9/22 10
Digital Logic Design Ch1-10
Binary Codes
• Error-Detecting Code
– To detect errors in data communication and
processing, an eighth bit is sometimes added to
the ASCII character to indicate its parity.
– A parity bit is an extra bit included with a message
to make the total number of 1's either even or
odd.
• Example:
– Consider the following two characters and their
even and odd parity:
11/9/22 11
Digital Logic Design Ch1-11
Binary Codes
• Error-Detecting Code
– Redundancy (e.g. extra information), in the form of extra bits, can
be incorporated into binary code words to detect and correct
errors.
– A simple form of redundancy is parity, an extra bit appended onto
the code word to make the number of 1’s odd or even. Parity can
detect all single-bit errors and some multiple-bit errors.
– A code word has even parity if the number of 1’s in the code word
is even.
– A code word has odd parity if the number of 1’s in the code word
is odd.
– Example: Message A: 100010011 (even parity)
Message B: 10001001 0 (odd parity)
11/9/22 12
Digital Logic Design Ch1-12