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

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

Digital Fundamentals

CHW 261: Logic Design

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

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

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

Digital Systems and Binary Numbers

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Chapter 2. Data Representation in Computer Systems

Chapter 2: Number Systems

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

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

Chapter 1 Review of Number Systems

Module 2: Computer Arithmetic

CHAPTER 2 (b) : AND CODES

Binary Systems and Codes

DIGITAL SYSTEM DESIGN

Digital Fundamentals

CHAPTER 2 Data Representation in Computer Systems

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

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

CHAPTER 2 Data Representation in Computer Systems

NUMBER SYSTEMS AND CODES

Lecture 2: Number Systems

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.

Korea University of Technology and Education

Number System. Introduction. Decimal Numbers

Numbering systems. Dr Abu Arqoub

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

Review of Number Systems

MACHINE LEVEL REPRESENTATION OF DATA

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

Positional Number System

Number Systems Base r

Lecture (02) Operations on numbering systems

Computer Organization

Internal Data Representation

Chapter 1. Digital Systems and Binary Numbers

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

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

Digital Fundamentals

Digital Systems and Binary Numbers

Number Systems CHAPTER Positional Number Systems

The Gray Code. Script

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

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

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Lecture (03) Binary Codes Registers and Logic Gates

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

umber Systems bit nibble byte word binary decimal

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

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

Chapter 2. Data Representation in Computer Systems

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

EE292: Fundamentals of ECE

Final Labs and Tutors

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Number representations

Chapter 2 Data Representations

Bits, Words, and Integers

Binary Codes. Dr. Mudathir A. Fagiri

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

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

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION. Data Representation in Computer Systems

Chap 1. Digital Computers and Information

in this web service Cambridge University Press

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

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

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

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

MC1601 Computer Organization

Chapter 2 Number Systems and Codes Dr. Xu

Level ISA3: Information Representation

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

Chapter 3 Data Representation

Chapter 2. Data Representation in Computer Systems. Objectives (1 of 2) Objectives (2 of 2)

Data Representations & Arithmetic Operations

Electronic Data and Instructions

COMPUTER ARITHMETIC (Part 1)

Binary. Hexadecimal BINARY CODED DECIMAL

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

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

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

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

Digital Systems and Binary Numbers

Number codes nibble byte word double word

Chapter 3 DATA REPRESENTATION

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

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

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

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Agenda EE 224: INTRODUCTION TO DIGITAL CIRCUITS & COMPUTER DESIGN. Lecture 1: Introduction. Go over the syllabus 3/31/2010

EEM336 Microprocessors I. Arithmetic and Logic Instructions

Transcription:

COURSE / CODE DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) NUMBER SYSTEM A considerable subset of digital systems deals with arithmetic operations. To understand the operation of this class of circuits, it is necessary to understand the representation of numbers. All modern number systems use the radix representation (from Hindus via Arabia). Its format is: 1. The position of a symbol within a number indicates the multiplication by a relevant power of the base. 2. A special symbol is used to represent nothing (zero). 3. The number of different symbols is restricted to the base quantity. Decimal Numbers Decimal number system, in mathematics, is a positional numeral system employing 10 as the base and requiring 10 different numerals, the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. It also requires a dot (decimal point) to represent decimal fractions. In this scheme, the numerals used in denoting a number take different place values depending upon position. In a base-10 system the number 543.21 represents the sum (5 10 2 ) + (4 10 1 ) + (3 10 0 ) + (2 10 1 ) + (1 10 2 ). Binary Numbers The binary numeral system, or base-2 number system represents numeric values using two symbols, usually 0 and 1. More specifically, the usual base-2 system is a positional notation with a radix of 2. Owing to its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by all modern computers. Representation of a binary number. Binary Number Conversion To convert from a base-10 integer numeral to its base-2 (binary) equivalent, the number is divided by two, and the remainder is the least-significant bit. The (integer) result is again divided by two, its remainder is the next most significant bit. This process repeats until the result of further division becomes zero. The example shows how decimal number 32 is converted into binary using the division method. The answer is read from the bottom (MSB) upwards (LSB) and is 1000002. Conversion from base-2 to base-10 proceeds by applying the preceding algorithm, in reverse. The bits of the binary number are used one by one, starting with the most significant bit. Beginning with the value 0, repeatedly double the prior value and add the next bit to produce the next value. This can be organized in a multi-column table. For example, to convert the binary number 100101011012 into decimal: Binary: 1 0 0 1 0 1 0 1 1 0 1 Decimal: 1 2 10 + 0 2 9 + 0 2 8 + 1 2 7 + 0 2 6 + 1 2 5 + 0 2 4 + 1 2 3 + 1 2 2 + 0 2 1 + 1 2 0 = 1197 Mohd Uzir Kamaluddin / Aug 2016 page 1

Fractional decimal number To convert a fractional decimal number into binary, the method is as follows: Decimal number: 0.684 0.684 x 2 = 1.368 1 0.368 x 2 = 0.736 0 0.736 x 2 = 1.472 1 0.472 x 2 = 0.944 0 0.944 x 2 = 1.888 1 giving the result as: 0.10101 (read from top to bottom). Short-Cut method Another way to convert Q m binary numbers to decimal is to represent the binary number as a signed integer, and to divide by 2 m. To convert a decimal number to Q m, multiply the number by 2 m and take the rightmost m digits. Note, this simply truncates the number; it is more elegant, and accurate, but slightly more complicated, to round the number. 1. Convert 0.100 1001 to decimal. Take the binary number 0100 1001 (=73), and divide by 2 7 =128. The answer is 73/128=0.5703125. 2. Convert 1.100 1001 to decimal. Take the two's complements binary number 1100 1001 (=-55), and divide by 128. The answer is - 0.4296875. 3. Convert 0.9 to 7-bit format. Multiply 0.9 by 128 to get 115.2. This is represented in binary as 111 0011, so the 7-bit representation is 0.111 0011. 4. Convert -0.9 to 7-bit format. Multiply -0.9 by 128 to get -115.2. The 7-bit representation is 1.000 1101. Exercises 1. Convert 63.2510 to binary. 2. Convert 43.812510 to binary. 3. Convert 1001011.0112 to decimal. 4. Convert 110101.10112 to decimal. Binary Arithmetic The common arithmetic operations that are carried out on binary numbers are addition and subtraction operations. 1 + 1 = 102 1 1 = 0 1 + 0 = 1 1 0 = 1 0 + 1 = 1 0 0 = 0 0 + 0 = 0 0 1 = 112 For example: Multiplication Multiplying unsigned numbers in binary is quite easy. Recall that with 4 bit binary numbers, it can represent numbers from 0 to 15. Multiplication can be performed done exactly as with decimal numbers, except that they have only two digits (0 and 1). The only number facts to remember are that 0*1=0, and 1*1=1 (this is the same as a logical "and"). Mohd Uzir Kamaluddin / Aug 2016 page 2

Multiplication is different than addition in that multiplication of an n bit number by an m bit number results in an n+m bit number. Let's take a look at an example where n=m=4 and the result is 8 bits. Decimal 10 x6 60 Binary 1010 x0110 0000 1010 1010 +0000 0111100 In this case the result was 7 bit, which can be extended to 8 bits by adding a 0 at the left. When multiplying larger numbers, the result will be 8 bits, with the leftmost set to 1, as shown. Decimal 13 x14 182 Binary 1101 x1110 0000 1101 1101 +1101 10110110 As long as there are n+m bits for the result, there is no chance of overflow. For 2 four bit multiplicands, the largest possible product is 15*15=225, which can be represented in 8 bits. Signed Numbers In computing, signed number representations are required to encode negative numbers in binary number systems. In mathematics, negative numbers in any base are represented by prefixing them with a minus (" ") sign. However, in computer hardware, numbers are represented only as sequences of bits, without extra symbols. The left-most bit in a signed binary number is the sign bit, which inform the user whether the number is positive or negative. LEFT MOST BIT INDICATION Example 0 Positive number 01010011 1 Negative number 10010010 Sign-Magnitude Form When a signed binary number is represented in sign-magnitude form, the left-most bit is the sign bit and the remaining bits are the magnitude bits. The magnitude bits are in true (un-complemented) binary for both positive and negative numbers. For example, the number +25 is expressed as an 8-bit signed binary number using the sign-magnitude form as 00011001 and the number -25 is expressed as 10011001. Exercises 1. Convert the following decimal values into signed binary numbers using the sign-magnitude format: -15 as a 6-bit number -56 as an 8-bit number +23 as a 6-bit number +85 as an 8-bit number Mohd Uzir Kamaluddin / Aug 2016 page 3

-127 as an 8-bit number Complements of Binary Numbers Complement means opposite. If a binary number is complemented, the result is the opposite of the original number. There are two types of complements in binary system, that is, one s and two s complements. Two s complement is especially important because it allows to represent signed numbers in binary, and one s complement is the interim step to finding the two s complement. One s complement The ones' complement of a binary number is defined as the value obtained by inverting all the bits in the binary representation of the number (swapping 0s for 1s and vice versa). The ones' complement of the number then behaves like the negative of the original number in some arithmetic operations. To within a constant (of 1), the ones' complement behaves like the negative of the original number with binary addition. However, unlike two's complement, these numbers have not seen widespread use because of issues such as the offset of 1, that negating zero results in a distinct negative zero-bit pattern, less simplicity with arithmetic borrowing, etc. An N-bit one s complement numeral system can only represent integers in the range (2 N 1 1) to 2 N 1 1. Decimal 1 s compl. Decimal 1 s compl. 0 0000-0 1111 1 0001-1 1110 2 0010-2 1101 3 0011-3 1100 4 0100-4 1011 5 0101-5 1010 6 0110-6 1001 7 0111-7 1000 Positive numbers are the same simple, binary system used by two's complement and sign-magnitude. Negative values are the bit complement of the corresponding positive value. The largest positive value is characterized by the sign (high-order) bit being off (0) and all other bits being on (1). The smallest negative value is characterized by the sign bit being 1, and all other bits being 0. The table above shows all possible values in a 4-bit system, from 7 to +7. Two s Complement A two's-complement system or two's-complement arithmetic is a system in which negative numbers are represented by the two's complement of the absolute value; this system is the most common method of representing signed integers on computers. In such a system, a number is negated (converted from positive to negative or vice versa) by computing its two's complement. The two's-complement system has the advantage of not requiring that the addition and subtraction circuitry examine the signs of the operands to determine whether to add or subtract. This property makes the system both simpler to implement and capable of easily handling higher precision arithmetic. Also, zero has only a single representation, obviating the subtleties associated with negative zero, which exists in ones'-complement systems. An N-bit two s complement numeral system can represent integers in the range express 2 N 1 to +2 N 1 1. Mohd Uzir Kamaluddin / Aug 2016 page 4

Decimal 2 s compl. Decimal 2 s compl. 0 0000-1 1111 1 0001-2 1110 2 0010-3 1101 3 0011-4 1100 4 0100-5 1011 5 0101-6 1010 6 0110-7 1001 7 0111-8 1000 The table above shows all possible values in a 4-bit system, from 8 to +7. Method to find two s complement of a number Invert all bits (i.e. 0 -> 1 and 1 -> 0) and then add 1 to the result. For example: To find the two s complement representation of 25 (in binary = 0110012) By inverting all bits, resulting value is 100110 and then by adding a 1, resulting in final value 100111 Thus, -25 = 100111 The value of a two's-complement binary number can be calculated by adding up the power-of-two weights of the "one" bits, but with a negative weight for the most significant (sign) bit; for example: 111110112 = 128 + 64 + 32 + 16 + 8 + 0 + 2 + 1 = 5 Exercises 1. Convert the following decimal numbers into its two s complement form: a) 156 b) -156 2. Convert the following two s complement numbers into decimal: a) 01110011 b) 10111010 Arithmetic Operations with Signed Numbers It is very important to know how the binary numbers are being manipulated by addition, subtraction, multiplication and division operations since in any modern computer systems, these are the fundamental operations carried out by the computer system. Most computer systems use the two s complement form in representing numbers and therefore the discussion will only focus on two s complement arithmetic. Addition The two numbers in an addition are the addend and the augend. The result is the sum. Mohd Uzir Kamaluddin / Aug 2016 page 5

Subtraction Subtraction is a special case of addition. The two numbers in a subtraction operation are the subtrahend and the minuend. The result is the difference. For example, subtracting +6 (the subtrahend) from +9 (the minuend) is the same as adding -6 to +9. The sign of a positive or negative binary number is changed by taking its 2 s complement. Example 1: 00001000 00000011 = 1 00000101 => 8-3=5 changed to 8+(-3)=5, carry is discarded. Example 2: 00001100 00001001 = 00010101 => 12-(-9) changed to 12+9=21. Example 3: 11100111 00010011 = 1 11010100 => -25-(+19) changed to -25+(-19)=-44, discard carry. Example 4: 10001000 00011110 = 10100110 => (-120-(-30)) changed to -120+30=-90. Multiplication The two numbers in a multiplication operation are the multiplicand and the multiplier. The result is the product. For example, 8x3=24. The number 8 is called the multiplicand, 3 is the multiplier and 24 is the product. In a computer system, multiplication is done through direct addition. For example, 8x3 is carried out by 8+8+8=24. Multiplying Signed Numbers There are many methods to multiply 2's complement numbers. The easiest is to simply find the magnitude of the two multiplicands, multiply these together, and then use the original sign bits to determine the sign of the result. If the multiplicands had the same sign, the result must be positive, if the they had different signs, the result is negative. Multiplication by zero is a special case (the result is always zero, with no sign bit). Multiplying Fractions As expected, the multiplication of fractions can be done in the same way as the multiplication of signed numbers. The magnitudes of the two multiplicands are multiplied, and the sign of the result is determined by the signs of the two multiplicands. There are a couple of complications involved in using fractions. Although it is almost impossible to get an overflow (since the multiplicands and results usually have magnitude less than one), it is possible to get an overflow by multiplying -1x-1 since the result of this is +1, which cannot be represented by fixed point numbers. The other difficulty is that in multiplying two 3 bit numbers, obviously results in a 6-bit number, but there are 8 bits in the result (since it s the multiplying of two 4 bit numbers). This means that the result end up with two bits to the left of the decimal point. These are sign extended, so that for positive numbers they are both zero, and for negative numbers they are both one. Consider the case of multiplying -1/2 by -1/2: Mohd Uzir Kamaluddin / Aug 2016 page 6

Decimal Fractional Binary -0.5 x0.5-0.25 1100 x0100 0000 0000 +111100 11110000 This obviously presents a difficulty if result is to be stored as 3-bit binary number, because if only the 4 leftmost bits is taken, the result would end up with two sign bits. So, an important step to take is to shift the number to the left by one and then take the 4 leftmost bit. This leaves with 1110 which is equal to -1/4, as expected. Division The two numbers in a division operation are the dividend and the divisor. The result is the quotient. The format is: dividend/divisor=quotient. In a computer system, division is done through subtraction. As an example: 1001012 1012 (3710 510) 111 result = 7 10 ------- 101)100101 101 --- 1000 101 --- 111 101 --- 10 remainder = 2 10 --- Hexadecimal Number System The hexadecimal (also base-16, hexa, or hex) is a numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0 9 to represent values zero to nine, and A, B, C, D, E, F (or a through f) to represent values ten to fifteen. Its primary use is as a human friendly representation of binary coded values, so it is often used in digital electronics and computer engineering. Since each hexadecimal digit represents four binary digits (bits) also called a nibble it is a compact and easily translated shorthand to express values in base two. In digital computing, hexadecimal is primarily used to represent bytes. Attempts to represent the 256 possible byte values by other means have led to problems. Directly representing each possible byte value with a single character representation runs into unprintable control characters in the ASCII character set. Octal Number System The octal numeral system, is the base-8 number system, and uses the digits 0 to 7. Octal is sometimes used in computing instead of hexadecimal. Mohd Uzir Kamaluddin / Aug 2016 page 7

Binary to Octal Conversion Binary is also easily converted to the octal numeral system, since octal uses a radix of 8, which is a power of two (namely, 2 3, so it takes exactly three binary digits to represent an octal digit). Octal Binary 0 000 1 001 2 010 3 011 Octal Binary 4 100 5 101 6 110 7 111 Converting from octal to binary proceeds as follows: 658 = 110 1012 178 = 001 1112 And from binary to octal: 1011002 = 101 1002 grouped = 548 100112 = 010 0112 grouped with padding = 238 And from octal to decimal: 658 = (6 8 1 ) + (5 8 0 ) = (6 8) + (5 1) = 5310 1278 = (1 8 2 ) + (2 8 1 ) + (7 8 0 ) = (1 64) + (2 8) + (7 1) = 8710 Binary to Hexadecimal Conversion Binary may be converted to and from hexadecimal somewhat more easily. This is because the radix of the hexadecimal system (16) is a power of the radix of the binary system (2). More specifically, 16 = 2 4, so it takes four digits of binary to represent one digit of hexadecimal. The following table shows each hexadecimal digit along with the equivalent decimal value and four-digit binary sequence: Hex Dec Binary 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 Hex Dec Binary 8 8 1000 9 9 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111 To convert a hexadecimal number into its binary equivalent, simply substitute the corresponding binary digits: 3A16 = 0011 10102 E716 = 1110 01112 To convert a binary number into its hexadecimal equivalent, divide it into groups of four bits. If the number of bits isn't a multiple of four, simply insert extra 0 bits at the left (called padding). For example: 10100102 = 0101 0010 grouped with padding = 5216 110111012 = 1101 1101 grouped = DD16 To convert a hexadecimal number into its decimal equivalent, multiply the decimal equivalent of each hexadecimal digit by the corresponding power of 16 and add the resulting values: Mohd Uzir Kamaluddin / Aug 2016 page 8

C0E716 = (12 16 3 ) + (0 16 2 ) + (14 16 1 ) + (7 16 0 ) = (12 4096) + (0 256) + (14 16) + (7 1) = 49,38310 Exercises: 1. Convert 11001.12 to base 8. 2. Convert 25.68 to binary. 3. Convert 35.18 to base 16. 4. Convert 39.A16 to base 8. 5. Convert 485 to base 16. CODES It is possible to represent quantities in a binary fashion without resorting to the use of 8-4-2-1 weightings. This representation is useful from the point of view of error detection, thus many specialized codes are used in digital systems. Other advantages lie in reduction of electronic circuitry or ease of arithmetic computations. Binary Coded Decimal (BCD) Number System In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each decimal digit is represented by a fixed number of bits, usually four or eight. Special bit patterns are sometimes used for a sign or for other indications (e.g., error or overflow). Numbers larger than 9, having two or more digits in the decimal system, are expressed digit by digit. For example, the BCD rendition of the number 1895 is 0001 1000 1001 0101, this is called packed BCD. The unpacked format is to use 8-bit for each digit, for example 19 = 0000 0001 0000 1001. The BCD system offers relative ease of conversion between machine-readable and human-readable numerals. As compared to the simple binary system, however, BCD increases the circuit complexity. The BCD system is not as widely used today as it was a few decades ago, although some systems still employ BCD in financial applications. Converting from Decimal to BCD: To convert a decimal number into a BCD number, assign each digit of the decimal to its 4-bit equivalent, padding the upper nibble with zeroes if necessary. For example, 238 = 0000 0010 0011 1000 (packed BCD) Converting from BCD to Decimal: To convert a BCD into a decimal number, just reverse the appropriate process from above; beginning with the LSB, group the binary digits by 4 bits, then convert each set into its decimal equivalent. For example, 1000 0110 1001 0011 = 8693. BCD Addition The BCD numbers can be summed. BCD addition follows the same rules as binary addition. However, if the addition produces a carry and/or creates an invalid BCD number, an adjustment is required to correct the sum. The correction method is to add 6 to the sum in any digit position that has caused an error. For example, Mohd Uzir Kamaluddin / Aug 2016 page 9

BCD Subtraction The BCD numbers can be subtracted. BCD subtraction follows the same rules as binary subtraction. However, if the subtraction causes a borrow and/or creates an invalid BCD number, an adjustment is required to correct the answer. The correction method is to subtract 6 from the difference in any digit position that has caused an error. Unpacked BCD Multiplication Multiplication cannot be performed on packed BCD; the 4 most significant bits must be zeroed for the adjustment to work. Multiply the two unpacked BCD numbers using the rules for binary multiplication. To adjust the product divide it by decimal 10, then place the quotient in the most significant byte and the remainder in the least significant byte (convert the binary answer to unpacked BCD). Unpacked BCD Division BCD division also cannot be performed on packed numbers. Before dividing an unpacked BCD number, the division adjustment is made by converting the BCD numbers to binary. Adjust the twobyte BCD number by multiplying the upper byte by decimal 10 and adding the product to the lower byte. After the adjustment, divide the two binary numbers using the rules of binary arithmetic. Finally, convert the binary quotient into an unpacked BCD number if necessary. ASCII Code ASCII is the abbreviation for American Standard Code for Information Interchange. This alphanumeric code is universally accepted to be used in most computers and other electronic equipment (keyboards). ASCII has 128 characters and symbols represented by a 7-bit code, actually 8-bit by making the MSB to be 0. The first 32 ASCII characters are nongraphic commands (e.g. null, line feed, start of text, escape) that are never printed or displayed and are used for control purposes only. The other characters are graphic symbols that can be printed or displayed. For example the text My name is Uzir converted into ASCII as 077 121 032 110 097 109 101 032 105 115 032 085 122 105 114 Mohd Uzir Kamaluddin / Aug 2016 page 10

Unicode Characters The Unicode Standard provides a unique number for every character, no matter what platform, device, application or language. It has been adopted by all modern software providers and now allows data to be transported through many different platforms, devices and applications without corruption. Support of Unicode forms the foundation for the representation of languages and symbols in all major operating systems, search engines, browsers, laptops, and smart phones plus the Internet and World Wide Web (URLs, HTML, XML, CSS, JSON, etc.). Supporting Unicode is the best way to implement ISO/IEC 10646. The emergence of the Unicode Standard and the availability of tools supporting it are among the most significant recent global software technology trends. Gray Code This code also known as Reflected Binary Code (RBC) is an unweighted code and is not an arithmetic code; meaning there are no specific weights assigned to the bit positions. The important feature of the Gray code is that it exhibits only a single bit change from one code word to the next code in sequence. This property is important in many applications, such as shaft position encoders. Binary Gray code 0 0000 0000 1 0001 0001 2 0010 0011 3 0011 0010 4 0100 0110 5 0101 0111 Binary Gray code 6 0110 0101 7 0111 0100 8 1000 1100 9 1001 1101 10 1010 1111 11 1011 1110 Mohd Uzir Kamaluddin / Aug 2016 page 11

12 1100 1010 13 1101 1011 14 1110 1001 15 1111 1000 Binary to Gray code conversion Steps to follow for the conversion: 1. The MSB of the Gray code will be exactly equal to the first bit of the given binary number. 2. Now the second bit of the code will be exclusive-or of the first and second bit of the given binary number, i.e. if both the bits are same the result will be 0 and if they are different the result will be 1. 3. The third bit of Gray code will be equal to the exclusive-or of the second and third bit of the given binary number. Thus the binary to Gray code conversion goes on. Gray code to binary conversion Steps to follow for the conversion: 1. The MSB of the binary number will be equal to the MSB of the given Gray code. 2. Now if the second Gray bit is 0 the second binary bit will be same as the previous or the first bit. If the Gray bit is 1 the second binary bit will alter. If it was 1 it will be 0 and if it was 0 it will be 1. 3. This step is continued for all the bits. BCD-to-7 Segment Code There is a Digital Decoder IC (74LSx), is a device which converts one digital format into another and one of the most commonly used device for doing this is called the Binary Coded Decimal (BCD) to 7- Segment Display Decoder. The 7-segment LED (Light Emitting Diode) type displays, provide a very convenient way of displaying information or digital data in the form of numbers, letters or even alpha-numerical characters. Typically, 7-segment displays consist of seven individual colored LED s (called the segments), within one single display package. In order to produce the required numbers or HEX characters from 0 to 9 and A to F respectively, on the display the correct combination of LED segments need to be illuminated. A standard 7-segment LED display generally has 8 input connections, one for each LED segment and one that acts as a common terminal or connection for all the internal display segments. Some single displays have also had an additional input pin to display a decimal point in their lower right or left hand corner. In electronics there are two important types of 7-segment LED digital display. Mohd Uzir Kamaluddin / Aug 2016 page 12

1. The Common Cathode Display (CCD) In the common cathode display, all the cathode connections of the LED s are joined together to logic 0 or ground. The individual segments are illuminated by application of a HIGH, logic 1 signal to the individual Anode terminals. 2. The Common Anode Display (CAD) In the common anode display, all the anode connections of the LED s are joined together to logic 1 and the individual segments are illuminated by connecting the individual Cathode terminals to a LOW, logic 0 signal. Electrical connection of the individual diodes for a common cathode display and a common anode display and by illuminating each light emitting diode individually, they can be made to display a variety of numbers or characters. The table below shows the digits and the segments to be lighted for a display system using common anode (CA) method. The table below shows the digits and the segments to be lighted for a display system using common cathode (CC) method. Mohd Uzir Kamaluddin / Aug 2016 page 13

Parity Codes Parity codes are codes used to detect error in the binary number being transmitted. Any group of bits contain either an even or an odd number of 1 s. A parity bit is attached to a group of bits to make the total number of 1s in a group always even or always odd. An even parity bit makes the total number of 1s is even, and an odd parity bit makes the total odd. The parity bit can be attached to the binary code at either at the beginning or at the end, depending on the system design. Any system operates with even or odd parity, but not both. For example, (using 7 data bits, P is the parity bit generated): EVEN PARITY Data #1's in data P Total # 1's (data and P) ---------- ------------ - -------------------------- 0110110 4 (Even) 0 4 (Even) 0011111 5 (Odd) 1 6 (Even) 0000000 0 (Even) 0 0 (Even) 1010100 3 (Odd) 1 4 (Even) 1111111 7 (Odd) 1 8 (Even) For example (using 7 data bits, P is the parity bit generated): ODD PARITY Data #1's in data P Total # 1's (data and P) ---------- ------------ - ------------------------ 0110110 4 (Even) 1 5 (Odd) 0011111 5 (Odd) 0 5 (Odd) 0000000 0 (Even) 1 1 (Odd) 1010100 3 (Odd) 0 3 (Odd) 1111111 7 (Odd) 0 7 (Odd) If a single bit is switched during transmission, a parity check will detect it, and the data received are bad. But it cannot be determined, however, which bit was switched. For example, suppose 0110110 is sent using odd parity, and the second bit from the left is switched: Data sent: 0110110 #1's in data: 4 (Even) Parity bit: 1 Tl. # 1's: 5 (Odd) Data received: 0010110 (Note the changed bit) #1's in data: 3 (Odd) Parity bit: 0 Tl. # 1's: 3 (Odd) Comparing the two parity bits, it can be seen that there was an error. However, which bit was switched is unknown. Error detection is the process of detecting the errors that are present in the data transmitted from transmitter to receiver, in a communication system. We use some redundancy codes to detect these errors, by adding to the data while it is transmitted from source (transmitter). These codes are called Error detecting codes. Mohd Uzir Kamaluddin / Aug 2016 page 14

Types of Error detection Parity Checking Cyclic Redundancy Check (CRC) Longitudinal Redundancy Check (LRC) Check Sum EBCDIC (Extended Binary Coded Decimal Interchange Code) code 8-bit alphanumeric code developed by IBM, supports 256 symbols. It was mainly used in IBM mainframe computers. Excess-3 code 4-bit code is obtained by adding binary 0011 to the natural BCD code of the digit. Example - decimal 2 is coded as 0010 + 0011 = 0101 as Excess-3 code. It not weighted code. Its self-complimenting code, means 1's complement of the coded number yields 9's complement of the number itself. Used in digital system for performing substraction operations. Mohd Uzir Kamaluddin / Aug 2016 page 15