BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.

Slides:



Advertisements
Similar presentations
Princess Sumaya Univ. Computer Engineering Dept. د. بســام كحـالــه Dr. Bassam Kahhaleh.
Advertisements

A digital system is a system that manipulates discrete elements of information represented internally in binary form. Digital computers –general purposes.
ENGIN112 L4: Number Codes and Registers ENGIN 112 Intro to Electrical and Computer Engineering Lecture 4 Number Codes and Registers.
Chapter 1 Binary Systems 1-1. Digital Systems
Digital Fundamentals Floyd Chapter 2 Tenth Edition
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 3 Dr. Shi Dept. of Electrical and Computer Engineering.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
CS 151 Digital Systems Design Lecture 4 Number Codes and Registers.
Level ISA3: Information Representation
CS 151 Digital Systems Design Lecture 2 Number Systems Prof. Ahmed Sameh Room 239A.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
ENGIN112 L2: Number Systems September 5, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 2 Number Systems Russell Tessier KEB 309 G.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
EE 261 – Introduction to Logic Circuits
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Dr. Bernard Chen Ph.D. University of Central Arkansas
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Numbering systems.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Chapter 3 Data Representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
Chapter 1: Digital Computers and Information Illustration at beginning of each Chapter Base 10 Binary Base 2 Octal Base 8 Hex bas
Topic 1 – Number Systems. What is a Number System? A number system consists of an ordered set of symbols (digits) with relations defined for addition,
CHAPTER 1 INTRODUCTION TO DIGITAL LOGIC
AEEE2031 Data Representation and Numbering Systems.
Chapter 1 Digital Systems and Binary Numbers
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Chapter 1: Binary Systems
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
Unit 1 Introduction Number Systems and Conversion.
Chapter 1 Digital Systems and Binary Numbers
Lec 3: Data Representation
Lecture No. 4 Number Systems
CHAPTER 1 INTRODUCTION TO DIGITAL LOGIC
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Introduction to Chapter 2
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
Number Systems Give qualifications of instructors:
Chapter 3 Data Representation
Number Systems.
Chapter 1 Digital Systems and Binary Numbers
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
University of Gujrat Department of Computer Science
INTRODUCTION TO LOGIC DESIGN Chapter 1 Digital Systems and Binary Numbers gürtaçyemişçioğlu.
Digital Logic & Design Lecture 03.
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic & Design Lecture 02.
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Number Systems Lecture 2.
Digital Systems and Binary Numbers
Chapter Four Data Representation in Computers By Bezawit E.
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems

BEE1244 Digital System and Electronics Overview °The design of computers It all starts with numbers Building circuits Building computing machines °Digital systems °Understanding decimal numbers °Binary and octal numbers The basis of computers! °Conversion between different number systems

BEE1244 Digital System and Electronics Overview °Hexadecimal numbers Related to binary and octal numbers °Conversion between hexadecimal, octal and binary °Value ranges of numbers °Representing positive and negative numbers °Creating the complement of a number Make a positive number negative (and vice versa) °Why binary?

BEE1244 Digital System and Electronics Digital Computer Systems °Digital systems consider discrete amounts of data. °Examples 26 letters in the alphabet 10 decimal digits °Larger quantities can be built from discrete values: Words made of letters Numbers made of decimal digits (e.g ) °Computers operate on binary values (0 and 1) °Easy to represent binary values electrically Voltages and currents. Can be implemented using circuits Create the building blocks of modern computers

BEE1244 Digital System and Electronics Understanding Decimal Numbers °Decimal numbers are made of decimal digits: (0,1,2,3,4,5,6,7,8,9) °But how many items does a decimal number represent? 8653 = 8x x x x10 0 °What about fractions? = 9x x x x x x x10 -2 In formal notation -> ( ) 10 °Why do we use 10 digits, anyway?

BEE1244 Digital System and Electronics Understanding Octal Numbers °Octal numbers are made of octal digits: (0,1,2,3,4,5,6,7) °How many items does an octal number represent? (4536) 8 = 4x x x x8 0 = (2398) 10 °What about fractions? (465.27) 8 = 4x x x x x8 -2 = ( ) 10 °Octal numbers don’t use digits 8 or 9 °Who would use octal number, anyway?

BEE1244 Digital System and Electronics Understanding Binary Numbers °Binary numbers are made of binary digits (bits): 0 and 1 °How many items does an binary number represent? (1011) 2 = 1x x x x2 0 = (11) 10 °What about fractions? (110.10) 2 = 1x x x x x2 -2 = (6.5) 10 °Groups of eight bits are called a byte ( ) 2 °Groups of four bits are called a nibble. (1101) 2

BEE1244 Digital System and Electronics Why Use Binary Numbers? °Easy to represent 0 and 1 using electrical values. °Possible to tolerate noise. °Easy to transmit data °Easy to build binary circuits. AND Gate 1 0 0

BEE1244 Digital System and Electronics Conversion Between Number Bases Decimal(base 10) Octal(base 8) Binary(base 2) Hexadecimal (base16) °Learn to convert between bases. °Already demonstrated how to convert from binary to decimal. °Hexadecimal described in next section.

BEE1244 Digital System and Electronics Convert an Integer from Decimal to Another Base 1.Divide decimal number by the base (e.g. 2) 2.The remainder is the lowest-order digit 3.Repeat first two steps until no divisor remains. For each digit position: Example for (13) 10: Integer Quotient 13/2 = 6 + ½ a 0 = 1 6/2 = a 1 = 0 3/2 = 1 + ½ a 2 = 1 1/2 = 0 + ½ a 3 = 1 RemainderCoefficient Answer (13) 10 = (a 3 a 2 a 1 a 0 ) 2 = (1101) 2

BEE1244 Digital System and Electronics Convert an Fraction from Decimal to Another Base 1.Multiply decimal number by the base (e.g. 2) 2.The integer is the highest-order digit 3.Repeat first two steps until fraction becomes zero. For each digit position: Example for (0.625) 10: Integer x 2 = a -1 = x 2 = a -2 = x 2 = a -3 = 1 FractionCoefficient Answer (0.625) 10 = (0.a -1 a -2 a -3 ) 2 = (0.101) 2

BEE1244 Digital System and Electronics The Growth of Binary Numbers n2n2n 02 0 = = = = = = = =128 n2n2n 82 8 = = = = = =1M =1G =1T Mega Giga Tera

BEE1244 Digital System and Electronics Binary Addition °Binary addition is very simple. °This is best shown in an example of adding two binary numbers… carries

BEE1244 Digital System and Electronics Binary Subtraction °We can also perform subtraction (with borrows in place of carries). °Let’s subtract (10111) 2 from ( ) 2 … borrows

BEE1244 Digital System and Electronics Binary Multiplication °Binary multiplication is much the same as decimal multiplication, except that the multiplication operations are much simpler… X

BEE1244 Digital System and Electronics Convert an Integer from Decimal to Octal 1.Divide decimal number by the base (8) 2.The remainder is the lowest-order digit 3.Repeat first two steps until no divisor remains. For each digit position: Example for (175) 10: Integer Quotient 175/8 = /8 a 0 = 7 21/8 = 2 + 5/8 a 1 = 5 2/8 = 0 + 2/8 a 2 = 2 RemainderCoefficient Answer (175) 10 = (a 2 a 1 a 0 ) 2 = (257) 8

BEE1244 Digital System and Electronics Convert an Fraction from Decimal to Octal 1.Multiply decimal number by the base (e.g. 8) 2.The integer is the highest-order digit 3.Repeat first two steps until fraction becomes zero. For each digit position: Example for (0.3125) 10: Integer x 8 = a -1 = x 8 = a -2 = 4 FractionCoefficient Answer (0.3125) 10 = (0.24) 8

BEE1244 Digital System and Electronics Understanding Hexadecimal Numbers °Hexadecimal numbers are made of 16 digits: (0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F) °How many items does an hex number represent? (3A9F) 16 = 3x x x x16 0 = °What about fractions? (2D3.5) 16 = 2x x x x16 -1 = °Note that each hexadecimal digit can be represented with four bits. (1110) 2 = (E) 16 °Groups of four bits are called a nibble. (1110) 2

BEE1244 Digital System and Electronics Putting It All Together °Binary, octal, and hexadecimal similar °Easy to build circuits to operate on these representations °Possible to convert between the three formats

BEE1244 Digital System and Electronics Converting Between Base 16 and Base 2 °Conversion is easy!  Determine 4-bit value for each hex digit °Note that there are 2 4 = 16 different values of four bits °Easier to read and write in hexadecimal. °Representations are equivalent! 3A9F 16 = A9F

BEE1244 Digital System and Electronics Converting Between Base 16 and Base 8 1.Convert from Base 16 to Base 2 2.Regroup bits into groups of three starting from right 3.Ignore leading zeros 4.Each group of three bits forms an octal digit = A9F 16 = A9F

BEE1244 Digital System and Electronics How To Represent Signed Numbers Plus and minus sign used for decimal numbers: 25 (or +25), -16, etc..For computers, desirable to represent everything as bits. Three types of signed binary number representations: signed magnitude, 1’s complement, 2’s complement. In each case: left-most bit indicates sign: positive (0) or negative (1). Consider signed magnitude: = Sign bitMagnitude = Sign bitMagnitude

BEE1244 Digital System and Electronics One’s Complement Representation The one’s complement of a binary number involves inverting all bits. 1’s comp of is ’s comp of is For an n bit number N the 1’s complement is (2 n -1) – N. Called diminished radix complement by Mano since 1’s complement for base (radix 2). To find negative of 1’s complement number take the 1’s complement = Sign bitMagnitude = Sign bitMagnitude

BEE1244 Digital System and Electronics Two’s Complement Representation The two’s complement of a binary number involves inverting all bits and adding 1. 2’s comp of is ’s comp of is For an n bit number N the 2’s complement is (2 n -1) – N + 1. Called radix complement by Mano since 2’s complement for base (radix 2). To find negative of 2’s complement number take the 2’s complement = Sign bitMagnitude = Sign bitMagnitude

BEE1244 Digital System and Electronics Two’s Complement Shortcuts °Algorithm 1 – Simply complement each bit and then add 1 to the result. Finding the 2’s complement of ( ) 2 and of its 2’s complement… N = [N] = °Algorithm 2 – Starting with the least significant bit, copy all of the bits up to and including the first 1 bit and then complementing the remaining bits. N = [N] =

BEE1244 Digital System and Electronics Finite Number Representation °Machines that use 2’s complement arithmetic can represent integers in the range -2 n-1 <= N <= 2 n-1 -1 where n is the number of bits available for representing N. Note that 2 n-1 -1 = ( ) 2 and –2 n-1 = ( ) 2 oFor 2’s complement more negative numbers than positive. oFor 1’s complement two representations for zero. oFor an n bit number in base (radix) z there are z n different unsigned values. (0, 1, …z n-1 )

BEE1244 Digital System and Electronics 1’s Complement Addition °Using 1’s complement numbers, adding numbers is easy. °For example, suppose we wish to add +(1100) 2 and +(0001) 2. °Let’s compute (12) 10 + (1) 10. (12) 10 = +(1100) 2 = in 1’s comp. (1) 10 = +(0001) 2 = in 1’s comp Add carry Final Result Step 1: Add binary numbers Step 2: Add carry to low-order bit Add

BEE1244 Digital System and Electronics 1’s Complement Subtraction °Using 1’s complement numbers, subtracting numbers is also easy. °For example, suppose we wish to subtract +(0001) 2 from +(1100) 2. °Let’s compute (12) 10 - (1) 10. (12) 10 = +(1100) 2 = in 1’s comp. (-1) 10 = -(0001) 2 = in 1’s comp Add carry Final Result Step 1: Take 1’s complement of 2 nd operand Step 2: Add binary numbers Step 3: Add carry to low order bit 1’s comp Add

BEE1244 Digital System and Electronics 2’s Complement Addition °Using 2’s complement numbers, adding numbers is easy. °For example, suppose we wish to add +(1100) 2 and +(0001) 2. °Let’s compute (12) 10 + (1) 10. (12) 10 = +(1100) 2 = in 2’s comp. (1) 10 = +(0001) 2 = in 2’s comp Final Result Step 1: Add binary numbers Step 2: Ignore carry bit Add Ignore

BEE1244 Digital System and Electronics 2’s Complement Subtraction °Using 2’s complement numbers, follow steps for subtraction °For example, suppose we wish to subtract +(0001) 2 from +(1100) 2. °Let’s compute (12) 10 - (1) 10. (12) 10 = +(1100) 2 = in 2’s comp. (-1) 10 = -(0001) 2 = in 2’s comp Final Result Step 1: Take 2’s complement of 2 nd operand Step 2: Add binary numbers Step 3: Ignore carry bit 2’s comp Add Ignore Carry

BEE1244 Digital System and Electronics 2’s Complement Subtraction: Example #2 °Let’s compute (13) 10 – (5) 10. (13) 10 = +(1101) 2 = (01101) 2 (-5) 10 = -(0101) 2 = (11011) 2 °Adding these two 5-bit codes… °Discarding the carry bit, the sign bit is seen to be zero, indicating a correct result. Indeed, (01000) 2 = +(1000) 2 = +(8) carry

BEE1244 Digital System and Electronics 2’s Complement Subtraction: Example #3 °Let’s compute (5) 10 – (12) 10. (-12) 10 = -(1100) 2 = (10100) 2 (5) 10 = +(0101) 2 = (00101) 2 °Adding these two 5-bit codes… °Here, there is no carry bit and the sign bit is 1. This indicates a negative result, which is what we expect. (11001) 2 = -(7)

BEE1244 Digital System and Electronics Homework Q2:Perform binary subtraction for the following: °(i) – using 1’s complement °(ii) – using 1’s complement °(iii) – 1101 using 2’s complement °(iv) – using 2’s complement

BEE1244 Digital System and Electronics Homework Q1: Convert the following BinaryOctalDecimalHex BC Q2 : Perform binary subtraction for the following: °(i) – using 1’s complement °(ii) – using 1’s complement °(iii) – 1101 using 2’s complement °(iv) – using 2’s complement

BEE1244 Digital System and Electronics Binary Coded Decimal °Binary coded decimal (BCD) represents each decimal digit with four bits Ex = °This is NOT the same as °Why do this? Because people think in decimal. Digit BCD Code Digit BCD Code

BEE1244 Digital System and Electronics Putting It All Together °BCD not very efficient °Used in early computers (40s, 50s) °Used to encode numbers for seven- segment displays. °Easier to read?

BEE1244 Digital System and Electronics Gray Code °Gray code is not a number system. It is an alternate way to represent four bit data °Only one bit changes from one decimal digit to the next °Useful for reducing errors in communication. °Can be scaled to larger numbers. DigitBinary Gray Code

BEE1244 Digital System and Electronics ASCII Code °American Standard Code for Information Interchange °ASCII is a 7-bit code, frequently used with an 8 th bit for error detection (more about that in a bit). CharacterASCII (bin) ASCII (hex) DecimalOctal A B C … Z a … 1 ‘

BEE1244 Digital System and Electronics ASCII Codes and Data Transmission °ASCII Codes °A – Z (26 codes), a – z (26 codes) °0-9 (10 codes), others °Complete listing °Transmission susceptible to noise °Typical transmission rates (1500 Kbps, 56.6 Kbps) °How to keep data transmission accurate?

BEE1244 Digital System and Electronics Parity Codes °Parity codes are formed by concatenating a parity bit, P to each code word of C. °In an odd-parity code, the parity bit is specified so that the total number of ones is odd. °In an even-parity code, the parity bit is specified so that the total number of ones is even. Information BitsP  Added even parity bit  Added odd parity bit

BEE1244 Digital System and Electronics Parity Code Example °Concatenate a parity bit to the ASCII code for the characters 0, X, and = to produce both odd-parity and even-parity codes. CharacterASCII Odd-Parity ASCII Even-Parity ASCII X =

BEE1244 Digital System and Electronics Binary Data Storage Binary cells store individual bits of data Multiple cells form a register. Data in registers can indicate different values Hex (decimal) BCD ASCII Binary Cell

BEE1244 Digital System and Electronics Register Transfer °Data can move from register to register. °Digital logic used to process data °We will learn to design this logic Register ARegister B Register C Digital Logic Circuits

BEE1244 Digital System and Electronics Transfer of Information °Data input at keyboard °Shifted into place °Stored in memory NOTE: Data input in ASCII

BEE1244 Digital System and Electronics Building a Computer °We need processing °We need storage °We need communication °You will learn to use and design these components.

BEE1244 Digital System and Electronics Summary °Binary numbers are made of binary digits (bits) °Binary and octal number systems °Conversion between number systems °Addition, subtraction, and multiplication in binary

BEE1244 Digital System and Electronics Summary °Binary numbers can also be represented in octal and hexadecimal °Easy to convert between binary, octal, and hexadecimal °Signed numbers represented in signed magnitude, 1’s complement, and 2’s complement °2’s complement most important (only 1 representation for zero). °Important to understand treatment of sign bit for 1’s and 2’s complement.

BEE1244 Digital System and Electronics Summary °Although 2’s complement most important, other number codes exist °ASCII code used to represent characters (including those on the keyboard) °Registers store binary data °Next time: Building logic circuits!