EE380 Spring 2014 Exam 1 Answer Key

Similar documents
ECE Exam I - Solutions February 19 th, :00 pm 4:25pm

CDA3100 Midterm Exam, Summer 2013

EE380 Fall 2015 Final Exam

CENG 3420 Lecture 06: Datapath

ECE Exam I February 19 th, :00 pm 4:25pm

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

CSEN 601: Computer System Architecture Summer 2014

ECE 30 Introduction to Computer Engineering

CS3350B Computer Architecture Quiz 3 March 15, 2018

CS 351 Exam 2 Mon. 11/2/2015

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

University of California College of Engineering Computer Science Division -EECS. CS 152 Midterm I

Reduced Instruction Set Computer (RISC)

CSc 256 Midterm 2 Spring 2012

Q1: /30 Q2: /25 Q3: /45. Total: /100

CSEE W3827 Fundamentals of Computer Systems Homework Assignment 3 Solutions

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

CSc 256 Midterm 2 Fall 2011

McGill University Faculty of Engineering FINAL EXAMINATION Fall 2007 (DEC 2007)

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

ECE 3056: Architecture, Concurrency and Energy of Computation. Single and Multi-Cycle Datapaths: Practice Problems

EE380 Fall 2015 Final Exam Sample Solution

Machine Organization & Assembly Language

2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

Processor (I) - datapath & control. Hwansoo Han

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

King Fahd University of Petroleum and Minerals College of Computer Science and Engineering Computer Engineering Department

Reduced Instruction Set Computer (RISC)

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

COMP MIPS instructions 2 Feb. 8, f = g + h i;

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

4. What is the average CPI of a 1.4 GHz machine that executes 12.5 million instructions in 12 seconds?

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Arithmetic for Computers

The MIPS Processor Datapath

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

Flow of Control -- Conditional branch instructions

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

2B 52 AB CA 3E A1 +29 A B C. CS120 Fall 2018 Final Prep and super secret quiz 9

Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm

MIPS Assembly Programming

CS 61c: Great Ideas in Computer Architecture

Solution printed. Do not start the test until instructed to do so! CS 2504 Intro Computer Organization Test 2 Spring 2006.

Examples of branch instructions

EE 361 University of Hawaii Fall

Winter 2002 FINAL EXAMINATION

Chapter 5 Solutions: For More Practice

CSE 378 Midterm 2/12/10 Sample Solution

NATIONAL UNIVERSITY OF SINGAPORE

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY

Computer Organization and Components

Project Description EEC 483 Computer Organization, Spring 2019

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates


CSc 256 Final Fall 2016

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

HW2 solutions You did this for Lab sbn temp, temp,.+1 # temp = 0; sbn temp, b,.+1 # temp = -b; sbn a, temp,.+1 # a = a (-b) = a + b;

CS 61C: Great Ideas in Computer Architecture. MIPS CPU Datapath, Control Introduction

Computer Architecture. The Language of the Machine

Programming the processor

CSE 378 Final Exam 3/14/11 Sample Solution

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Laboratory Exercise 6 Pipelined Processors 0.0

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

CS 61C Summer 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

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

Computer Architecture I Midterm I (solutions)

ECE 313 Computer Organization EXAM 2 November 11, 2000

MIPS-Lite Single-Cycle Control

Systems Architecture

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

RISC-V Assembly and Binary Notation

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

EE557--FALL 1999 MAKE-UP MIDTERM 1. Closed books, closed notes

CS 61C Fall 2016 Guerrilla Section 4: MIPS CPU (Datapath & Control)

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

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007

MIPS function continued

Problem maximum score 1 35pts 2 22pts 3 23pts 4 15pts Total 95pts

We are quite familiar with adding two numbers in decimal

Computer Architecture I Midterm I

CS3350B Computer Architecture

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

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

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

Winter 2009 FINAL EXAMINATION Location: Engineering A Block, Room 201 Saturday, April 25 noon to 3:00pm

bits 5..0 the sub-function of opcode 0, 32 for the add instruction

MIPS Reference Guide

Department of Electrical Engineering and Computer Sciences Fall 2003 Instructor: Dave Patterson CS 152 Exam #1. Personal Information

University of California at Santa Barbara. ECE 154A Introduction to Computer Architecture. Quiz #1. October 30 th, Name (Last, First)

Transcription:

Your name is: Your email address is: The two questions you skipped are: There are 15 questions. Each of the first 14 questions is wor th 8points; you must answer any 12 and indicate above which 2 you skipped (no extra credit). You also must answer question 15, which is wor th just 4 points. For the multiple choice questions, indicate your single answer for each question by checking the appropriate box,,unless the question explicitly asks you to mar k all that apply. The short answer questions should get shor t answers; excessively long answers may beconsidered incorrect. You may tear-out the reference page at the end of this exam if you wish, and you do not need to turn that page in. The test is closed book, closed notes, closed minds, nocalculators. Page 1 of 7

1. One of the function units we discussed perfor med sign extension, converting a 16-bit 2 s complement number into the 32-bit 2 s complement representation with the same value. Suppose that you have the 4-bit 2 s complement value 1010. What 8-bit pattern would result from sign extending that value to an 8-bit 2 s complement representation? Sign extension replicates the top bit into the larger representation: 1010 becomes 11111010 2. For this question, mar k all that apply. Which of the following does not descr ibe an instr uction in the MIPS ISA as discussed in this course? Store a 32-bit word from a register into memory Load a 32-bit immediate constant into a register Push a 32-bit value from a register onto a stack inmemor y Add two values in registers and put the result in a third register Add a value from memory toavalue in a register and put the result in that register 3. Using only MIPS instructions listed on the last page of this exam, write assembly code to implement the following C code. Var iables should be placed in the registers with the same name, i.e., t0 is kept in the register named $t0; other t registers may beused as temporar ies. Comment any non-obvious things you do. if (t0 < 0) { t0 = 42; } fi: slt $t1,$t0,$0 beq $t1,$0,fi ori $t0,$0,42 Page 2 of 7

4. Using only MIPS instructions listed on the last page of this exam, write assembly code to implement the following C code. Var iables should be placed in the registers with the same name, i.e., t0 is kept in the register named $t0; other t registers may beused as temporar ies. Comment any non-obvious things you do. while (t0) { t0 = t0 - t1; } while: beq $t0,$0,elihw sub $t0,$t0,$t1 j while elihw: 5. The IEEE 754 floating point standard specifies that a 32-bit float encodes 1 sign bit, 8 bits of exponent, and 24 bits of mantissa. That adds up to 33 bits. How is this possible? Normalized floating point numbers has a 1 in the mantissa MSB; thus, there is no need to store the MSB... and 24 bits fits a 23-bit field. 6. Which one of the following four ways to build a 32-bit 2 s-complement binary adder is not a strictly combinatorial circuit (i.e., might require two clock cycles to compute the correct result)? Ripple carry Carr y select Carr y lookahead Speculative carr y requires a second clock cycle if carry guess was wrong None of the above Page 3 of 7

7. You have been hired to optimize a program operating on normal IEEE 754 floats so it will execute a little faster. Par t of the code looks like: float a[n];... float sum=0; float prod=1; int i; for (i=0; i<n; ++i) { sum = sum + a[i]; prod = prod * a[i]; } However, you happen to know that the particular processor it is running on has a special instruction that makes loops that count down faster than ones that count up. So, you rewr ite the code as: float a[n];... float sum=0; float prod=1; int i; for (i=n-1; i>=0; --i) { sum = sum + a[i]; prod = prod * a[i]; } The new code runs faster, but your boss has a problem with the new version. Assuming none of the float values go out of range, what s bother ing her? It doesn t get the same value for sum because the order of additions is changed. 8. For this question, mar k all that apply. Consider the figure shown at the end of this exam. Which of the following four control lines is a don t care while executing an xor instr uction? Branch must be 0 RegDst must be 1 ALUSrc must be 0 MemRead must be 0 MemToReg must be 0 None of these are don t cares! Page 4 of 7

9. For this question, mar k all that apply. Consider the figure shown at the end of this exam (the same one used in the previous question). For this single-cycle implementation, suppose we were to probe a few of the control signals and found that for a particular clock cycle, ALUSrc=0, MemtoReg=0, RegWrite=0, and MemRead=0. Which of the following MIPS instructions might have been executing? lw No: ALUSrc=1, MEMtoReg=1, RegWrite=1, MemRead=1 sw No: ALUSrc=1 beq Yes! add No: RegWrite=1 addi No: ALUSrc=1, RegWrite=1 10. For this question, mar k all that apply. Consider the figure shown at the end of this exam (the same one in the previous two questions). For this single-cycle implementation, which of the following control signals cannot have the same value for the ori, lw, and sw instr uctions? Branch None are branches ALUsrc ALUSrc=1 for all of these]fr RegDst RegDst=0 is needed by ori and lw, and sw doesn t care MemRead 1for lw, 0for ori and sw MemToReg 0for ori, 1 for lw, swdoesn t care Page 5 of 7

11. Assuming the following code is executed using 32-bit IEEE 754 floating-point, what does this code do? float f = 0; int i; for (i=0; i<1000000000; ++i) { ++f; } if (i == f) printf("yes!\n"); else printf("no!\n"); The for loop executes the body 1000000000 times. However, f stops incrementing at around 2ˆ24 -- when the value of f differs from 1 by more than we have bits in the mantissa. Thus, it prints "No!" and a newline. 12. Imagine a 32-by-32-bit hardware multiplier using Booth s algor ithm, as we discussed in class. Suppose we need to compute 63*63, 51*51, and 42*42. Which of these three multiplications would you expect would take the fewest clock cycles? Why? 63 is 111111 -- one subtract: (64<<6)-(64<<0) 51 is 110011 -- four add/subtract 42 is 101010 -- three adds 13. What is the effect of executing the MIPS subroutine f?.data x:.word 42.word 601.word 13.word 100.word 380.text f: la $t0, x lw $t1, 4($t0) addi $t1, $t1, 4 sw $t1, 0($t0) jr $ra It s essentially like: x[0] = x[1]+4; Which means it replaces 42 with 605. Page 6 of 7

14. Using only MIPS instructions listed on the last page of this exam, write assembly code to implement the following C code. Var iables should be placed in the registers with the same name, i.e., t0 is kept in the register named $t0; other t registers may beused as temporar ies. Comment any non-obvious things you do. t0 = t1 + (t2 & t3); and $tx,$t2,$t3 add $t0,$t1,$tx where $tx is any of$t0, $t4, $t5, etc. 15. Given the following logic array diagram, show the connections needed to make X = (A AND C) OR (B AND D) OR (NOT(A) AND NOT(B) AND NOT(C)) A B C D X Y Z Page 7 of 7

Reference Information Feel free to separate (and discard) this sheet from your exam. It is intended as a reference only. MIPS Instructions (a subset) add addu addi addiu and andi or ori sub subi xor xori lui slt beq bne j jal jr lw sw r1,immediate r1,r2,label r1,r2,label label label r1 r1,offset(r2) r1,offset(r2) Note that for this exam, you may use li and/or la even though they are not really instr uctions.

Single-Cycle Implementation Architecture EE380 Spring 2014 Exam 1 Answer Key