COE 308 – Computer Architecture Exam I – Fall 2008 Monday, November 24, 2008 7:00 pm – 9:00 pm Computer Engineering Department College of Computer Sciences & Engineering King Fahd University of Petroleum & Minerals Student Name: Student ID: Q1 / 10 Q2 / 10 Q3 / 20 Q4 / 20 Q5 / 20 Q6 / 25 Total / 105 Important Reminder on Academic Honesty Using unauthorized information on an exam, peeking at others work, or altering graded exams to claim more credit are severe violations of academic honesty. Detected cases will receive a failing grade in the course. Prepared by Dr. Muhamed Mudawar Page 1 of 7 Page 2 of 7 Q1. a) (5 pts) A wafer containing 100 copies of a 2 cm2 die costs $900 to manufacture. The defect density is 2/cm2. What is the manufacturing cost of a good die? The die yield is given by the following formula: Die yield = [1 + (Defect density × Die area)/3]-3 b) (5 pts) If the die area is reduced from 2 cm2 to 1 cm2, what will be manufacturing cost of the smaller 1 cm2 die? Q2. Given the bit pattern of a single-precision floating-point number: 11000110110101000000000000000000 (binary) a) (4 pts) What is the decimal value of the above number? b) (6 pts) Show the single precision representation for -0.05, rounded to the nearest even. Page 3 of 7 Q3. (20 pts) Write a minimal sequence of real MIPS instructions to: a) (4 pts) Produce a carry bit in $t0 that results from the addition of $s0 and $s1. b) (6 pts) Produce an overflow bit in $t0 from the addition of $s0 and $s1. Hint: overflow occurs if $s0 and $s1 have the same sign, but their sum has a different sign. c) (5 pts) Swap the content of registers $s0 and $s1 without disturbing the content of any other register. Hint: (x y) y = x d) (5 pts) Rotate left the content of registers $s0 by 7 bits and put the result in register in register $t0. Only register $at can be used for intermediate results. Page 4 of 7 Q4. a) (8 pts) The following code computes a result in register $s1, when given a positive integer N in register $s0. Describe what the code does and what will be returned in register $s1. How many instructions are executed in all iterations in terms of N? loop: done: b) add addi addi addi add beq addi j add $t2, $t2, $t0, $t1, $t0, $t1, $t1, loop $s1, $s0, $s0 $t2, 1 $zero, 0 $zero, 1 $t0, $t1 $t2, done $t1, 2 $zero, $t0 (12 pts) The following code fragment processes two arrays and produces a result in register $v0. Assume that each array consists of N words, the base addresses of the arrays are stored in $a0 and $a1 respectively, and their size (N) is stored in $a2. Describe what the code does and what will be returned in $v0. How many instructions are executed in all iterations in terms of N? sll add add outer: add lw add inner: add lw bne addi skip: addi bne addi bne $a2, $v0, $t0, $t4, $t4, $t1, $t3, $t3, $t3, $v0, $t1, $t1, $t0, $t0, $a2, 2 $zero, $zero $zero, $zero $a0, $t0 0($t4) $zero, $zero $a1, $t1 0($t3) $t4, skip $v0, 1 $t1, 4 $a2, inner $t0, 4 $a2, outer Page 5 of 7 Q5. (20 pts) Given that x = 1 10000101 101100000000000000000012 and y = 1 01111111 010000000000000001000002 are single precision IEEE 754 floating-point numbers. Perform the following operations showing all the intermediate steps and final result in binary. Round to the nearest even. a) b) (10 pts) x + y (10 pts) x * y Page 6 of 7 Q6. (25 Pts) Write MIPS assembly code for the procedure BinarySearch to search an array which has been previously sorted. Each element in the array is a 32-bit signed integer. The procedure receives three parameters: register $a0 = address of array to be searched, $a1 = size (number of elements) in the array, and $a2 = item to be searched. If found then BinarySearch returns in register $v0 = address of the array element where item is found. Otherwise, $v0 = 0. BinarySearch ($a0=array, $a1=size, $a2=item) { lower = 0; upper = size-1; while (lower <= upper) { middle = (lower + upper)/2; if (item == array[middle]) return $v0 = ADDRESS OF array[middle]; else if (item < array[middle]) upper = middle–1; else lower = middle+1; } return $v0=0; } Page 7 of 7 Additional Page if Needed