ECE 30 Introduction to Computer Engineering

Similar documents
ECE331: Hardware Organization and Design

Chapter 3: Arithmetic for Computers

ECE 341 Midterm Exam

Chapter 3 Arithmetic for Computers

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

ECE 341 Midterm Exam

Principles of Computer Architecture. Chapter 3: Arithmetic

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Computer Architecture Set Four. Arithmetic

Tailoring the 32-Bit ALU to MIPS

Week 7: Assignment Solutions

Computer Architecture and Organization

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

MIPS Integer ALU Requirements

Binary Adders: Half Adders and Full Adders

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

Computer Organization EE 3755 Midterm Examination

Number Systems and Computer Arithmetic

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

CS Computer Architecture. 1. Explain Carry Look Ahead adders in detail

Arithmetic and Logical Operations

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

ECE 341 Midterm Exam

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

ECE331: Hardware Organization and Design

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Introduction to Computers and Programming. Numeric Values

Computer Organization EE 3755 Midterm Examination

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

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Number System. Introduction. Decimal Numbers

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Two-Level CLA for 4-bit Adder. Two-Level CLA for 4-bit Adder. Two-Level CLA for 16-bit Adder. A Closer Look at CLA Delay

Chapter 5 : Computer Arithmetic

Binary Arithmetic. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T.

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

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Integer Multiplication and Division

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

ECE232: Hardware Organization and Design

Unsigned Binary Integers

Unsigned Binary Integers

CPE300: Digital System Architecture and Design

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Numeric Encodings Prof. James L. Frankel Harvard University

ECE 341. Lecture # 6

EE 109 Unit 6 Binary Arithmetic

Basic Arithmetic (adding and subtracting)

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Computer Organization EE 3755 Midterm Examination

Topics. 6.1 Number Systems and Radix Conversion 6.2 Fixed-Point Arithmetic 6.3 Seminumeric Aspects of ALU Design 6.4 Floating-Point Arithmetic

Computer Organisation CS303

EC2303-COMPUTER ARCHITECTURE AND ORGANIZATION

Review: MIPS Organization

Computer Arithmetic Multiplication & Shift Chapter 3.4 EEC170 FQ 2005

COMP2611: Computer Organization. Data Representation

ECE260: Fundamentals of Computer Engineering

CENG 3420 Lecture 05: Arithmetic and Logic Unit

Binary Multiplication

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

CHW 261: Logic Design

Organisasi Sistem Komputer

Experimental Methods I

Chapter 4. Combinational Logic

Thomas Polzer Institut für Technische Informatik

Chapter Three. Arithmetic

CENG3420 L05: Arithmetic and Logic Unit

CS/COE 0447 Example Problems for Exam 2 Spring 2011

Divide: Paper & Pencil

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Lecture 8: Addition, Multiplication & Division

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

ECE260: Fundamentals of Computer Engineering

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

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

ECE260: Fundamentals of Computer Engineering

UNIT IV: DATA PATH DESIGN

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

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

ECE 341. Lecture # 7


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

CS 5803 Introduction to High Performance Computer Architecture: Arithmetic Logic Unit. A.R. Hurson 323 CS Building, Missouri S&T

COMP 303 Computer Architecture Lecture 6

Timing for Ripple Carry Adder

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

Fast Arithmetic. Philipp Koehn. 19 October 2016

Computer Architecture. Chapter 3: Arithmetic for Computers

Number Systems. Both numbers are positive

Chapter 3: part 3 Binary Subtraction

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

Boolean Unit (The obvious way)

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8

Advanced Computer Architecture-CS501

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

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

COMPUTER ORGANIZATION AND DESIGN

Transcription:

ECE 30 Introduction to Computer Engineering Study Problems, Set #6 Spring 2015 1. With x = 1111 1111 1111 1111 1011 0011 0101 0011 2 and y = 0000 0000 0000 0000 0000 0010 1101 0111 2 representing two s complement signed integers, perform the following operations, showing all your work. Also verify that your results are correct by converting the numbers into decimal notation. (a) x + y (b) x y (c) x y Solution: (a) x + y x + y = 1111 1111 1111 1111 1011 0011 0101 0011 2 + 0000 0000 0000 0000 0000 0010 1101 0111 2 = 1111 1111 1111 1111 1011 0110 0010 1010 2 = (0000 0000 0000 0000 0100 1001 1101 0101 2 + 1) = 0000 0000 0000 0000 0100 1001 1101 0110 2 = 18902 10 We can check our work as follows: x = 1111 1111 1111 1111 1011 0011 0101 0011 2 = (0000 0000 0000 0000 0100 1100 1010 1100 2 + 1) = 2 = 19629 10 y = 0000 0000 0000 0000 0000 0010 1101 0111 2 = 727 10 1

Since 19629 10 + 727 10 = 18902 10, our answer makes sense. (b) x y x y = x + ( y) = 1111 1111 1111 1111 1011 0011 0101 0011 2 + (0000 0000 0000 0000 0000 0010 1101 0111 2 ) = 1111 1111 1111 1111 1011 0011 0101 0011 2 + 1111 1111 1111 1111 1111 1101 0010 1000 2 + 1 = 1111 1111 1111 1111 1011 0000 0111 1100 2 = (0000 0000 0000 0000 0100 1111 1000 0011 2 + 1) = 0000 0000 0000 0000 0100 1111 1000 0100 2 = 20356 10 We can check our work as follows: x = 1111 1111 1111 1111 1011 0011 0101 0011 2 = (0000 0000 0000 0000 0100 1100 1010 1100 2 + 1) = 2 = 19629 10 y = 0000 0000 0000 0000 0000 0010 1101 0111 2 = 727 10 Since 19629 10 727 10 = 20356 10, our answer makes sense. (c) x y Since x is negative, we two-complement x to obtain x, a positive number. We then perform a standard longhand multiplication between the positive numbers x and y. Finally, we negate the result to obtain the correct answer. 2

x y = ( x y) = 0000 0000 0000 0000 0000 0010 1101 0111 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000... (all zeroes from here on) 0000 0000 0000 0000 1101 1001 1011 1111 0100 1011 2 = 1111 1111 1111 1111 0010 0110 0100 0000 1011 0101 2 (taking 2 s complement) = 14270283 10 We can check our work as follows: x = 1111 1111 1111 1111 1011 0011 0101 0011 2 = (0000 0000 0000 0000 0100 1100 1010 1100 2 + 1) = 2 = 19629 10 y = 0000 0000 0000 0000 0000 0010 1101 0111 2 = 727 10 Since 19629 10 727 10 = 14270283 10, our answer makes sense. 2. Bit patterns have no inherent meaning. They may represent signed integers, unsigned integers, floating-point numbers, instructions, and so on. What is represented depends on the context. 3

What does the bit pattern 10101101000100000000000000000010 2 represent, assuming that it is (a) a two s complement integer? (b) an unsigned integer? (c) a single precision floating-point number? (d) a MIPS instruction? Solution: (a) 1010 1101 0001 0000 0000 0000 0000 0010 2 = (0101 0010 1110 1111 1111 1111 1111 1101 2 + 1) = 0101 0010 1110 1111 1111 1111 1111 1110 2 = 1391460350 ten (b) 1010 1101 0001 0000 0000 0000 0000 0010 2 = 2903506946 ten (c) sign = 1 exponent = 01011010 = 90 fraction = 00100000000000000000010 = 2 3 + 2 22 ( 1) 1 (1 +.00100000000000000000010 2 ) 2 (90 127) = 8.1854541 10 12 (d) opcode: 101011 = sw (so, it must be a I-format instruction) rs: 01000 = $t0 rt: 10000 = $s0 immediate: 0000000000000010 = 2 ten So, the instruction is sw $s0, 2($t0). 3. Show the IEEE 754 binary representation for the floating-point number 20 ten in single and double precision. 4

Solution: Single Precision Single precision floating point numbers are of the form: ( 1) sign 1.fraction 2 (exponent 127) sign = 0 (20 is positive) exponent = 127 + log 2 (20) = 131 = 10000011 fraction = 20 2 131 127 1 = 0.25 = 2 2 = 01000000000000000000000 So, 20 ten = 01000001101000000000000000000000 Double Precision Double precision floating point numbers are of the form: ( 1) sign 1.fraction 2 (exponent 1023) sign = 0 (20 is positive) exponent = 1023 + log 2 (20) = 1027 = 10000000011 fraction = 20 2 1027 1023 1 = 0.25 = 2 2 = 0100000000000000000000000000000000000000000000000000 So, 20 ten = 0100000000110100000000000000000000000000000000000000000000000000 4. Write a sequence of MIPS R2000 instructions for computing 0x56789abc 0.75 with the smallest execution time. Assume that 0x56789abc is initially stored in $t0. Use any of the following instructions whose CPI s are as follows: The CPI of mult is 5. The CPI of each of srl, sll, add, and sub is 1. The least significant 32 bits of the resulting product must be stored in $t2. Solution: The instruction sequence is: srl $t2, $t0, 2 # $t2 = multiplicand x 0.25 sub $t2, $t0, $t2 # $t2 = multiplicand x 0.75 5

5. Trace the steps of multiplying a 5-bit two s complement multiplicand 10110 2 with a 3-bit two s complement multiplier 111 2, using Booth s algorithm. Assume that the shift-add multiplier shown below is used. Initially, the most significant 5 bits of the 8-bit product register contain 00000 and the least significant 3 bits contain the multiplier (111 2 ). When the algorithm completes, the product register must contain the 8-bit product in two s complement representation. Complete the table below. 6

Solution: The result of Booth s algorithm is as follows: 7

6. Trace the steps of multiplying a 5-bit two s complement multiplicand 10001 2 with a 3-bit two s complement multiplier 011 2, using Booth s algorithm. Assume that the shift-add multiplier shown below is used. Initially, the most significant 5 bits of the 8-bit product register contain 00000 and the least significant 3 bits contain the multiplier (011 2 ). When the algorithm completes, the product register must contain the 8-bit product in two s complement representation. Complete the table below. 8

Solution: The result of Booth s algorithm is as follows: 9

7. We have seen that a subtraction A B can be computed as A + ( B). Assuming that A and B are represented in two s complement representation, construct a 4-bit adder/subtractor using four full adders and XOR gates. The resulting adder/subtractor circuit should perform either addition or subtraction depending on the value of a select bit S. For S = 0, the circuit is to behave as an adder. For S = 1, the circuit is to perform subtraction. Solution: Addition (S = 0): X i = B i and C 0 = S = 0, so the circuit simply adds A and B. Subtraction (S = 1): X i = B i and C 0 = S = 1, so the circuit adds A, B and 1. Since B + 1 generates B in two s complement representation, adding A, B and 1 is equivalent to adding A and B, or, subtracting B from A. 10

8. a) Construct a 64-bit, 3-level carry lookahead adder using 4-bit CLA (carry lookahead adder) blocks and 4-bit lookahead carry generator blocks as shown below. b) What is the worst-case propagation delay from a change in inputs to the last sum bit, given the following: - Delay from a i /b i /c 0 to g i /p i (lookahead carry generator inputs inside 4-bit CLA) = 1T. - Delay from g i /p i /c 0 to G/P/c i (lookahead carry generator) = 2T. - Delay from c i to s i (for full adder inside 4-bit CLA) = 1T. Solution: a) A 3-level carry lookahead adder is shown in the diagram below. The P and G outputs from the CLA blocks (indicated with superscript 1) form the p i and g i inputs to the level-2 lookahead carry generator. Each level-2 lookahead carry generator accepts these inputs and generates carries and its own P and G outputs (indicated with superscript 2). This way, the level-2 lookahead carry generators provide the p i and g i inputs to the next level, i.e., the level-3 lookahead carry generator. The level-3 lookahead carry generator generates the carries c 16, c 32, c 48 and c 64. 11

b) The following table provides the sequence of signals generated and the delay involved in generating each of them. Level Signal computed Delay PRE g i, p i inside each 4-bit CLA 1T 1 g i, p i to G 1 and P 1 outputs of 4-bit CLA s 2T 2 G 1 and P 1 to G 2 and P 2 outputs of level-2 lookahead carry generators 2T 3 G 2 and P 2 to c 16, c 32, c 48 outputs of level-3 lookahead carry generator 2T 2 c 16, c 32, c 48 to c 20, c 24, c 28, c 36, c 40, c 44, c 52, c 56, c 60 2T 1 c 20, c 24,..., c 60 to c 21, c 22, c 23, c 25, c 26, c 27,..., c 61, c 62, c 63 2T POST c 21, c 22, c 23, c 25, c 26, c 27,..., c 61, c 62, c 63 to s 21, s 22, s 23, s 25, s 26.s 27,..., s 61, s 62, s 63 1T Therefore, the worst-case delay from the inputs a i /b i /c 0 to the sum bits s i is given by: 1T + 2T + 2T + 2T + 2T + 2T + 1T = 12T. 12