Digital Logic Lecture 4 Binary Codes

Similar documents
Digital Fundamentals

Chapter 2 Number Systems and Codes Dr. Xu

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

BINARY SYSTEM. Binary system is used in digital systems because it is:

Binary Codes. Dr. Mudathir A. Fagiri

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

umber Systems bit nibble byte word binary decimal

Digital Logic Lecture 2 Number Systems

Chapter 3 DATA REPRESENTATION

Binary. Hexadecimal BINARY CODED DECIMAL

Systems Programming. Lecture 2 Review of Computer Architecture I

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

OBJECTIVES After reading this chapter, the student should be able to:

SE311: Design of Digital Systems

Positional Number System

that system. weighted value associated with it. numbers. a number. the absence of a signal. MECH 1500 Quiz 2 Review Name: Class: Date:

Review of Number Systems

Chapter 4: Computer Codes. In this chapter you will learn about:

MACHINE LEVEL REPRESENTATION OF DATA

CHW 261: Logic Design

D I G I T A L C I R C U I T S E E

Digital Fundamentals

CHAPTER 2 Data Representation in Computer Systems

Module -10. Encoder. Table of Contents

CHAPTER 2 Data Representation in Computer Systems

a- As a special case, if there is only one symbol, no bits are required to specify it.

The Gray Code. Script

Data Representation and Binary Arithmetic. Lecture 2

UNIT 7A Data Representation: Numbers and Text. Digital Data


Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Lecture (03) Binary Codes Registers and Logic Gates

DIGITAL SYSTEM DESIGN

M1 Computers and Data

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

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

Lecture 2: Number Systems

Number codes nibble byte word double word

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

Information Science 1

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Digital Fundamentals

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

ENEE x Digital Logic Design. Lecture 3

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

Hybrid Electronics Laboratory

Thus needs to be a consistent method of representing negative numbers in binary computer arithmetic operations.

Lecture (02) Operations on numbering systems

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

Chap 1. Digital Computers and Information

ECE 20B, Winter Purpose of Course. Introduction to Electrical Engineering, II. Administration

Binary Systems and Codes

FE Review Computer Terms

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

EEM336 Microprocessors I. Arithmetic and Logic Instructions

Introduction to Numbering Systems

Character Codes and Error Detec=on

Microcomputers. Outline. Number Systems and Digital Logic Review

Unit - II. Computer Concepts and C Programming 06CCP13. Unit II

IBM 370 Basic Data Types

EE292: Fundamentals of ECE

CHAPTER 2 (b) : AND CODES

Chapter 10 Error Detection and Correction 10.1

Lecture (02) Network Protocols and Standards

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

1.1 Information representation

Computer Organization

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-II COMBINATIONAL CIRCUITS

SCR 1013 : Digital Logic Module 2: NUMBER SYSTEM & CODES

Sender Receiver Sender

REPRESENTING INFORMATION:

FAULT TOLERANT SYSTEMS

Introduction to Computers - Chapter 4

1. Draw general diagram of computer showing different logical components (3)

15110 Principles of Computing, Carnegie Mellon University - CORTINA. Digital Data

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

KING FAHD UNIVERSITY OF PETROLEUM & MINERALS COMPUTER ENGINEERING DEPARTMENT

Computer Logical Organization Tutorial

Korea University of Technology and Education

Basic data types. Building blocks of computation

Stonelaw High School. Computing Science. BGE - Computer Systems

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

Chapter 1. Digital Systems and Binary Numbers

Fundamentals of Programming (C)

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Chapter 2. Data Representation in Computer Systems

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Chapter 10 Error Detection and Correction. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Digital Systems and Binary Numbers

NUMBER SYSTEMS AND CODES

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Transcription:

Digital Logic Lecture 4 Binary Codes By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department

Outline Introduction. Character coding. Error detection codes. Gray code. Decimal coding. The Hashemite University 2

Introduction Binary code is a sequence of 1 and 0 to represent specific values or quantities. Simply it is a substitution or a simplification technique. Binary code objectives: Security assurance: encryption and decryption techniques used to secure communication and data storage. Civil applications: such as text coding in computers, and codes used to reduce digital communication errors opportunities. Mainly we are interested in civil applications. The Hashemite University 3

General Rules of Binary Codes For n-bit binary code, the number of values that can be codes (or simply the max number of codes) = 2 n. The min number of bits required to code m values = ciel[log 10 m/log 10 2]. The max number of bit used to code m values can be >= min limit computed using the above equation (i.e. there is no restrictions on the maximum limit of the used bits). Each value must be assigned a unique code and vice versa to enable correct encoding and decoding. The Hashemite University 4

Binary Codes Types Character coding. Error detection codes. Gray code. Decimal coding. The Hashemite University 5

Character Coding -- ASCII ASCII stands for American Standard Code for Information Interchange. It is a 7-bit code. So, each character is assigned a 7- bit binary value. This value is used by the digital systems (e.g. Computers) to correctly store and manipulate text data. Originally used on non IBM systems. Basis of most currently used digital systems. Need to add an additional bit to make the code 8-bit to be stored in a byte. Two options are provided: Simply add 0 in the MSB. Use it in even or odd-parity error detection coding as will be seen later. The Hashemite University 6

ASCII Table The Hashemite University 7

Character Coding -- EBCDIC EBCDIC stands for Extended Binary Coded Decimal Interchange Code. 8-bit code. Originally used in IBM mainframes. Provide a larger set of codes than ASCII. Less common than ASCII. The Hashemite University 8

Character Coding -- Unicode Designated as the universal code for text coding. Comes to provide a large set of codes, i.e. solve the limitations found in ASCII and EBCDIC. 16-bit code. Used in the Internet. The Hashemite University 9

Error Detection Codes I Data communication requires special codes and algorithms to determine whether the received data is the same as the one transmitted, i.e. error free. The simplest error detection code is based on adding a parity bit for ASCII code. Parity means that two things are equal (identical). Simply add a 1 or 0 to the MSB in ASCII (parity) to make the number of ones in that byte either odd (odd parity) or even (even parity). Even parity is most common. E.g.: for 0111100 add 0 to MSB to obtain an even parity and 1 to obtain an odd parity. The Hashemite University 10

Error Detection Codes II The sender and the receiver know in advance the used parity type (odd or even). The sender add the parity bit to each byte before transmission. The receiver checks the parity before decoding the data. Assume that even parity is used, if the number of ones in a byte found to be odd, this means that there is an error in this byte. The Hashemite University 11

Error Detection Codes III Disadvantages: Both even and odd parity can detect odd number of error bits only. So, if two bits are in error for example, the parity remains correct. Parity cannot determine the locations of the bits in error. Cannot determine the number of bits in error. What to do when detecting an error in the received message? Ask the sender to retransmit the message. Or use an error correction algorithm to recover the original message. The Hashemite University 12

Gray Code Also, known as The Reflected Binary Code. The main idea of Gray code is that any two subsequent codes differ in one bit only. Useful for error detection and correction in digital communication systems. Manly used in applications that produce values in an increasing (or decreasing) order, i.e. similar to the counter concept. Gray code can be 1-bit, 2-bit, 3-bit, etc., based on the number of values needed to be coded. The Hashemite University 13

3-bit Gray Code Decimal Binary Gray Code 0 000 000 1 001 001 2 010 011 3 011 010 4 100 110 5 101 111 6 110 101 7 111 100 The Hashemite University 14

Gray Code Conversion I The first method includes conversion in one direction only (from binary value to Gray). Start from the LSB, if the next bit (in the higher significance location) is 1 invert the current bit. If it is 0 then do not change the current bit. E.g. convert 11011 to Gray code. 11011 1 0 1 1 0 Answer = 10110 Remains the same since the bit after it is 0 Inverted (1 0) since the bit after it is 1 The Hashemite University 15

Gray Code Conversion II The second method includes conversion in two directions and it is based on the usage of the XOR logical function. Convert Binary to Gray as follows: Copy the most significant bit For each smaller i do G[i] = XOR(B[i+1], B[i]) (to convert binary to Gray) The Hashemite University 16

Gray Code Conversion III Convert Gray to Binary as follows: Copy the most significant bit B[i] = XOR(B[i+1], G[i]) (to convert Gray to binary) The Hashemite University 17

Decimal Coding I BCD is the main example of decimal coding. BCD Code (Binary Coded Decimal): A code used to represent each decimal digit of a number by a 4-Bit Binary Value. Valid Digits for 0-9 are (0000 to 1001) the binary codes 1010 to 1111 are invalid. So, the BCD code of each digit is the binary conversion of that decimal digit. BCD comes to provide: A solution for the difficulty of the conversion between binary and decimal. Easier to be understood by humans. The Hashemite University 18

Decimal Coding II Decimal BCD 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 The Hashemite University 19

Decimal Coding III For a compound number of decimal (multidigit number) the BCD of that number is simply the substitution of the BCD code of each digit. E.g. 123 10 000100100011 (BCD) So, n digit decimal number needs 4*n binary bits to be represented in BCD. Pay attention to number justification when it is in BCD. Also, note that numbers in BCD are decimal not binary numbers. The Hashemite University 20

Decimal Coding IV Note that a BCD digit needs 4 bit to be stored. The smallest storage unit in computer is byte which is larger than what needed by 1 BCD digit. There are two types of BCD code depending on how to store BDC digits in a byte. BCD code types: Packed BCD: a byte can store two BCD digits. So, for example, the number 8678 10 needs 2 bytes. Unpacked BCD: a byte can store one BCD digit in the lower nibble while the higher nibble contains zeros. So, for example, the number 8678 10 needs 4 bytes. The Hashemite University 21

Additional Notes This lecture covers the following material from the textbook: Chapter 1: Section 1.7 The Hashemite University 22