Arithmetic Logical Unit

Slides:



Advertisements
Similar presentations
Chapter Three.
Advertisements

©UCB CPSC 161 Lecture 6 Prof. L.N. Bhuyan
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
1  2004 Morgan Kaufmann Publishers Chapter Three.
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
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.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Computing Systems Basic arithmetic for computers.
ECE232: Hardware Organization and Design
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Computer Architecture Lecture Notes Spring 2005 Dr. Michael P. Frank Competency Area 4: Computer Arithmetic.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
Prof. Hsien-Hsin Sean Lee
Lec 11Systems Architecture1 Systems Architecture Lecture 11: Arithmetic for Computers Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
May 2, 2001System Architecture I1 Systems Architecture I (CS ) Lecture 11: Arithmetic for Computers * Jeremy R. Johnson May 2, 2001 *This lecture.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Based on slides from D. Patterson and www-inst.eecs.berkeley.edu/~cs152/ COM 249 – Computer Organization and Assembly Language Chapter 3 Arithmetic For.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Computer System Design Lecture 3
Computer Architecture & Operations I
Dr. Clincy Professor of CS
CS 232: Computer Architecture II
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers
William Stallings Computer Organization and Architecture 7th Edition
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Data Representation Data Types Complements Fixed Point Representation
How to represent real numbers
Computer Arithmetic Multiplication, Floating Point
ECEG-3202 Computer Architecture and Organization
Computer Architecture
COMS 361 Computer Organization
Chapter 8 Computer Arithmetic
Chapter 3 Arithmetic for Computers
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Arithmetic Logical Unit Be able to explain the organization of the classical von Neumann machine and its major functional components Focus on ALU design issues

Arithmetic Where we've been: What's up ahead: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing the Architecture Focus on ALU 32 operation result a b ALU 11/29/2018

Numbers Many interpretations for bit strings Numbers Binary numbers (base 2) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001... Octal and Hexadecimal representation Decimal: 0...2n-1 Factors to consider: numbers are finite (overflow) fractions and real numbers negative numbers How do we represent negative numbers? 11/29/2018

Representations for Negative Numbers Sign Magnitude One's Complement Two's Complement 000 = +0 000 = +0 000 = +0 001 = +1 001 = +1 001 = +1 010 = +2 010 = +2 010 = +2 011 = +3 011 = +3 011 = +3 100 = -0 100 = -3 100 = -4 101 = -1 101 = -2 101 = -3 110 = -2 110 = -1 110 = -2 111 = -3 111 = -0 111 = -1 Which would you use? Rotation measurement (shaft encoder) – which would you use? What is the highest negative number that can be represented by an 8 bit number? 11/29/2018

Addition & Subtraction Just like in grade school (carry/borrow 1s) 0111 0111 + 0110 - 0110 1101 0001 Two's complement operations easy subtraction using addition of negative numbers 0111 + 1010 0001 Overflow (result too large for finite computer word): e.g., adding two n-bit positive numbers yields negative number 0111 + 0001 note that “overflow” is somewhat misleading, 1000 it does not mean a carry “overflowed” 11/29/2018

An exception (interrupt) occurs Overflow - Exception An exception (interrupt) occurs Control jumps to predefined address for exception processing Interrupted address is saved for possible resumption Details based on software system / language example: flight control vs. homework assignment 11/29/2018

Review: The Multiplexor Selects one of the inputs to be the output, based on a control input Lets build our ALU using a MUX: S C A B note: we call this a 2-input mux even though it has 3 inputs! 1 11/29/2018

Building a 32 bit ALU 11/29/2018 Ó Morgan Kaufmann Publishers

What about subtraction (a – b) ? Two's complement approach: just negate b and add. How do we negate? 11/29/2018 Ó Morgan Kaufmann Publishers

Multiplication More complicated than addition accomplished via addition and shifting How many bits in the result? More time More storage Let's look at 3 versions based on grade school algorithm 0010 (multiplicand) __x_1011 (multiplier) Negative numbers: convert and multiply there are better techniques, we won’t look at them 11/29/2018

Multiplication: Implementation 11/29/2018 Ó Morgan Kaufmann Publishers

Multiplication Hardware – second version Initially 0 11/29/2018

Final Version One partial-product addition per cycle. OK if multiplication is not frequent. 11/29/2018 Ó Morgan Kaufmann Publishers

Neat Multiplication Trick Simple example: 1221 * 9 = 1221 * 9 = 10989 1221 * (10 – 1) = 1221*10 – 1221*1 = 12210 – 1221 = 10989 More complex: 1221 * 99 = 1221 * 100 – 1221 * 1 = 122100 – 1221 = 122100 – 1221 = 120879 Can we apply this to binary numbers? 11/29/2018

Neat Multiplication Trick – Binary Numbers 1010 * 011 = 10 * 3 = 30 1010 * (100 – 001) = 1010 * 100 – 1010 * 001 = 101000 – 1010 = (32 + 8) – (8 + 2) = 30 1010 * 01110 = 10 * 14 = 140 1010 * (10000 – 00010) = 10100000 – 1010*00010 = 10100000 – 10100 = (128 + 32) – ( 16 + 4) = 160 – 20 = 140 Identify runs of 1, and convert the multiply problem into a shifting problem + subtraction. 11/29/2018

Booth’s Algorithm 0 1 1 1 1 0 End of run (current bit = 0, bit to right = 1) Middle of run Beginning of run (current bit = 1, bit to right = 0) Booth’s Algorithm: 00: Middle of string of 0s, so no operation 01: End of string of 1s, so add multiplicand to the left half of the partial product 10: Beginning of the 1s run, so subtract the multiplicand from the left half of the partial product 11: Middle of the 1s run, so no operation What happens if the runs are short: 01001010101 ? 11/29/2018

Floating Point (a brief look) We need a way to represent numbers with fractions, e.g., 3.1416=3.1416 ´ 100 (Do you recognize this?) very small numbers, e.g., .000000001=1.0 ´ 10-9 very large numbers, e.g., 3.15576 ´ 109 Scientific notation – one non-zero digit to left of decimal point Binary equivalent – one non-zero digit to left of binary point (1.0 ´ 2-1) Representation: sign, exponent, fraction: (–1)sign ´ fraction ´ 2exponent leading bit is always 1, so this is implied. For example in 1.011 is stored 011. significand = 1 + fraction => significand 1 bit longer than fraction stored more bits for fraction (significand) gives more accuracy more bits for exponent increases range IEEE 754 floating point standard: single precision: 1 bit sign, 8 bit exponent, 23 bit fraction = 32 bits what if exponent is negative? bias the exponent by 127, so -1 is represented by -1+127=126 double precision: 1 bit sign, 11 bit exponent, 52 bit fraction = 64 bits 11/29/2018

Floating point addition Floating point arithmetic deserves special attention A simple floating point addition problem 99.99 + 0.1610 = 9.999 ´101 + 1.610 ´ 10-1 (scientific notation) assume 4 digit significand To add we need the exponents to be the same Align the decimal point 9.999 ´101 + 0.01610 ´ 101 Add the significands Sum is 10.015 ´101 Normalize to scientific notation 10.015 ´101 = 1.0015 ´102 We started with 4 digit significand. Reduce to 4 digit significand. result is 1.002 ´102 11/29/2018

Pipelines for Vector Addition Illustrate the potential advantages of pipelines Pipelines for instruction execution discussed in Chapter 6 Objective: Compute C = A – B, where A and B are 7 x 1 vectors i.e. C(i) = A(i) – B(i) Each subtraction involves Complement of B(i) Increment to get two’s complement Add to A(i) R1 Complement R4 B(i) A(i) R3 Adder R2 Increment Use pipeline for overlapping operations Registers act as buffers storing intermediate values R5 11/29/2018

B(i) A(i) R2 Increment R5 R1 Complement R4 R3 Adder Clock Pulse # R1 6 B(6) B(4)+1 A(4) C(3) 7 B(7) B(5)+1 A(5) C(4) 8 B(6)+1 A(6) C(5) 9 B(7)+1 A(7) C(6) 10 C(7) R2 Increment R5 R1 Complement R4 R3 Adder What if A, B are 8 element? Advantage of pipeline? Basic assumptions / requirements of good pipelines? 11/29/2018

Binary to Floating Point Hexadecimal number: 24A60000 Bit pattern: 0010 0100 1010 0110 0000 0000 0000 0000 0 01001001 0100 1100 0000 0000 0000 000 + 73 + 4x16-1 + 12x16-2+0x16-3 + 0x16-4 + 0x16-5 + 0x16-6 Exponent: Sign = 73 -127 = -54 Mantissa: 1+.25 + .046875 = 1.29688 1.29688 x 2-54 11/29/2018 11/29/2018

Chapter 3 Assignments 3.3.1, 3.3.2, 3.3.3, 3.5.1, 3.10.1, 3.10.2, 3.10.3, 3.11.2 11/29/2018