Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Size: px
Start display at page:

Download "Computer Organization and Structure. Bing-Yu Chen National Taiwan University"

Transcription

1 Computer Organization and Structure Bing-Yu Chen National Taiwan University

2 Arithmetic for Computers Addition and Subtraction Gate Logic and K-Map Method Constructing a Basic ALU Arithmetic Logic Unit Multiplication and Division Floating Point

3 Arithmetic operation a 32 ALU result b

4 Integer Addition & Subtraction Example: (just like in grade school) () () () () () (carries) () () () () () () Subtraction = Add negation of second operand Example: 7 6 = 7 + ( 6) +7: 6: +: 3

5 Overflow Overflow if result out of range Adding +ve and ve operands no overflow two +ve operands overflow if result sign is two ve operands overflow if result sign is Subtracting two +ve or two ve operands no overflow +ve from ve operand overflow if result sign is ve from +ve operand overflow if result sign is Consider the operations A + B, and A B Can overflow occur if B is? Can overflow occur if A is? 4

6 Detecting Overflow Operation Operand A A+B Operand B Result indicating overflow A+B A-B A-B 5

7 Dealing with Overflow An exception (interrupt) occurs On overflow, invoke exception handler Save PC in exception program counter (EPC) register Jump to predefined handler address mfc (move from coprocessor reg) instruction can retrieve EPC value, to return after corrective action Some languages (e.g., C) ignore overflow new MIPS instructions: addu, addiu, sub note: addiu still sign-extends! note: sltu, sltiu for unsigned comparisons 6

8 An ALU (Arithmetic Logic Unit) build an ALU to support andi & ori instructions just build a bit ALU, and use 32 of them operation op a b res a b result Possible Implementation (sum-of-products): 7

9 Review: The NOT, AND, OR Gates Description Gates Truth Table NOT If X = then X = If X = then X = X X X X AND Z = if X and Y are both X Y Z X Y Z OR Z = if X or Y (or both) are X Y Z X Y Z 8

10 Review: NAND, NOR, XOR, XNOR 6 functions of two variables: X Y F F F2 F3 F4 F5 F6 F7 X Y X Y X Y X, X', Y, Y', X Y, X+Y,, only half of the possible functions F8 F9 F Y F F2 X F3 F4 F5 9

11 Review: NAND, NOR NAND Description Gates Truth Table Z = if X is or Y is X Y Z X Y Z NOR Z = if both X and Y are X Y Z X Y Z

12 Review: XOR, XNOR XOR XOR: X or Y but not both ("inequality", "difference") X Y XY XY XNOR: X and Y are the same ("equality", "coincidence") X Y XY XY Description Gates Truth Table Z = if X has a different value than Y X Y Z X Y Z XNOR Z = if X has the same value as Y X Y Z X Y Z

13 Review: Truth Tables Tabulate all possible input combinations and their associated output values Example: half adder adds two binary digits to form Sum and Carry A B Sum Carry NOTE: plus is with a carry of in binary Example: full adder adds two binary digits and Carry in to form Sum and Carry Out A B C in S um C out 2

14 Deriving Boolean Equations from Truth Tables for Half Adder OR'd together product terms for each truth table row where the function is if input variable is, it appears in complemented form; if, it appears uncomplemented A B Sum Carry Sum = A B + A B Carry = A B 3

15 4 Example: Full Adder A B Cin Sum Cout Sum = A B Cin + A B Cin + A B Cin + A B Cin Cout = A B Cin + A B Cin + A B Cin + A B Cin

16 Reducing the Complexity of Boolean Equations each product term in the above equation covers exactly two rows in the truth table; several rows are "covered" by more than one term B C in A C in A B A B C in C out Cout = A Cin + B Cin + A B 5

17 Review: Gates & Net most widely used primitive building block in digital system design Standard Logic Gate Representation INVERTER A AND Net B SUM OR Net 2 CARRY Net: electrically connected collection of wires 6

18 Two-Level Simplification Key Tool: The Uniting Theorem A (B' + B) = A A B F F = A B' + A B = A (B' + B) = A B's values change within the on-set rows B is eliminated, A remains A's values don't change within the on-set rows Essence of Simplification: find two element subsets of the ON-set where only one variable changes its value. This single varying variable can be eliminated! 7

19 Karnaugh Map Method K-map is an alternative method of representing the truth table that helps visualize adjacencies in up to 6 dimensions Beyond that, computer-based methods are needed 2-variable K-map 3-variable K-map A B C AB A B C CD AB A B D 4-variable K-map 8

20 Karnaugh Map Method Numbering Scheme:,,, Gray Code only a single bit changes from code word to next code word 9

21 K-Map Method Examples A B A asserted, unchanged B varies A B Cin AB F = A A B complemented, unchanged A varies AB C G = B' A B Cout = A B + B Cin + A Cin B F(A,B,C) = A 2

22 K-Map Method Examples, 3 Variables AB C A F(A,B,C) = Sm(,4,5,7) F = B' C' + A C In the K-map, adjacency wraps from left to right and from top to bottom C AB B A F' simply replace 's with 's and vice versa F'(A,B,C) = Sm(,2,3,6) F' = B C' + A' C B compare with the method of using DeMorgan's Theorem and Boolean Algebra to reduce the complement! 2

23 K-map Method Examples: 4 variables AB CD A F(A,B,C,D) = Sm(,2,3,5,6,7,8,,,4,5) F = C + A' B D + B' D' C D B find the smallest number of the largest possible subcubes that cover the ON-set 22

24 K-map Example: Don't Cares Don't Cares can be treated as 's or 's if it is advantageous to do so AB CD C A X X X D F = A'D + B' C' D w/o don't cares F = C' D + A' D w/ don't cares by treating this DC as a "", a 2-cube can be formed rather than one -cube AB CD A X In PoS form: F = D (A' + C') same answer as above, but fewer literals B C X X B D 24

25 25 Design Example: Two Bit Comparator Block Diagram and Truth Table A 4-Variable K-map for each of the 3 output functions F F 2 F 3 D C B A =, >, < F A B = C D F 2 A B < C D F 3 A B > C D A B C D N N 2

26 Design Example: Two Bit Comparator AB CD A AB CD A AB CD A C D C D C D B B B K-map for F K-map for F 2 K-map for F 3 F = A' B' C' D' + A' B C' D + A B C D + A B' C D' F2 = A' B' D + A' C + B' C D F3 = B C' D' + A C' + A B D' (A xnor C)(B xnor D) 26

27 27 Design Example: Two Bit Adder Block Diagram and Truth Table A 4-variable K-map for each of the 3 output functions X Y Z D C B A + N 3 A B C D N N 2 X Y Z

28 Design Example: Two Bit Adder AB CD A AB CD A AB CD A C D C D C D B K-map for X X = A C + B C D + A B D Z = B D' + B' D = B xor D Y = A' B' C + A B' C' + A' B C' D + A' B C D' + A B C' D' + A B C D = B' (A xor C) + A' B (C xor D) + A B (C xnor D) = B' (A xor C) + B (A xor B xor C) B K-map for Y 's on diagonal suggest XOR! Y K-Map not minimal as drawn B K-map for Z gate count reduced if XOR available 28

29 Two Level Simplification Definition of Terms implicant: single element of the ON-set or any group of elements that can be combined together in a K-map prime implicant: implicant that cannot be combined with another implicant to eliminate a term essential prime implicant: if an element of the ON-set is covered by a single prime implicant, it is an essential prime Objective: grow implicants into prime implicants cover the ON-set with as few prime implicants as possible essential primes participate in ALL possible covers 29

30 Examples to Illustrate Terms AB CD A 6 Prime Implicants: A' B' D, B C', A C, A' C' D, A B, B' C D C D essential Minimum cover = B C' + A C + A' B' D AB CD C B A B D 5 Prime Implicants: B D, A B C', A C D, A' B C, A' C' D essential Essential implicants form minimum cover 3

31 Examples to Illustrate Terms AB CD A Prime Implicants: B D, C D, A C, B' C C D essential Essential primes form the minimum cover B 3

32 Algorithm: Minimum Sum of Products Expression from a K-Map. Choose an element of ON-set not already covered by an implicant 2. Find "maximal" groupings of 's and X's adjacent to that element. Remember to consider top/bottom row, left/right column, and corner adjacencies. This forms prime implicants (always a power of 2 number of elements). Repeat Steps and 2 to find all prime implicants 3. Revisit the 's elements in the K-map. If covered by single prime implicant, it is essential, and participates in final cover. The 's it covers do not need to be revisited 4. If there remain 's not covered by essential prime implicants, then select the smallest number of prime implicants that cover the remaining 's 32

33 Example AB CD A AB CD A AB CD A X X X C X X D C X X D C X X D B B B Initial K-map Primes around A' B C' D' Primes around A B C' D 33

34 Example AB CD A AB CD A AB CD A X X X C X X D C X X D C X X D B B B Primes around A B C' D Primes around A B' C' D' Essential Primes with Min Cover 34

35 Different Implementations Not easy to decide the best way to build something Don't want too many inputs to a single gate Don't want to have to go through too many gates for our purposes, ease of comprehension is important Let's look at a -bit ALU for addition: c in a b + sum c out = ab + ac in + bc in sum = a xor b xor c in c out How could we build a -bit ALU for add, and, and or? How could we build a 32-bit ALU? 35

36 Review: The Multiplexor Selects one of the inputs to be the output, based on a control input d d c a b c a b note: we call this a 2-input mux even though it has 3 inputs! Lets build our ALU using a MUX 36

37 -bit ALU for AND & OR a operation result b 37

38 Building a 32 bit ALU CarryIn operation a c in operation a b c in ALU c out result result a b c in ALU c out result 2 b + c out a3 b3 c in ALU3 c out result3 38

39 What about Subtraction? binvert c in operation a 2 result b + c out 39

40 Tailoring the ALU to the MIPS Need to support the set-on-less-than instruction (slt) remember: slt is an arithmetic instruction produces a if rs < rt and otherwise use subtraction: (a-b) < implies a < b Need to support test for equality (beq $t5, $t6, $t7) use subtraction: (a-b) = implies a = b 4

41 Supporting slt without overflow binvert c in operation a b + 2 less 3 result c out 4

42 Supporting slt with overflow & set binvert c in operation a b + 2 less 3 overflow detection result set overflow 42

43 A 32 bit ALU binvert CarryIn operation bit ALU without overflow & set a b c in ALU result c out a b c in ALU c out result bit ALU with overflow & set a3 b3 c in ALU3 result3 set overflow 43

44 Test for Equality binvert operation control lines: = and = or = add = subtract = slt = beq (use zero as the output) a b a b a3 b3 c in ALU c out c in ALU c out c in ALU3 set result result result3 zero overflow 44

45 The ALU Symbol ALU operation a zero ALU result overflow b CarryOut 45

46 Multiplication more complicated than addition accomplished via shifting and addition more time and more area Let's look at 3 versions based on grade school algorithm (multiplicand) x (multiplier) negative numbers: convert and multiply 46

47 Multiplication (multiplicand) x (multiplier) 47

48 Multiplication Hardware: First Version Multiplicand shift left 64 bits 64-bit ALU Multiplier shift right 32 bits Product write control test 64 bits 48

49 Multiplication Algorithm: First Version start Multiplier=. test Multiplier Multiplier= a. add Multiplicand to Product and place the result in Product register 2. shift the Multiplicand register left bit 3. shift the Multiplier register right bit 32nd repetition? no: < 32 repetitions yes: 32 repetitions done 49

50 Multiplication Example: First Version iteration step Multiplier Multiplicand Product initial value a: Prod = Prod + Mcand 2: shift left Multiplicand 3: shift right Multiplier 2 a: Prod = Prod + Mcand 2: shift left Multiplicand 3: shift right Multiplier 3 : no operation 2: shift left Multiplicand 3: shift right Multiplier 4 : no operation 2: shift left Multiplicand 3: shift right Multiplier 5

51 Multiplication Hardware: Second Version Multiplicand 32 bits Multiplier shift right 32 bits 32-bit ALU Product 64 bits shift right write control test 5

52 Multiplication Algorithm: Second Version start Multiplier=. test Multiplier Multiplier= a. add Multiplicand to the left half of the Product and place the result in the left half of the Product register 2. shift the Product register right bit 3. shift the Multiplier register right bit 32nd repetition? no: < 32 repetitions yes: 32 repetitions done 52

53 Multiplication Example: Second Version iteration step Multiplier Multiplicand Product initial value a: Prod = Prod + Mcand 2: shift right Product 3: shift right Multiplier 2 a: Prod = Prod + Mcand 2: shift right Product 3: shift right Multiplier 3 : no operation 2: shift right Product 3: shift right Multiplier 4 : no operation 2: shift right Product 3: shift right Multiplier 53

54 Multiplication Hardware: Third Version Multiplicand 32 bits 32-bit ALU Product 64 bits shift right write control test 54

55 Multiplication Algorithm: Third Version start Product=. test Product Product= a. add Multiplicand to the left half of the Product and place the result in the left half of the Product register 2. shift the Product register right bit 32nd repetition? no: < 32 repetitions yes: 32 repetitions done 55

56 Multiplication Example: Third Version iteration step Multiplicand Product initial value a: Prod = Prod + Mcand 2: shift right Product 2 a: Prod = Prod + Mcand 2: shift right Product 3 : no operation 2: shift right Product 4 : no operation 2: shift right Product 56

57 MIPS Multiplication Two 32-bit registers for product HI: most-significant 32 bits LO: least-significant 32-bits Instructions mult rs, rt / multu rs, rt 64-bit product in HI/LO mfhi rd / mflo rd Move from HI/LO to rd Can test HI value to see if product overflows 32 bits mul rd, rs, rt Least-significant 32 bits of product > rd 57

58 Division Dividend = Quotient x Divisor + Remainder

59 Division Hardware: First Version Divisor shift right 64 bits 64-bit ALU Quotient shift left 32 bits Remainder write control test 64 bits 59

60 Division Algorithm: First Version start. subtract the Divisor register from the Remainder register and place the result in the Remainder register Remainder>= 2a. shift the Quotient register to the left, setting the new rightmost bit to Test Remainder Remainder< 2b. restore the original value by adding the Divisor register to the Remainder register and place the sum in the Remainder register. Also shift the Quotient register to the left, setting the new least significant bit to 3. shift the Divisor register right bit 33rd repetition? no: < 33 repetitions done yes: 33 repetitions 6

61 Division Example: First Version iteration step Quotient Divisor Remainder initial values : Rem = Rem - Div 2b: Rem < +Div, sll Q, Q= 3: shift Div right 2 : Rem = Rem - Div 2b: Rem < +Div, sll Q, Q= 3: shift Div right 3 : Rem = Rem - Div 2b: Rem < +Div, sll Q, Q= 3: shift Div right 4 : Rem = Rem - Div 2a: Rem sll Q, Q= 3: shift Div right 5 : Rem = Rem - Div 2a: Rem sll Q, Q= 3: shift Div right 6

62 Division Hardware: Second Version Divisor 32 bits Quotient shift left 32 bits 32-bit ALU Remainder 64 bits shift left write control test 62

63 Division Hardware: Third Version Divisor 32 bits 32-bit ALU Remainder shift right shift left write control test 64 bits 63

64 Division Algorithm: Third Version start. shift the Remainder register left bit 2. subtract the Divisor register from the left half of the Remainder register and place the result in the left half of the Remainder register Remainder>= 3a. shift the Remainder register to the left, setting the new rightmost bit to Test Remainder Remainder< 3b. restore the original value by adding the Divisor register to the left half of the Remainder register and place the sum in the left half of the Remainder register. Also shift the Remainder register to the left, setting the new rightmost bit to 33rd repetition? no: < 33 repetitions yes: 33 repetitions done. shift left half of Remainder right bit 64

65 Division Example: Third Version iteration step Divisor Remainder initial value shift Rem left 2: Rem = Rem Div 3b: Rem < +Div, sll R, R = 2 2: Rem = Rem Div 3b: Rem < +Div, sll R, R = 3 2: Rem = Rem Div 3a: Rem +Div, sll R, R = 4 2: Rem = Rem Div 3a: Rem +Div, sll R, R = shift left half of Rem right 65

66 MIPS Division Use HI/LO registers for result HI: 32-bit remainder LO: 32-bit quotient Instructions div rs, rt / divu rs, rt No overflow or divide-by- checking Software must perform checks if required Use mfhi, mflo to access result 66

67 Right Shift and Division Left shift by i places multiplies an integer by 2 i Right shift divides by 2 i? Only for unsigned integers For signed integers Arithmetic right shift: replicate the sign bit e.g., 5 / 4 2 >> 2 = 2 = 2 Rounds toward c.f. 2 >>> 2 = 2 =

68 Floating Point We need a way to represent numbers with fractions, e.g., very small numbers, e.g.,. very large numbers, e.g., x 9 Like scientific notation In binary ±.xxxxxxx 2 2 yyyy Types float and double in C 68

69 Floating Point Standard Defined by IEEE Std Developed in response to divergence of representations Portability issues for scientific code Now almost universally adopted Two representations Single precision (32-bit) Double precision (64-bit) 69

70 IEEE Floating-Point Format single: 8 bits double: bits S Exponent x ( ) S single: 23 bits double: 52 bits Fraction ( Fraction) 2 (Exponent Bias) S: sign bit ( non-negative, negative) Normalize significand:. significand < 2. Always has a leading pre-binary-point bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the. restored Exponent: excess representation: actual exponent + Bias Ensures exponent is unsigned Single: Bias = 27; Double: Bias = 23 7

71 Single-Precision Range Exponents and reserved Smallest value Exponent: actual exponent = 27 = 26 Fraction: significand =. ± ±.2 38 Largest value Exponent: actual exponent = = +27 Fraction: significand 2. ± ±

72 Double-Precision Range Exponents and reserved Smallest value Exponent: actual exponent = 23 = 22 Fraction: significand =. ± ± Largest value Exponent: actual exponent = = +23 Fraction: significand 2. ± ±

73 Floating-Point Precision Relative precision all fraction bits are significant Single: approx 2 23 Equivalent to 23 log decimal digits of precision Double: approx 2 52 Equivalent to 52 log decimal digits of precision 73

74 Floating-Point Example Represent = ( ). 2 2 S = Fraction = 2 Exponent = + Bias Single: + 27 = 26 = 2 Double: + 23 = 22 = 2 Single: Double: 74

75 Floating-Point Example What number is represented by the single-precision float S = Fraction = 2 Exponent = 2 = 29 x = ( ) ( + 2 ) 2 (29 27) = ( ) = 5. 75

76 Floating-Point Addition x +.6 x - =?..6 x - =.6 x align decimal points shift number with smaller exponent =.5 add significands 3..5 x =.5 x 2 normalize result & check for over/underflow 4..5 x 2 =.2 x 2 round and renormalize if necessary 76

77 Floating-Point Addition Now consider a 4-digit binary example ( ). Align binary points Shift number with smaller exponent Add significands = Normalize result & check for over/underflow , with no over/underflow 4. Round and renormalize if necessary (no change) =

78 Floating-Point Addition start. compare the exponents of the two numbers. shift the smaller number to the right until its exponent would match the larger exponent 2. add the significands 3. normalize the sum, either shifting right and incrementing the exponent or shifting left and decrementing the exponent overflow or underflow? yes no exception 4. round the significand to the appropriate number of bits no still normalized? done yes 78

79 Floating-Point Addition Sign Exponent Fraction Sign Exponent Fraction small ALU exponent difference control shift right big ALU incrementor difference shift left or right rounding hardware Sign Exponent Fraction 79

80 Floating-Point Multiplication. x x 9.2 x -5 =?. addition of exponents + -5 = 5 2. multiplication of significands. x 9.2 = x 5 =.22 x x 6 =.2 x 6 5. determination of sign + 8

81 Floating-Point Multiplication Now consider a 4-digit binary example ( ). Add exponents + 2 = 3 2. Multiply significands = Normalize result & check for over/underflow (no change) with no over/underflow 4. Round and renormalize if necessary (no change) 5. Determine sign: +ve ve ve =

82 Floating-Point Multiplication start. add the biased exponents of the two numbers, subtracting the bias from the sum to get the new biased exponent 2. multiply the significands 3. normalize the product if necessary, shifting if right and incrementing the exponent overflow or underflow? yes no 4. round the significand to the appropriate number of bits exception no still normalized? yes 5. set the sign of the product to positive if the signs of the original operands are the same; if they differ make the sign negative 82 done

83 Rounding with Guard Digits 2.56 x x 2 =? with Guard Digits (2 extra bits).256 x x 2 = x 2 = 2.37 x 2 without Guard Digits.2 x x 2 = 2.36 x 2 83

84 FP Instructions in MIPS Separate FP registers 32 single-precision: $f, $f, $f3 Paired for double-precision: $f/$f, $f2/$f3, FP instructions operate only on FP registers Programs generally don t do integer ops on FP data, or vice versa More registers with minimal code-size impact FP load and store instructions lwc, ldc, swc, sdc e.g., ldc $f8, 32($sp) 84

85 FP Instructions in MIPS Single-precision arithmetic add.s, sub.s, mul.s, div.s e.g., add.s $f, $f, $f6 Double-precision arithmetic add.d, sub.d, mul.d, div.d e.g., mul.d $f4, $f4, $f6 Single- and double-precision comparison c.xx.s, c.xx.d (xx is eq, lt, le, ) Sets or clears FP condition-code bit e.g. c.lt.s $f3, $f4 Branch on FP condition code true or false bct, bcf e.g., bct TargetLabel 85

86 FP Example: F to C C code: float f2c (float fahr) { return ((5./9.)*(fahr - 32.)); } fahr in $f2, result in $f, literals in global memory space MIPS code: f2c: lwc $f6, const5($gp) lwc2 $f8, const9($gp) div.s $f6, $f6, $f8 lwc $f8, const32($gp) sub.s $f8, $f2, $f8 mul.s $f, $f6, $f8 jr $ra 86

Chapter 3. Arithmetic Text: P&H rev

Chapter 3. Arithmetic Text: P&H rev Chapter 3 Arithmetic Text: P&H rev3.29.16 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Thomas Polzer Institut für Technische Informatik

Thomas Polzer Institut für Technische Informatik Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers VO

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Boolean Algebra Boolean algebra is the basic math used in digital circuits and computers.

More information

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Floating Point Arithmetic Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Floating Point (1) Representation for non-integral numbers Including very

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

Arithmetic for Computers. Hwansoo Han

Arithmetic for Computers. Hwansoo Han Arithmetic for Computers Hwansoo Han Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

TDT4255 Computer Design. Lecture 4. Magnus Jahre

TDT4255 Computer Design. Lecture 4. Magnus Jahre 1 TDT4255 Computer Design Lecture 4 Magnus Jahre 2 Chapter 3 Computer Arithmetic ti Acknowledgement: Slides are adapted from Morgan Kaufmann companion material 3 Arithmetic for Computers Operations on

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Chapter 3 Arithmetic for Computers (Part 2)

Chapter 3 Arithmetic for Computers (Part 2) Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

More information

Computer Architecture Set Four. Arithmetic

Computer Architecture Set Four. Arithmetic Computer Architecture Set Four Arithmetic Arithmetic Where we ve been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What

More information

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point Chapter 3 Part 2 Arithmetic for Computers Floating Point Floating Point Representation for non integral numbers Including very small and very large numbers 4,600,000,000 or 4.6 x 10 9 0.0000000000000000000000000166

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI Homework 4 Assigned on Feb 22, Thursday Due Time: 11:59pm, March 5 on Monday

More information

Review: MIPS Organization

Review: MIPS Organization 1 MIPS Arithmetic Review: MIPS Organization Processor Memory src1 addr 5 src2 addr 5 dst addr 5 write data Register File registers ($zero - $ra) bits src1 data src2 data read/write addr 1 1100 2 30 words

More information

Written Homework 3. Floating-Point Example (1/2)

Written Homework 3. Floating-Point Example (1/2) Written Homework 3 Assigned on Tuesday, Feb 19 Due Time: 11:59pm, Feb 26 on Tuesday Problems: 3.22, 3.23, 3.24, 3.41, 3.43 Note: You have 1 week to work on homework 3. 3 Floating-Point Example (1/2) Q:

More information

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers Chapter 3 Arithmetic for Computers 1 Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing the Architecture operation

More information

MIPS Integer ALU Requirements

MIPS Integer ALU Requirements MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set

More information

Computer Architecture. Chapter 3: Arithmetic for Computers

Computer Architecture. Chapter 3: Arithmetic for Computers 182.092 Computer Architecture Chapter 3: Arithmetic for Computers Adapted from Computer Organization and Design, 4 th Edition, Patterson & Hennessy, 2008, Morgan Kaufmann Publishers and Mary Jane Irwin

More information

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic 5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner Topic 3: Arithmetic These slides are mostly taken verbatim, or with minor changes, from those

More information

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

More information

Arithmetic. Chapter 3 Computer Organization and Design

Arithmetic. Chapter 3 Computer Organization and Design Arithmetic Chapter 3 Computer Organization and Design Addition Addition is similar to decimals 0000 0111 + 0000 0101 = 0000 1100 Subtraction (negate) 0000 0111 + 1111 1011 = 0000 0010 Over(under)flow For

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

More information

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Signed Multiplication Multiply the positives Negate result if signs of operand are different Another Improvement Save on space: Put multiplier in product saves on speed: only single shift needed Figure: Improved hardware for multiplication Signed Multiplication Multiply the positives Negate result

More information

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers Chapter 3 Arithmetic for Computers 1 Outline Signed and unsigned numbers (Sec. 3.2) Addition and subtraction (Sec. 3.3) Multiplication (Sec. 3.4) Division (Sec. 3.5) Floating point (Sec. 3.6) 2 Representation

More information

3.5 Floating Point: Overview

3.5 Floating Point: Overview 3.5 Floating Point: Overview Floating point (FP) numbers Scientific notation Decimal scientific notation Binary scientific notation IEEE 754 FP Standard Floating point representation inside a computer

More information

Arithmetic for Computers

Arithmetic for Computers MIPS Arithmetic Instructions Cptr280 Dr Curtis Nelson Arithmetic for Computers Operations on integers Addition and subtraction; Multiplication and division; Dealing with overflow; Signed vs. unsigned numbers.

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 10: Multiplication & Floating Point Representation Adapted from Computer Organization and Design, Patterson & Hennessy, UCB MIPS Division Two 32-bit registers

More information

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures Homework 3 Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) 1 CSCI 402: Computer Architectures Arithmetic for Computers (2) Fengguang Song Department

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Basics Midterm to cover Book Sections (inclusive) 1.1 1.5

More information

Integer Multiplication and Division

Integer Multiplication and Division Integer Multiplication and Division COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS Lecture 13 Floating Point I (1) Fall 2005 Integer Multiplication (1/3) Paper and pencil example (unsigned): Multiplicand 1000 8

More information

Floating Point COE 308. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals

Floating Point COE 308. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals Floating Point COE 38 Computer Architecture Prof. Muhamed Mudawar Computer Engineering Department King Fahd University of Petroleum and Minerals Presentation Outline Floating-Point Numbers IEEE 754 Floating-Point

More information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point

More information

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Integer Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring EE 260: Introduction to Digital Design Arithmetic II Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Integer multiplication n Booth s algorithm n Integer division

More information

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions Outline EEL-4713 Computer Architecture Multipliers and shifters Multiplication and shift registers Chapter 3, section 3.4 Next lecture Division, floating-point 3.5 3.6 EEL-4713 Ann Gordon-Ross.1 EEL-4713

More information

CENG3420 L05: Arithmetic and Logic Unit

CENG3420 L05: Arithmetic and Logic Unit CENG3420 L05: Arithmetic and Logic Unit Bei Yu byu@cse.cuhk.edu.hk (Latest update: January 25, 2018) Spring 2018 1 / 53 Overview Overview Addition Multiplication & Division Shift Floating Point Number

More information

EEC 483 Computer Organization

EEC 483 Computer Organization EEC 483 Computer Organization Chapter 3. Arithmetic for Computers Chansu Yu Table of Contents Ch.1 Introduction Ch. 2 Instruction: Machine Language Ch. 3-4 CPU Implementation Ch. 5 Cache and VM Ch. 6-7

More information

Number Systems and Their Representations

Number Systems and Their Representations Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

More information

Lecture 10: Floating Point, Digital Design

Lecture 10: Floating Point, Digital Design Lecture 10: Floating Point, Digital Design Today s topics: FP arithmetic Intro to Boolean functions 1 Examples Final representation: (-1) S x (1 + Fraction) x 2 (Exponent Bias) Represent -0.75 ten in single

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Arithmetic for Computers James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Arithmetic for

More information

Lecture 10: Floating Point, Digital Design

Lecture 10: Floating Point, Digital Design Lecture 10: Floating Point, Digital Design Today s topics: FP arithmetic Intro to Boolean functions 1 Examples Final representation: (-1) S x (1 + Fraction) x 2 (Exponent Bias) Represent -0.75 ten in single

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Chapter Three. Arithmetic

Chapter Three. Arithmetic Chapter Three 1 Arithmetic Where we've been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing

More information

xx.yyyy Lecture #11 Floating Point II Summary (single precision): Precision and Accuracy Fractional Powers of 2 Representation of Fractions

xx.yyyy Lecture #11 Floating Point II Summary (single precision): Precision and Accuracy Fractional Powers of 2 Representation of Fractions CS61C L11 Floating Point II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II 2007-7-12 Scott Beamer, Instructor Sony & Nintendo make E3 News www.nytimes.com Review

More information

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers CSE 675.02: Introduction to Computer Architecture MIPS Processor Memory Instruction Set Architecture of MIPS Processor CPU Arithmetic Logic unit Registers $0 $31 Multiply divide Coprocessor 1 (FPU) Registers

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

Integer Subtraction. Chapter 3. Overflow conditions. Arithmetic for Computers. Signed Addition. Integer Addition. Arithmetic for Computers

Integer Subtraction. Chapter 3. Overflow conditions. Arithmetic for Computers. Signed Addition. Integer Addition. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Integer Subtraction Chapter 3 Arithmetic for Computers Add negation of second operand Example: 7 6 = 7 + ( 6) +7: 0000 0000

More information

CENG 3420 Lecture 05: Arithmetic and Logic Unit

CENG 3420 Lecture 05: Arithmetic and Logic Unit CENG 3420 Lecture 05: Arithmetic and Logic Unit Bei Yu byu@cse.cuhk.edu.hk CENG3420 L05.1 Spring 2017 Outline q 1. Overview q 2. Addition q 3. Multiplication & Division q 4. Shift q 5. Floating Point Number

More information

CPE300: Digital System Architecture and Design

CPE300: Digital System Architecture and Design CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Arithmetic Unit 10122011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Fixed Point Arithmetic Addition/Subtraction

More information

Arithmetic for Computers. Integer Addition. Chapter 3

Arithmetic for Computers. Integer Addition. Chapter 3 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

More complicated than addition. Let's look at 3 versions based on grade school algorithm (multiplicand) More time and more area

More complicated than addition. Let's look at 3 versions based on grade school algorithm (multiplicand) More time and more area Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's look at 3 versions based on grade school algorithm 01010010 (multiplicand) x01101101 (multiplier)

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

More information

COMP 303 Computer Architecture Lecture 6

COMP 303 Computer Architecture Lecture 6 COMP 303 Computer Architecture Lecture 6 MULTIPLY (unsigned) Paper and pencil example (unsigned): Multiplicand 1000 = 8 Multiplier x 1001 = 9 1000 0000 0000 1000 Product 01001000 = 72 n bits x n bits =

More information

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade CSE 141 Computer Architecture Summer Session 1 2004 Lecture 3 ALU Part 2 Single Cycle CPU Part 1 Pramod V. Argade Reading Assignment Announcements Chapter 5: The Processor: Datapath and Control, Sec. 5.3-5.4

More information

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

More information

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm Final Review Format 10 multiple choice 8 points each Make sure to show your work Can write a description to the side as to why you think your answer is correct for possible partial credit 1 short answer

More information

CS/COE 0447 Example Problems for Exam 2 Spring 2011

CS/COE 0447 Example Problems for Exam 2 Spring 2011 CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product

More information

IEEE Standard 754 for Binary Floating-Point Arithmetic.

IEEE Standard 754 for Binary Floating-Point Arithmetic. CS61C L11 Floating Point II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II 2005-10-05 There is one handout today at the front and back of the room! Lecturer

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information

Incompletely Specified Functions with Don t Cares 2-Level Transformation Review Boolean Cube Karnaugh-Map Representation and Methods Examples

Incompletely Specified Functions with Don t Cares 2-Level Transformation Review Boolean Cube Karnaugh-Map Representation and Methods Examples Lecture B: Logic Minimization Incompletely Specified Functions with Don t Cares 2-Level Transformation Review Boolean Cube Karnaugh-Map Representation and Methods Examples Incompletely specified functions

More information

CS222: Processor Design

CS222: Processor Design CS222: Processor Design Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Previous Class: Floating points: Add, Sub, Mul,Div, Rounding Processor Design: Introduction

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #11 Floating Point II Scott Beamer, Instructor Sony & Nintendo make E3 News 2007-7-12 CS61C L11 Floating Point II (1) www.nytimes.com Review

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals [Adapted from

More information

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support Components of an ISA EE 357 Unit 11 MIPS ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2) Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

More information

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction 1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

More information

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers Chapter 3 Arithmetic for Computers Arithmetic for Computers Unsigned vs. Signed Integers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point

More information

Specifying logic functions

Specifying logic functions CSE4: Components and Design Techniques for Digital Systems Specifying logic functions Instructor: Mohsen Imani Slides from: Prof.Tajana Simunic and Dr.Pietro Mercati We have seen various concepts: Last

More information

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal. Page < 1 > Math in MIPS Adding and Subtracting Numbers Adding two binary numbers together is very similar to the method used with decimal numbers, except simpler. When you add two binary numbers together,

More information

Simplification of two-level combinational logic

Simplification of two-level combinational logic ombinational logic optimization! lternate representations of oolean functions " cubes " karnaugh maps! Simplification " two-level simplification " exploiting don t cares " algorithm for simplification

More information

CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B

CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B CPE 335 Computer Organization MIPS Arithmetic Part I Content from Chapter 3 and Appendix B Dr. Iyad Jafar Adatped from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html

More information

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y Arithmetic A basic operation in all digital computers is the addition and subtraction of two numbers They are implemented, along with the basic logic functions such as AND,OR, NOT,EX- OR in the ALU subsystem

More information

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the

More information

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division 361 div.1 Computer Architecture EECS 361 Lecture 7: ALU Design : Division Outline of Today s Lecture Introduction to Today s Lecture Divide Questions and Administrative Matters Introduction to Single cycle

More information

Chapter 5 : Computer Arithmetic

Chapter 5 : Computer Arithmetic Chapter 5 Computer Arithmetic Integer Representation: (Fixedpoint representation): An eight bit word can be represented the numbers from zero to 255 including = 1 = 1 11111111 = 255 In general if an nbit

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: The MIPS ISA (P&H 2.1-2.14) 1 Announcements Consulting hours Milestone #1 (due 1/26) Milestone #2 (due 2/2) 2 1 Review: Integer Operations Internal

More information

MIPS Instruction Set

MIPS Instruction Set MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

More information

Review of Last lecture. Review ALU Design. Designing a Multiplier Shifter Design Review. Booth s algorithm. Today s Outline

Review of Last lecture. Review ALU Design. Designing a Multiplier Shifter Design Review. Booth s algorithm. Today s Outline Today s Outline San Jose State University EE176-SJSU Computer Architecture and Organization Lecture 5 HDL, ALU, Shifter, Booth Algorithm Multiplier & Divider Instructor: Christopher H. Pham Review of Last

More information

Timing for Ripple Carry Adder

Timing for Ripple Carry Adder Timing for Ripple Carry Adder 1 2 3 Look Ahead Method 5 6 7 8 9 Look-Ahead, bits wide 10 11 Multiplication Simple Gradeschool Algorithm for 32 Bits (6 Bit Result) Multiplier Multiplicand AND gates 32

More information

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) (aritmeettis-looginen yksikkö) Does all

More information

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) Does all work in CPU (aritmeettis-looginen

More information

Review. Steps to writing (stateless) circuits: Create a logic function (one per output)

Review. Steps to writing (stateless) circuits: Create a logic function (one per output) MIPS ALU Review Steps to writing (stateless) circuits: Create a truth table Go through all different combinations of inputs For each row, generate each output based on the problem description Create a

More information

Part III The Arithmetic/Logic Unit. Oct Computer Architecture, The Arithmetic/Logic Unit Slide 1

Part III The Arithmetic/Logic Unit. Oct Computer Architecture, The Arithmetic/Logic Unit Slide 1 Part III The Arithmetic/Logic Unit Oct. 214 Computer Architecture, The Arithmetic/Logic Unit Slide 1 About This Presentation This presentation is intended to support the use of the textbook Computer Architecture:

More information

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

Arithmetic Logic Unit

Arithmetic Logic Unit Arithmetic Logic Unit A.R. Hurson Department of Computer Science Missouri University of Science & Technology A.R. Hurson 1 Arithmetic Logic Unit It is a functional bo designed to perform "basic" arithmetic,

More information

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4

Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4 Part I: a Program: Compiler, Linker, Assembler, Loader Lecture 4 Program Translation Hierarchy C program Com piler Assem bly language program Assem bler Object: Machine language module Object: Library

More information

Computer Architecture. The Language of the Machine

Computer Architecture. The Language of the Machine Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

CO Computer Architecture and Programming Languages CAPL. Lecture 15

CO Computer Architecture and Programming Languages CAPL. Lecture 15 CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 15 Dr. Kinga Lipskoch Fall 2017 How to Compute a Binary Float Decimal fraction: 8.703125 Integral part: 8 1000 Fraction part: 0.703125

More information

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation ICS 233 COMPUTER ARCHITECTURE MIPS Processor Design Multicycle Implementation Lecture 23 1 Add immediate unsigned Subtract unsigned And And immediate Or Or immediate Nor Shift left logical Shift right

More information

CO Computer Architecture and Programming Languages CAPL. Lecture 13 & 14

CO Computer Architecture and Programming Languages CAPL. Lecture 13 & 14 CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 13 & 14 Dr. Kinga Lipskoch Fall 2017 Frame Pointer (1) The stack is also used to store variables that are local to function, but

More information