ch3.pptx
Document Details
Uploaded by SmootherWave2901
Far East University
Full Transcript
Digital Logic Circuit Digital Code Mak(Prof. KIM) A303 010 6201 2453 [email protected] 1 Today's lecture table of contents Numeric Codes Error Detection Codes Alphanumeric Codes...
Digital Logic Circuit Digital Code Mak(Prof. KIM) A303 010 6201 2453 [email protected] 1 Today's lecture table of contents Numeric Codes Error Detection Codes Alphanumeric Codes 2 Overview : Digital Codes (Binary Codes) Digital data is represented, stored and transmitted as groups of binary digits also known as binary code. Weighted codes: In weighted codes, each digit is assigned a specific weight according to its position. Non-weighted codes: In non-weighted codes are not appositionally weighted. Reflective codes: A code is reflective when the code is self complementing. In other words, when the code for 9 is the complement the code for 0, 8 for 1, 7 for 2, 6 for 3 and 5 for 4. Sequential codes: In sequential codes, each succeeding 'code is one binary number greater than its preceding code. Alphanumeric codes: Codes used to represent numbers, alphabetic characters, symbols Error defecting and correcting codes: Codes which allow error defection and correction are called error detecting and' correcting codes. 3 Overview : Classification of Codes (08:18) 4 1. Numeric 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. Example: Consider decimal 185 and its corresponding value in BCD and binary: 1000 + 0111 BCD addition 1111 + 0110 6 0001 0101 1. Numeric Codes 6 1. Numeric Codes Other Decimal Codes 7 1. Numeric Codes Excess-3 code BCD code + 0011 = Excess-3 code Self-Complement Characteristic 10 진수 BCD 코드 3 초과 코드 0 0000 0011 1 0001 0100 2 0010 0101 3 0011 0110 4 0100 0111 5 0101 1000 6 0110 1001 7 0111 1010 8 1000 1011 9 1001 1100 8 1. Numeric Codes Non-weighted code ; Code for special use, such as data conversion decima excess-3 2-out-of-5 code shift counter code gray code l code 0 0011 11000 00000 0000 1 0100 00011 00001 0001 2 0101 00101 00011 0011 3 0110 00110 00111 0010 4 0111 01001 01111 0110 5 1000 01010 11111 0111 6 1001 01100 11110 0101 7 1010 10001 11100 0100 8 1011 10010 11000 1100 9 1100 10100 10000 1101 9 A 2-out-of-5 code is a type of constant-weight code used to represent decimal digits using five bits. In this code, exactly two out of the five bits are set to 1, and the remaining three bits are set to 0. This allows for ten unique combinations, each representing a digit from 0 to 9. A shift count code refers to the number of positions that bits in a binary number are shifted to the left or right. This operation is commonly used in computer programming for tasks like bit manipulation, arithmetic operations, and optimizing performance. Gray code is a binary numeral system where two successive values differ in only one bit. Gray code is a binary numeral system where two successive values differ in only one bit. This property helps to minimize errors in digital communications and is often used in error correction, analog-to-digital converters. 10 1. Numeric Codes Gray Code The advantage is that only bit in the code group changes in going from one number to the next. Using to Analog to Digital Converter Error detection. Representation of analog data. Low power design. (only bit in the code group changes) 000 001 010 011 100 101 110 111 11 1-1 and onto!! Conversion between Binary and Gray codes Binary code Gray code 0 1 1 1 ⊕ ⊕ ⊕ 2진 코 드 그 레 이 코드 0 1 0 0 Gray code Binary code 그 레 이 코드 0 1 0 0 ⊕ ⊕ ⊕ 2진 코 드 0 1 1 1 12 2. Error-Detecting Codes 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: 13 Parity? (08:32) 14 Error-Detecting Codes Hamming code Simple 1 parity bit can tell us an error occurred Multiple parity bits can also tell us where it occurred O(lg(n)) bits needed to detect and correct only one bit error. And as parity bits increase, communication efficiency will inevitably decrease. (This is because parity bits are additionally used for error processing.) Relationship between data bit and parity bit p 1 p p 2 2 p 1 d 2 p 1 if p=4, then 24-1 – 4 + 1 ≤ d ≤24 – 4 – 1 5 ≤ d ≤ 11 When the number of data bits is 5 or more and 11 or less, four parity is required. If data bits are 4 then 3 parity bits needed. Hamming code uses even parity. 2. Error-Detecting Codes Hamming code - Mark with symbols P1, P2, P4, P8, and... depending on the location of the parity - The data bits enter the rest of the locations in order. 비트 위치 1 2 3 4 5 6 7 8 9 10 11 12 기호 P1 P2 D3 P4 D5 D6 D7 P8 D9 D10 D11 D12 P1 영역 P2 영역 P4 영역 P8 영역 2. Error-Detecting Codes Example: Two data blocks, 1011 and 0001. - Create Parity Bit Expand the first block to 7 bits: _ _ 1 _ 0 1 1. Bit 1 is 0, because b3+b5+b7 is even. Bit 2 is 1, b3+b6+b7 is odd. Bit 4 is 0, because b5+b6+b7 is even. Our 7 bit block is: 0 1 1 0 0 1 1 If you received data from the second block including parity, 1 1 1 1 0 0 1 Check each parity bit Bits 1 and 2 are incorrect 1 + 2 = 3, so the error occurred in bit 3 Checking for right block giving Error detectings: 1 1 0 1 0 0 1 17 2. Error-Detecting Codes 8 bits data P1 D3 D5 D7 D9 D11 P2 D3 D6 D7 D10 D11 P4 D5 D6 D7 D12 P8 D9 D10 D11 D12 for example 00101111 P1 P2 D3 P4 D5 D6 D7 P8 D9 D10 D11 D12 0 0 1 0 1 1 1 0 P1 D3 D5 D7 D9 D11 0 0 0 1 1 0 P2 D3 D6 D7 D10 D11 0 1 0 1 1 1 P4 D5 D6 D7 D12 0 1 0 0 1 P8 D9 D10 D11 D12 1 1 1 0 1 2. Error-Detecting Codes 19 Error Detection (12:19) 20 Error Correction (05:32) 21 3. Alphanumeric Codes Standard BCD Code Minimal bits are used for representation of text materials. Express one character with 6 bit. (Upper case and lower case indistinguishable) Maximum 64 character can be represented.(2 6 = 64) Only used in digital systems for specific purposes. Parity Zone Bit Digit Bit 6 5 4 3 2 1 0 1 1 A~I (0001~1001) 1 0 J~R (0001~1001) 0 1 S~Z (0010~1001) C 0 0 0~9 (0001~1010) Mixed Special characters and other characters 3. Alphanumeric Codes Standard BCD Code 문자 C ZZ8421 문자 C ZZ8421 문자 C ZZ8421 문자 C ZZ8421 문자 C ZZ8421 A 0 110001 J 1 100001 S 1 010010 1 0 000001 = 0 001011 B 0 110010 K 1 100010 T 0 010011 2 0 000010 > 1 001100 C 1 110011 L 0 100011 U 1 010100 3 1 000011 + 0 010000 D 0 110100 M 1 100100 V 0 010101 4 0 000100 , 1 011011 E 1 110101 N 0 100101 W 0 010110 5 1 000101 ) 0 011100 F 1 110110 O 0 100110 X 1 010111 6 1 000110 % 1 011101 G 0 110111 P 1 100111 Y 1 011000 7 0 000111 ? 0 011111 H 0 111000 Q 1 101000 Z 0 011001 8 0 001000 - 1 100001 I 1 111001 R 0 101001 9 1 001001 @ 1 111010 0 1 001010 $ 1 111111 3. Alphanumeric Codes EBCDIC(Extended Binary Coded Decimal Interchange Code) Code Used primarily on IBM medium and large computers Express one character with 8 bit. Maximum 256 character can be represented.(28 = 256) b9 b 8 b7 b6 b5 b 4 b3 b2 b1 parity zone digit 1 4 4 b 8 b7 b 6 b5 0 0 Communication control character 0 1 Special character 0 0 a ~i 0 1 j~r 1 0 Lower case 1 0 s~z 1 1 0 0 A~I 1 1 Upper case/numeric 0 1 J~R 1 0 S~Z 1 1 0~9 3. Alphanumeric Codes EBCDIC(Extended Binary Coded Decimal Interchange Code) Code 16 진 0 1 2 3 4 5 6 7 8 9 A B C D E F 2 진 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 0000 NUL SOH STX ETX HT DEL VT FF CR SO SI 1 0001 DLE BS CAN EM IFS IGS IRS IUS 2 0010 LF ETB ESC ENQ ACK BEL 3 0011 SYN EOT NAK SUB 4 0100 space [. ( + | 5 0101 & ! $ * ) ^ 6 0110 - / | , % _ > ? 7 0111 ` : # @ ‘ = " 8 1000 a b c d e f g h i 9 1001 j k l m n o p q r A 1010 ~ s t u v w x y z B 1011 C 1100 { A B C D E F G H I D 1101 } J K L M N O P Q R E 1110 \ S T U V W X Y Z F 1111 0 1 2 3 4 5 6 7 8 9 3. Alphanumeric Codes ASC-II (American Standard Code for Information Interchange) code Use on personal computer. Express one character with 7 bit. Maximum 128 character can be represented.(27 = 128) For communications, use 8 bit (added parity) parity zone bit digit bit 7 6 5 4 3 2 1 0 1 0 0 A~O (0001~1111) C 1 0 1 P~Z (0000~1010) 0 1 1 0~9 (0000~1001) 3. Alphanumeric Codes ASC-II (American Standard Code for Information Interchange) code 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 NUL SOH STX ETX EOT ENQ ACK BEL BS TAB LF VT FF CR SO SI 1 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 2 ! " # $ % & ' ( ) * + , -. / 3 0 1 2 3 4 5 6 7 8 9 : ; = > ? 4 @ A B C D E F G H I J K L M N O 5 P Q R S T U V W X Y Z [ \ ] ^ _ 6 ` a b c d e f g h i j k ㅣ m n o 7 p q r s t u v w x y z { | } ~ DEL Homework #1 1. Convert the following binary digits to gray code and gray code to binary digits. 1) 1011(2) 2) 0111(2) 3) 1110(G) 4) 1101(G) 2. Detect and correct errors in the following hamming codes. ①101101111110 ②011011001110 ③011000001010110 28 Thank you! See you next time. Mak(Prof. KIM) A303 010 6201 2453 [email protected] 29 I think I took away your precious time for a while with my new car-related call last week. I got a new car because of your consideration, and I've prepared some snacks, so let's take a break and have a good time. 30