CHAPTER 9 COMPUTER ARITHMETIC - ALU

Slides:



Advertisements
Similar presentations
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
Advertisements

CS 151 Digital Systems Design Lecture 3 More Number Systems.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
COMPUTER ORGANIZATIONS CSNB123 May 2014Systems and Networking1.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
Number Representation
CSNB374: Microprocessor Systems Chapter 1: Introduction to Microprocessor.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CPU The Central Processing Unit (CPU), has 3 main parts: Control Unit Arithmetic and Logic Unit Registers. These components are connected to the rest.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
973cs111_add_posneg.ppt Integers Whole numbers Do NOT contain decimal points (as in money) 43,689 is an integer 43, is NOT an integer (it is floating.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Lecture 4: Digital Systems & Binary Numbers (4)
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Cosc 2150: Computer Organization
Computer Architecture & Operations I
Addition and Subtraction
Computer Architecture & Operations I
Number Systems.
William Stallings Computer Organization and Architecture 7th Edition
Computer Organization and ASSEMBLY LANGUAGE
Data Representation Data Types Complements Fixed Point Representation
King Fahd University of Petroleum and Minerals
Data Representation in Computer Systems
ECEG-3202 Computer Architecture and Organization
Unit 18: Computational Thinking
C1 Number systems.
Number Representation
How are negative and rational numbers represented on the computer?
Decimal and binary representation systems
Chapter 8 Computer Arithmetic
ECE 331 – Digital System Design
CSC 220: Computer Organization Signed Number Representation
Chapter3 Fixed Point Representation
OBJECTIVES After reading this chapter, the reader should be able to :
Two’s Complement & Binary Arithmetic
Presentation transcript:

CHAPTER 9 COMPUTER ARITHMETIC - ALU CSNB123 coMPUTER oRGANIZATION NSMS2013 Ver.1 Systems and Networking

Overview NSMS2013 Ver.1 Systems and Networking Arithmetic Logic Unit (ALU) Focus on – computer arithmetic Logic function Support 2 types of number Integer Floating-point Component in processor NSMS2013 Ver.1 Systems and Networking

ALU Part of the computer that do the arithmetic and logical operation on data Simple digital logic devices that can; Store binary digits Perform simple BOOLEAN logic operations CPU Registers Arithmetic Logic Unit (ALU) Internal CPU Interconnection Control Unit NSMS2013 Ver.1 Systems and Networking

Systems and Networking ALU Interconnection NSMS2013 Ver.1 Systems and Networking

ALU and Registers CPU Component Description Registers Present data to ALU Store result of an operation Temporary storage locations within the processor that are connected by signal paths to the ALU ALU set flags – result of an operation – store in registers Control unit Provides signals that control; Operation of the ALU Movement of the data into and out of the ALU CPU Registers Arithmetic Logic Unit (ALU) Internal CPU Interconnection Control Unit NSMS2013 Ver.1 Systems and Networking

Integer Representation Computer - logic circuits - operate on information; 0 and 1  two values electrical signals – bit How to represent negative value in binary? Sign-magnitude representation Twos complements representation NSMS2013 Ver.1 Systems and Networking

Sign Magnitude Representation NSMS2013 Ver.1 Systems and Networking

Sign-magnitude Representation Ways of presenting -ve and +ve integers The most significant (leftmost) bits in the word as a sign bit Example: if the sign bit is 0 then the number is +ve, vice versa Hence sign magnitude representation employed sign bit NSMS2013 Ver.1 Systems and Networking

Sign-magnitude Representation (Cont.) Example +18 = 00010010 -18 =10010010 Rarely used Drawbacks; Addition/subtraction require a consideration of both the signs of the numbers and their relative magnitudes to carry out the required operation 2 representation of 0; +010 = 00000000 -010 = 10000000 NSMS2013 Ver.1 Systems and Networking

Twos complements representation NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation Used the most significant bit (MSB) as a sign bit (similar to sign magnitude) Differs – the other bits are interpreted Example: +3 = 00000011 +2 = 00000010 +1 = 00000001 +0 = 00000000 NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation (Cont.) Negative – sign bit = 1 Example: -1 = 11111111 -2 = 11111110 -3 = 11111101 NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation (Cont.) Steps for negative integers. Example: -3 +3 = 00000011 11111100 1 11111101 Step 1: Take +ve value Step 2: Boolean Complement Step 3: Add 1 to LSB Result NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation (Cont.) Example: 11110000 11110000 00001111 1 00010000 00010000 = 16 -16 Step 1: Take value Step 2: Boolean Complement Step 3: Add 1 to LSB Result Convert into decimal Put –ve sign NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation – Special Case Example: 0, consider an 8-bit representation 11111111 1 100000000 Step 1: Take value Step 2: Boolean Complement Step 3: Add 1 to LSB Result 1 carry out at most significant bit (MSB) - Ignored hence -0 = 0 NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation – Range of Numbers 8-bit 2s complement +127 = 0111 1111 -127 = 1000 0000 16-bit 2s complement +32767 = 01111111 11111111 -32767 = 10000000 00000000 NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation – Conversion between lengths Positive Negative Pack with leading zeros 8-bits +18 = 00010010 16-bits -18 = 00000000 00010010 Pack with leading ones 8-bits +18 = 11101110 16-bits -18 = 11111111 11101110 NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation - Operations Addition Subtraction NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation - Operations Addition Addition follows as if the two numbers were unsigned integers (positive or zero) Overflow – result is larger than word ALU provide signals NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation - Operations Subtraction Do subtraction via addition NSMS2013 Ver.1 Systems and Networking

Twos Complements Representation - Operations OVERFLOW RULE If two numbers are added, and they BOTH are POSITIVE or BOTH NEGATIVE, Then OVERFLOW occurs if and only if the RESULT has the OPPOSITE SIGN NSMS2013 Ver.1 Systems and Networking