Lectures Computer architecture: Chapter 3 - ThS. Trần Thị Như Nguyệt
Số trang: 54
Loại file: pdf
Dung lượng: 5.03 MB
Lượt xem: 26
Lượt tải: 0
Xem trước 6 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Lectures "Computer architecture - Chapter 3: Arithmetic for computers" provides learners with the knowledge: Addition and subtraction, multiplication, division, floating point, parallelism and computer arithmetic - Associativity. Invite you to refer to the disclosures.
Nội dung trích xuất từ tài liệu:
Lectures Computer architecture: Chapter 3 - ThS. Trần Thị Như Nguyệt CE COMPUTER ARCHITECTURE CHAPTER 3 ARITHMETIC FOR COMPUTERS 1 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 2 CE Arithmetic for Computers 3 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 4 CE Introduction Computer words are composed of bits; thus, words can be represented as binary numbers. Chapter 2 shows that integers can be represented either in decimal or binary form, but what about the other numbers that commonly occur? For example: ■ What about fractions and other real numbers? ■ What happens if an operation creates a number bigger than can be represented? ■ And underlying these questions is a mystery: How does hardware really multiply or divide numbers? 5 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 6 CE Addition and Subtraction Addition: Binary addition, showing carries from right to left 7 CE Addition and Subtraction Subtraction: 8 CE Addition and Subtraction Overflow When does the overflow occur on the signed number? We also need to concern: - How to detect overflow for two’s complement numbers in a computer? - What about overflow with unsigned integers? (Unsigned integers are commonly used for memory addresses where overflows are ignored.) 9 CE Addition and Subtraction Overflow The computer designer must therefore provide a way to ignore overflow in some cases and to recognize it in others. The MIPS solution is to have two kinds of arithmetic instructions to recognize the two choices: ■ Add (add), add immediate (addi), and subtract (sub) cause exceptions (interrupt) on overflow. ■ Add unsigned (addu), add immediate unsigned (addiu), and subtract unsigned (subu) do not cause exceptions on overflow. Note: MIPS detects overflow with an exception, also called an interrupt on many computers. An exception or interrupt is essentially an unscheduled procedure call. 10 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 11 CE Multiplication Example Although the decimal example above happens to use only 0 and 1, multiplication of binary numbers must always use 0 and 1, and thus always offers only these two choices: 1. Just place a copy of the multiplicand (1 ×multiplicand) in the proper place if the multiplier digit is a 1. 2. Place 0 (0 ×multiplicand) in the proper place if the multiplier digit is 0. 12 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Fig.1: First version of the division hardware Note: Three steps are repeated 32 times to obtain the product. If each step took a clock cycle, this algorithm would require almost 100 clock cycles to multiply two 32-bit numbers. Fig.2: The first multiplication algorithm 13 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Example: Answer: Step by step follow the multiplication algorithm 14 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Fig.3 Refine version of the multiplication hardware Compare with the first version in the previous slide, the Multiplicand register, ALU, and Multiplier register are all 32 bits wide, with only the Product register left at 64 bits. It just takes one clock cycle to get the Product. 15 CE Multiplication Signed Multiplication The easiest way to understand how to deal with signed numbers is to first convert the multiplier and multiplicand to positive numbers and then remember the original signs. The algorithms should then be run for 31 iterations, leaving the signs out of the calculation. It turns out that the last algorithm will work for signed numbers. 16 CE Multiplication Faster Multiplication Fig.4 Fast multiplication hardware. 17 CE Multiplication Multiply in MIPS MIPS provides ...
Nội dung trích xuất từ tài liệu:
Lectures Computer architecture: Chapter 3 - ThS. Trần Thị Như Nguyệt CE COMPUTER ARCHITECTURE CHAPTER 3 ARITHMETIC FOR COMPUTERS 1 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 2 CE Arithmetic for Computers 3 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 4 CE Introduction Computer words are composed of bits; thus, words can be represented as binary numbers. Chapter 2 shows that integers can be represented either in decimal or binary form, but what about the other numbers that commonly occur? For example: ■ What about fractions and other real numbers? ■ What happens if an operation creates a number bigger than can be represented? ■ And underlying these questions is a mystery: How does hardware really multiply or divide numbers? 5 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 6 CE Addition and Subtraction Addition: Binary addition, showing carries from right to left 7 CE Addition and Subtraction Subtraction: 8 CE Addition and Subtraction Overflow When does the overflow occur on the signed number? We also need to concern: - How to detect overflow for two’s complement numbers in a computer? - What about overflow with unsigned integers? (Unsigned integers are commonly used for memory addresses where overflows are ignored.) 9 CE Addition and Subtraction Overflow The computer designer must therefore provide a way to ignore overflow in some cases and to recognize it in others. The MIPS solution is to have two kinds of arithmetic instructions to recognize the two choices: ■ Add (add), add immediate (addi), and subtract (sub) cause exceptions (interrupt) on overflow. ■ Add unsigned (addu), add immediate unsigned (addiu), and subtract unsigned (subu) do not cause exceptions on overflow. Note: MIPS detects overflow with an exception, also called an interrupt on many computers. An exception or interrupt is essentially an unscheduled procedure call. 10 CE Arithmetic for Computers 1. Introduction 2. Addition and Subtraction 3. Multiplication 4. Division 5. Floating Point 6. Parallelism and Computer Arithmetic: Associativity 11 CE Multiplication Example Although the decimal example above happens to use only 0 and 1, multiplication of binary numbers must always use 0 and 1, and thus always offers only these two choices: 1. Just place a copy of the multiplicand (1 ×multiplicand) in the proper place if the multiplier digit is a 1. 2. Place 0 (0 ×multiplicand) in the proper place if the multiplier digit is 0. 12 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Fig.1: First version of the division hardware Note: Three steps are repeated 32 times to obtain the product. If each step took a clock cycle, this algorithm would require almost 100 clock cycles to multiply two 32-bit numbers. Fig.2: The first multiplication algorithm 13 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Example: Answer: Step by step follow the multiplication algorithm 14 CE Multiplication Sequential Version of the Multiplication Algorithm and Hardware Fig.3 Refine version of the multiplication hardware Compare with the first version in the previous slide, the Multiplicand register, ALU, and Multiplier register are all 32 bits wide, with only the Product register left at 64 bits. It just takes one clock cycle to get the Product. 15 CE Multiplication Signed Multiplication The easiest way to understand how to deal with signed numbers is to first convert the multiplier and multiplicand to positive numbers and then remember the original signs. The algorithms should then be run for 31 iterations, leaving the signs out of the calculation. It turns out that the last algorithm will work for signed numbers. 16 CE Multiplication Faster Multiplication Fig.4 Fast multiplication hardware. 17 CE Multiplication Multiply in MIPS MIPS provides ...
Tìm kiếm theo từ khóa liên quan:
Lectures Computer architecture Computer architecture Arithmetic for computers Addition and subtraction Parallelism and computer arithmetic Floating pointGợi ý tài liệu liên quan:
-
Lecture Computer Architecture - Chapter 1: Technology and Performance evaluation
34 trang 167 0 0 -
Ebook Digital design and computer architecture - David Money Harris, Sarah L. Harris
561 trang 122 0 0 -
Lectures Computer architecture: Chapter 2 - ThS. Trần Thị Như Nguyệt
62 trang 46 0 0 -
Lecture Computer architecture - Lecture 4: MIPS ISA (1)
38 trang 45 0 0 -
Lecture Computer architecture - Lecture 12: Memory
27 trang 44 0 0 -
Lecture Computer Architecture: Introduction
9 trang 44 0 0 -
Bài giảng Kiến trúc máy tính: Chương 5 - Tạ Kim Huệ
83 trang 42 0 0 -
Lecture Computer architecture - Lecture 13: Memory (cont.)
31 trang 40 0 0 -
Lecture Computer Architecture - Chapter 3: Computer arithmetic
37 trang 39 0 0 -
Lecture Computer architecture - Lecture 14: Summary
19 trang 39 0 0