Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arithmetic Logical Unit

Similar presentations


Presentation on theme: "Arithmetic Logical Unit"— Presentation transcript:

1 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

2 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

3 Numbers Many interpretations for bit strings Numbers
Binary numbers (base 2) Octal and Hexadecimal representation Decimal: n-1 Factors to consider: numbers are finite (overflow) fractions and real numbers negative numbers How do we represent negative numbers? 11/29/2018

4 Representations for Negative Numbers
Sign Magnitude One's Complement Two's Complement 000 = = = = = = = = = = = = = = = = = = = = = = = = -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

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

6 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

7 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

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

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

10 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 (multiplicand) __x_ (multiplier) Negative numbers: convert and multiply there are better techniques, we won’t look at them 11/29/2018

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

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

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

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

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

16 Booth’s Algorithm 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: ? 11/29/2018

17 Floating Point (a brief look)
We need a way to represent numbers with fractions, e.g., = ´ (Do you recognize this?) very small numbers, e.g., =1.0 ´ 10-9 very large numbers, e.g., ´ 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 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 =126 double precision: 1 bit sign, 11 bit exponent, 52 bit fraction = 64 bits 11/29/2018

18 Floating point addition
Floating point arithmetic deserves special attention A simple floating point addition problem = ´ ´ 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 Add the significands Sum is ´101 Normalize to scientific notation ´101 = ´102 We started with 4 digit significand. Reduce to 4 digit significand. result is ´102 11/29/2018

19 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

20 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

21 Binary to Floating Point
Hexadecimal number: 24A60000 Bit pattern: x x16-2+0x x x x16-6 Exponent: Sign = = -54 Mantissa: = x 2-54 11/29/2018 11/29/2018

22 Chapter 3 Assignments 3.3.1, 3.3.2, 3.3.3, 3.5.1, , , , 11/29/2018


Download ppt "Arithmetic Logical Unit"

Similar presentations


Ads by Google