Digital Logic Design Lecture 3 Complements, Number Codes and Registers.

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

ICS312 Set 2 Representation of Numbers and Characters.
HEXADECIMAL NUMBERS Code
COE 202: Digital Logic Design Signed Numbers
ENGIN112 L4: Number Codes and Registers ENGIN 112 Intro to Electrical and Computer Engineering Lecture 4 Number Codes and Registers.
ECE 331 – Digital System Design
Chapter 1 Binary Systems 1-1. Digital Systems
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CS 151 Digital Systems Design Lecture 3 More Number Systems.
CS 151 Digital Systems Design Lecture 4 Number Codes and Registers.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Data Storage. SIGN AND MAGNITUDE Storing and representing numbers.
Number Systems Lecture 02.
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
1.6 Signed Binary Numbers.
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
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.
Programmable Logic Controllers
Simple Data Type Representation and conversion of numbers
Computers Organization & Assembly Language
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Digital Systems and Logic Design
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
Chapter 3 Data Representation
Binary Arithmetic & Data representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Topic 2 – Introduction to Computer Codes. Computer Codes A code is a systematic use of a given set of symbols for representing information. As an example,
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.
ICS312 Set 1 Representation of Numbers and Characters.
CS151 Introduction to Digital Design
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.
CE1111 :Digital Logic Design lecture 01 Introduction Dr. Atef Ali Ibrahim.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
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,
THE BINARY SYSTEM.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
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.
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Memory unit terminology memory contains series of bits, grouped into addressable units word - unit of memory access and/or size of data registers, 16/32/64.
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.
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
Chapter 3 Data Representation
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Digital Logic & Design Lecture 03.
ECE 331 – Digital System Design
Presentation transcript:

Digital Logic Design Lecture 3 Complements, Number Codes and Registers

Overview ° Complement of numbers Addition and subtraction °Binary coded decimal °Gray codes for binary numbers °ASCII characters °Moving towards hardware Storing data Processing data

Complements In general, we (human beings) express negative numbers by placing a minus (-) sign at the left end of the number. Similarly while representing the integers in binary format, we can leave the left-most bit be the sign bit. If the left- most bit is a zero, the integer is positive; if it is a one, it is negative. Zero is positive and -0 = 0 The top-most bit should tell us the sign of the integer. The negative of a negative integer is the original integer ie., -(-55) is 55. x - y should give the same result as x + (-y). That is, should give us the same result as 8 + (-3). Negative and positive numbers shouldn't be treated in different ways when we do multiplication and division with them.

Complement °If we consider only positive numbers, this would allow for all numbers from 0 (naturally represented by ) to and inclusively 255 (represented by ) °The most obvious solution is to spare the first bit as a sign indicator, thus leaving the 7 last bits to represent the numbers. °This simple way to represent negative numbers has for it the equally simple way to compute the negative of a given number: just invert the first bit!. Hence, the number 3, for example, represented as ( ) will give ( ) for -3 (we have just toggled the first bit). °This simple way has a drawback: the negative of 0 ( ) is now ( ), known as -0

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

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] =

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 )

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

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

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

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

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

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)

2’s Complement Subtraction °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 carry

Data Representation and Communication °Human communication Includes language, images and sounds °Computers Process and store all forms of data in binary format °Conversion to computer-usable representation using data formats Define the different ways human data may be represented, stored and processed by a computer

°Numbers are important to computers as they Represent information precisely Can be processed °Decimal numbers are favored by humans. Binary numbers are natural to computers. Hence, conversion is required. °If little calculation is required, we can use some coding schemes to store decimal numbers, for data transmission purposes. °Examples: BCD (or 8421), Excess-3, , 2421, etc. °Each decimal digit is represented as a 4-bit code. °The number of digits in a code is also called the length of the code. Data Representation and Communication

BCD DigitBit pattern Note: the following 6 bit patterns are not used: °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.

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?

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

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 ‘

21 Most significant bit Least significant bit ASCII Code

22 e.g., ‘ a ’ = ASCII Code

23 Alphabetic codes ASCII Code

24 Numeric codes ASCII Code

25 Punctuation, etc. ASCII Code

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

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

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 =

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

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

Transfer of Information °Data input at keyboard °Shifted into place °Stored in memory NOTE: Data input in ASCII

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

Summary °2’s complement most important (only 1 representation for zero). °Important to understand treatment of sign bit for 1’s and 2’s complement. °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