BINARY CODES. Binary Codes. Computer Mathematics I. Jiraporn Pooksook Department of Electrical and Computer Engineering Naresuan University

Similar documents
NUMBERS AND CODES CHAPTER Numbers

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

Multimedia Systems WS 2010/2011

Error Detection and Correction: Hamming Code; Reed-Muller Code

CSE 123: Computer Networks

9 THEORY OF CODES. 9.0 Introduction. 9.1 Noise

Introduction to Digital Logic

1. Basics of Information

Cyclic Redundancy Check Codes

Computer Organization I Test 1/Version 1 CMSC 2833 Autumn 2007

MATH 433 Applied Algebra Lecture 21: Linear codes (continued). Classification of groups.

FYSE410 DIGITAL ELECTRONICS [1] [2] [3] [4] [5] A number system consists of an ordered set of symbols (digits).

ECE 4450:427/527 - Computer Networks Spring 2017

channel of communication noise Each codeword has length 2, and all digits are either 0 or 1. Such codes are called Binary Codes.

IT T35 Digital system desigm y - ii /s - iii

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

Cs302 Quiz for MID TERM Exam Solved

CSCI 220: Computer Architecture-I Instructor: Pranava K. Jha. BCD Codes

Logic. Combinational. inputs. outputs. the result. system can

5 Binary to Gray and Gray to Binary converters:

IOSR Journal of Mathematics (IOSR-JM) e-issn: , p-issn: x. Volume 9, Issue 2 (Nov. Dec. 2013), PP

Z = F(X) Combinational circuit. A combinational circuit can be specified either by a truth table. Truth Table

UNIVERSITI TENAGA NASIONAL. College of Information Technology

Information redundancy

CSE 241 Digital Systems Spring 2013

CSCI 2570 Introduction to Nanocomputing

ELCT201: DIGITAL LOGIC DESIGN

Unit 3 Session - 9 Data-Processing Circuits

Top Ten Algorithms Class 6

Digital Systems Overview. Unit 1 Numbering Systems. Why Digital Systems? Levels of Design Abstraction. Dissecting Decimal Numbers

exercise in the previous class (1)

Textbook: Digital Design, 3 rd. Edition M. Morris Mano

CpE358/CS381. Switching Theory and Logical Design. Summer

Can You Hear Me Now?

Ma/CS 6b Class 24: Error Correcting Codes

MATH3302 Coding Theory Problem Set The following ISBN was received with a smudge. What is the missing digit? x9139 9

Assume that the follow string of bits constitutes one of the segments we which to transmit.

2. Polynomials. 19 points. 3/3/3/3/3/4 Clearly indicate your correctly formatted answer: this is what is to be graded. No need to justify!

Week No. 06: Numbering Systems

Function of Combinational Logic ENT263

MATH3302. Coding and Cryptography. Coding Theory

Chapter 7. Error Control Coding. 7.1 Historical background. Mikael Olofsson 2005

Coding theory: Applications

Carry Look Ahead Adders

Class Website:

Linear Codes and Syndrome Decoding

0 / 1 Now, Binary value of the given number :-

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CS6201 DIGITAL PRINCIPLES AND SYSTEM DESIGN

Modular numbers and Error Correcting Codes. Introduction. Modular Arithmetic.

Ma/CS 6b Class 25: Error Correcting Codes 2

Design of Combinational Logic

( c ) E p s t e i n, C a r t e r a n d B o l l i n g e r C h a p t e r 1 7 : I n f o r m a t i o n S c i e n c e P a g e 1

PAST EXAM PAPER & MEMO N3 ABOUT THE QUESTION PAPERS:

12/31/2010. Digital Operations and Computations Course Notes. 01-Number Systems Text: Unit 1. Overview. What is a Digital System?

Why digital? Overview. Number Systems. Binary to Decimal conversion

Modeling and Simulation NETW 707

UNIT II COMBINATIONAL CIRCUITS:

Getting Connected. Chapter 2, Part 2. Networking CS 3470, Section 1 Sarah Diesburg

CHAPTER 7. Exercises 17/ / /2 2 0

Conversions between Decimal and Binary

MATH Dr. Halimah Alshehri Dr. Halimah Alshehri

Part 1: Digital Logic and Gates. Analog vs. Digital waveforms. The digital advantage. In real life...

University of Florida EEL 3701 Fall 1996 Dr. Eric M. Schwartz

16.36 Communication Systems Engineering

1. How many errors may be detected (not necessarily corrected) if a code has a Hamming Distance of 6?

Error Detection & Correction

Digital Electronics Paper-EE-204-F SECTION-A

Introduction to Quantum Computation

Outline. EECS Components and Design Techniques for Digital Systems. Lec 18 Error Coding. In the real world. Our beautiful digital world.

Lecture 12. Block Diagram

Fundamentals of Digital Design

Digital Logic (2) Boolean Algebra

Cyclic Codes. Saravanan Vijayakumaran August 26, Department of Electrical Engineering Indian Institute of Technology Bombay

Lecture on Sensor Networks

Solutions to problems from Chapter 3

ECS 332: Principles of Communications 2012/1. HW 4 Due: Sep 7

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1

Exam 1. Problem 1: True or false

Optimization of the Hamming Code for Error Prone Media

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary


Fault Tolerant Computing CS 530 Information redundancy: Coding theory. Yashwant K. Malaiya Colorado State University

ECE260: Fundamentals of Computer Engineering

EE 229B ERROR CONTROL CODING Spring 2005

17.1 Binary Codes Normal numbers we use are in base 10, which are called decimal numbers. Each digit can be 10 possible numbers: 0, 1, 2, 9.

ECE 2300 Digital Logic & Computer Organization

Coset Decomposition Method for Decoding Linear Codes

Chapter 3 Linear Block Codes

Communications II Lecture 9: Error Correction Coding. Professor Kin K. Leung EEE and Computing Departments Imperial College London Copyright reserved

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

CPE100: Digital Logic Design I

1.6: Solutions 17. Solution to exercise 1.6 (p.13).

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

MODULAR CIRCUITS CHAPTER 7

Chapter 2. Digital Logic Basics

Save from: cs. Logic design 1 st Class أستاذ المادة: د. عماد

Math 1600B Lecture 4, Section 2, 13 Jan 2014

Computer Architecture, IFE CS and T&CS, 4 th sem. Representation of Integer Numbers in Computer Systems

Additional Gates COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

ENGIN 112 Intro to Electrical and Computer Engineering

Transcription:

Binary Codes Computer Mathematics I Jiraporn Pooksook Department of Electrical and Computer Engineering Naresuan University

BINARY CODES: BCD Binary Coded Decimal system is represented by a group of 4 bits using binary notation from 0000 to 1001. Binary coded decimal is different from hexadecimal because BCD numbers stop at 9 binary 1001 2. The advantage of BCD is that it allows easy conversion between decimal (base-10) and binary (base-2) form. However, the disadvantage is that BCD code is wasteful. Example: 12 to BCD=? 0001 2 = 1 0010 2 = 2 Then, = 0001 0010 Example: 92 to BCD=? 1001 2 = 9 0010 2 = 2 Then, = 1001 0010

BINARY CODES: EXCESS-3 This is an unweighted code. It is obtained from the value of BCD adding by 3. Example: 12 to Excess-3=? 0100 2 = 1 0101 2 = 2 Then, = 0100 0101 Example: 92 to Excess-3=? 1100 2 = 9 0101 2 = 2 Then, = 1100 0101

BINARY CODES: 84-2-1 This is also a weighted code similarly to BCD. Example: 12 to 84-2-1=? 0111 = 1 0110 = 2 Then, = 0111 0110 Example: 92 to 84-2-1=? 1111 = 9 0110 = 2 Then, = 1111 0110

BINARY CODES: 2421 This is also a weighted code similarly to BCD. Example: 12 to 84-2-1=? 0001 = 1 0010 = 2 Then, = 0001 0010 Example: 92 to 84-2-1=? 1111 = 9 0010 = 2 Then, = 1111 0010

SELF-COMPLEMENTING The excess-3, 84-2-1, and 2421 codes are examples of self-complementing codes. Example : Excess-3 395 = 0110 1100 1000 604 = 1001 0011 0111 (The 9 s complement of each number) Figure: Retrieved from Digital Design / M. Morris R. Mano, Micheal D. Ciletti.-3nd ed.

GRAY CODE If the device uses natural binary codes, positions 3 and 4 are next to each other but all three bits of the binary representation differ.in the transition between states 3 and 4, all three switches change state. The transition might look like 011-001-101-100. When the switches appear to be in position 001, the observer cannot tell if that is the "real" position 001, or a transitional state between two other positions. Gray code is cyclic which means it is arranged so that every transition from one value to the next value involves only one bit change. The example of 2 different cyclic gray codes: 000,001,011,010,110,111,101,100 000,001,011,111,101,100,110,010

GRAY CODE Converting Binary to Gray: 1. The most significant bit of the gray number is the most significant bit of the binary code 2. Add the next significant bit of the binary number to the next significant bit of the binary number to obtain the next gray coded bit 3. Repeat until all bits are changed. Example: Binary = 0000 Gray = 0000 Binary = 0001 Gray = 0001 Binary = 0010 Gray = 0011 Binary = 0011 Gray = 0010 Binary = 0100 Gray = 0110

CONSTRUCT N-BIT GRAY CODE n-bit code can be generated by n-1 bit code. Example(from 2 bits to 3 bits): Adding prefix 0 to the gray code in 2 bits Gray = 00 000 Gray = 01 001 Gray = 11 011 Gray = 10 010 Then adding prefix 1 to the reflects Gray = 10 110 Gray = 11 111 Gray = 01 101 Gray = 00 100 This method is the cyclic code.

ERROR DETECTING CODE: BIT PARITY Binary information can transmit from one location to another. The purpose of an error-detection code is to detect bit-reversal errors. A parity bit is an extra bit included with a message to make the total number of 1 s transmitted either odd or even. If the odd parity is adopted, the P bit is chosen such that the total number of 1 s is odd in the five bits that constitute the message and P. If the even parity is adopted, the P bit is chosen such that the total number of 1 s is even in the five bits that constitute the message and P. Even parity is more common.

ERROR DETECTING CODE: BIT PARITY

ERROR DETECTING CODE: BIT PARITY The parity bit s task: If an even parity bit is generated in the sending end for each message transmission, the message together with the parity bit is transmitted to its destination. The parity of the received data is checked. If the parity of the received information is not even, it means that at least one bit has changed value during the transmission. After an error is detected, there are many solution depending on the situation. One possibility is to request retransmission.

EVEN-PARITY BCD Decimal BCD Even-Parity 0 0000 0 1 0001 1 2 0010 1 3 0011 0 4 0100 1 5 0101 0 6 0110 0 7 0111 1 8 1000 1 9 1001 0

EVEN-PARITY BCD If the number of 1 s is odd, then P = 1. If the number of 1 s is even, then P = 0. Example: 0100 1, 0110 0 What if the data 01010 is changed to 01011 Detectable? 11010 Detectable? 11111 Detectable? 00110 Detectable? Problem: Can t detect which bit is in error. Can t detect even numbers of errors.

ERROR-DETECTING CODE: BIT PARITY Minimum distance of a code = smallest no. of bits in which any two codewords differ Example: Message 1 = 01101 Message 2 = 10011 Message 3 = 00110 Message 4 = 11000 Distance between codes: Message 1 and Message 2 = 4 Message 1 and Message 3 = 3 Hence, the minimum distance of a code = 3.

ERROR-DETECTING CODE The capability of code to be error detecting and/or error-correcting can be determined from its minimum distance. If a code s minimum distance is 2c+d+1, it can correct errors in upto c bits and detect errors in upto d additional bits. What is the minimum distance of Even-Parity BCD?

ERROR-DETECTING CODE: 2 OUT OF 5 CODE A two-out-of-five code is an m of n code that provides exactly ten possible combinations. It uses five bits representation. There are ways to assign weights to each bit such that the set bits sum to the desired value, with an exception for zero. A two-out-of-five code can have the number of 1 s = 2. Decimal 01247 0 00011 1 11000 2 10100 3 01100 4 10010 5 01010 6 00110 7 10001 8 01001 9 00101

ERROR-DETECTING CODE: 2 OUT OF 5 CODE If the number of 1 s 2 and the number of 0 s 3, detects as errors. What is the minimum distance of 2-out-of-5 code? What if the data 01010 is changed to 01011 Detectable? 11010 Detectable? 01001 Detectable? 00110 Detectable?

ERROR-CORRECTING After an error is detected, request for retransmission. The sender will send multiple times of data, usually three times. The receiver justifies the error using the repeated messages. Example: Even-Parity BCD Message = 01010 If we receive 01010 (no error) If we receive 01011, we request for a retransmission. Then, we receive 01010 01010 01010 (no error). If we receive, 01011, we request for a retransmission. Then, we receive 01010 01011 01110. (error)

ERROR-CORRECTING: HAMMING CODE It is invented by R. W. Hamming. k parity bits are added to an n-bit data word, forming a new word of n + k bits. The bit positions are numbered in sequence from 1 to n + k. Those positions numbered with powers of two are reserved for the parity bits. The remaining bits are the data bits. The code can be used with words of any length. Example: data 8 bits = 11000100 and four parity bits Bit position 1 2 3 4 5 6 7 8 9 10 11 12 P 1 P 2 1 P 4 1 0 0 P 8 0 1 0 0

ERROR-CORRECTING: HAMMING CODE D 1 D 2 D 3 P 1 x x P 2 x x Add at least 2 parity bits to the data bits. Calculate 2 parity bits from its group. When errors are detected, we can justify with the group of parity bits.

ERROR-CORRECTING: HAMMING CODE Example: 2 parity bits + 3 data bits Data = 101 with even parity hamming code 1 0 1 P 1 x x P 2 x x P 1 = 0 (the number of 1 s is even) P 2 = 1 (the number of 1 s is odd) Thus, message = 01 101

ERROR-CORRECTING: HAMMING CODE Example: 2 parity bits + 3 data bits Data = 101 with even parity hamming code Message = 01 101 If we receive 01 001 1 0 1 P 1 x x P 2 x x (1st bit) parity bit = 0 then the number of 1 s of data bit position 1,3 must be even. (error) data bit position 1 = 0 and data bit position 3 = 1, hence bit position 1 must be 1. (2nd bit) parity bit = 1 then the number of 1 s of data bit position 2,3 must be odd. (correct)

CREATE HAMMING CODE Example: Create hamming code with 3 data bits and 3 parity bits. Data = 101 P 1 = 1, P 2 = 0, P 3 = 1 D 1 =?, D 2 =? Bit position 1 2 3 4 5 6 P 1 P 2 D 1 P 4 D 2 D 3

CREATE HAMMING CODE Any numbers can be written in base 2 as sum of 2 i number 1 2 3 4 5 6 7 2 0 =1 x x x x 2 1 =2 x x x x 2 2 =4 x x x x

CREATE HAMMING CODE Each parity bit depends on its group which is defined by its summation position. P 1 P 2 D 1 P 4 D 2 D 3 2 0 =1 x x x 2 1 =2 x x x 2 2 =4 x x x position 1 2 3 4 5 6 P 1 = XOR of bits D 1,D 2 P 2 = XOR of bits D 1,D 3 P 3 = XOR of bits D 2,D 3

CREATE HAMMING CODE Example: Data = 101 P 1 = XOR of 1, 0 = 1 P 2 = XOR of 1, 1 = 0 P 3 = XOR of 0, 1 = 1 Hence, message = 101101 P 1 P 2 1 P 4 0 1 2 0 =1 x x x 2 1 =2 x x x 2 2 =4 x x x position 1 2 3 4 5 6

1 BIT CORRECTION: HAMMING CODE Example: Message = 101101 If we receive 101111 P 1 P 2 1 P 4 0 1 2 0 =1 x x x 2 1 =2 x x x 2 2 =4 x x x position 1 2 3 4 5 6 check bit 1: = 1 check bits 3,5 = 1,1 (wrong) check bit 2: = 0 check bits 3,6 = 1,1 (ok) check bit 4: = 1 check bits 5,6 = 1,1 (wrong) the bad bit is bit 1+4 = 5. Data is error. It should change bit 5 from 1 to 0.

1 BIT CORRECTION: HAMMING CODE Example: Message = 101101 If we receive 111101 P 1 P 2 1 P 4 0 1 2 0 =1 x x x 2 1 =2 x x x 2 2 =4 x x x position 1 2 3 4 5 6 check bit 1: = 1 check bits 3,5 = 1,0 (ok) check bit 2: = 1 check bits 3,6 = 1,1 (wrong) check bit 4: = 1 check bits 5,6 = 0,1 (ok) the bad bit is bit 2. Parity bit is error. Data is correct.