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

Similar documents
361 datapath.1. Computer Architecture EECS 361 Lecture 8: Designing a Single Cycle Datapath

COMP303 - Computer Architecture Lecture 8. Designing a Single Cycle Datapath

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

CS61C : Machine Structures

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

CS3350B Computer Architecture Winter Lecture 5.7: Single-Cycle CPU: Datapath Control (Part 2)

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

The Big Picture: Where are We Now? EEM 486: Computer Architecture. Lecture 3. Designing a Single Cycle Datapath

CS 61C: Great Ideas in Computer Architecture Datapath. Instructors: John Wawrzynek & Vladimir Stojanovic

Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

Lecture #17: CPU Design II Control

COMP303 Computer Architecture Lecture 9. Single Cycle Control

CS3350B Computer Architecture Quiz 3 March 15, 2018

Outline. EEL-4713 Computer Architecture Designing a Single Cycle Datapath

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

361 control.1. EECS 361 Computer Architecture Lecture 9: Designing Single Cycle Control

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

MIPS-Lite Single-Cycle Control

CPU Organization (Design)

CS61C : Machine Structures

CPU Design Steps. EECC550 - Shaaban

CS61C : Machine Structures

The Processor: Datapath & Control

UC Berkeley CS61C : Machine Structures

Working on the Pipeline

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

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath & Control Part 2

CS 61C: Great Ideas in Computer Architecture Control and Pipelining

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Lecture 28: Single- Cycle CPU Datapath Control Part 1

UC Berkeley CS61C : Machine Structures

Full Datapath. CSCI 402: Computer Architectures. The Processor (2) 3/21/19. Fengguang Song Department of Computer & Information Science IUPUI

Review. N-bit adder-subtractor done using N 1- bit adders with XOR gates on input. Lecture #19 Designing a Single-Cycle CPU

Ch 5: Designing a Single Cycle Datapath

UC Berkeley CS61C : Machine Structures

Single Cycle CPU Design. Mehran Rezaei

Major CPU Design Steps

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

Midterm I March 1, 2001 CS152 Computer Architecture and Engineering

Designing a Multicycle Processor

How to design a controller to produce signals to control the datapath

ECE170 Computer Architecture. Single Cycle Control. Review: 3b: Add & Subtract. Review: 3e: Store Operations. Review: 3d: Load Operations

CSCI 402: Computer Architectures. Fengguang Song Department of Computer & Information Science IUPUI. Today s Content

Lecture 6 Datapath and Controller

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 18 CPU Design: The Single-Cycle I ! Nasty new windows vulnerability!

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

EEM 486: Computer Architecture. Lecture 3. Designing Single Cycle Control

CS359: Computer Architecture. The Processor (A) Yanyan Shen Department of Computer Science and Engineering

CPSC614: Computer Architecture

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

CS61C : Machine Structures

CS 61C: Great Ideas in Computer Architecture Lecture 12: Single- Cycle CPU, Datapath & Control Part 2

Midterm I SOLUTIONS October 6, 1999 CS152 Computer Architecture and Engineering

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Single- Cycle CPU Datapath Control Part 1

CS 351 Exam 2 Mon. 11/2/2015

CS152 Computer Architecture and Engineering Lecture 10: Designing a Single Cycle Control. Recap: The MIPS Instruction Formats

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Instructor: Randy H. Katz hcp://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #18. Warehouse Scale Computer

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

EECS150 - Digital Design Lecture 10- CPU Microarchitecture. Processor Microarchitecture Introduction

CS 152 Computer Architecture and Engineering. Lecture 10: Designing a Multicycle Processor

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

Processor. Han Wang CS3410, Spring 2012 Computer Science Cornell University. See P&H Chapter , 4.1 4

The MIPS Instruction Set Architecture

Guerrilla Session 3: MIPS CPU

Adding Support for jal to Single Cycle Datapath (For More Practice Exercise 5.20)

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

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

Computer Architecture. The Language of the Machine

Review: Organization. CS152 Computer Architecture and Engineering Lecture 2. Review of MIPS ISA and Design Concepts

Lecture 7 Pipelining. Peng Liu.

CENG 3420 Lecture 06: Datapath

EECS150 - Digital Design Lecture 9- CPU Microarchitecture. Watson: Jeopardy-playing Computer

CS 4200/5200 Computer Architecture I

Final Exam Spring 2017

Processor (I) - datapath & control. Hwansoo Han

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

CS 61c: Great Ideas in Computer Architecture

CPU Organization Datapath Design:

inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 19 CPU Design: The Single-Cycle II & Control !

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

Midterm. Sticker winners: if you got >= 50 / 67

Recap: A Single Cycle Datapath. CS 152 Computer Architecture and Engineering Lecture 8. Single-Cycle (Con t) Designing a Multicycle Processor

Midterm Questions Overview

CSE 378 Midterm 2/12/10 Sample Solution

Computer Science 61C Spring Friedland and Weaver. The MIPS Datapath

Reduced Instruction Set Computer (RISC)

CSE 141 Computer Architecture Summer Session I, Lecture 3 Performance and Single Cycle CPU Part 1. Pramod V. Argade

Computer Architecture I Midterm I (solutions)

Anne Bracy CS 3410 Computer Science Cornell University. See P&H Chapter: , , Appendix B

EECS 151/251A Fall 2017 Digital Design and Integrated Circuits. Instructor: John Wawrzynek and Nicholas Weaver. Lecture 13 EE141

COMP303 - Computer Architecture Lecture 10. Multi-Cycle Design & Exceptions

Anne Bracy CS 3410 Computer Science Cornell University. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

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

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

CS61c Final Review Fall Andy Carle 12/12/2004

M2 Instruction Set Architecture

Midterm Questions Overview

Transcription:

Name: University of California College of Engineering Computer Science Division -EECS Fall 996 D.E. Culler CS 52 Midterm I Your Name: ID Number: Discussion Section: You may bring one double-sided pages of notes and you may use a calculator, but no book or computer. Please print your name clearly on the cover sheet and on every page. Show your work. Write neatly and be well organized. It never hurts to make it easy to grade. Good luck. Problem Possible Score 25 2 2 3 25 4 2 5 Total Mean: 69, Max 97 Distribution: - 85 (), 84-7 (2), 69-55 (24), 54-4 (7), 39 - (2)

Name: 2 Problem (25 points) a [5] State the five major components of a computer (according to Patterson and Hennessey).. Processor datapath 2. Processor Control 3. 4. Input 5. Output b [5 ]: Assemble the following MIPS instruction into its binary machine representation XORI $5, $, x8 answer: op(6) rsrtimmediate c [5 ]: Decode your answer to b as a -bit 2 s-complement integer a) 2 29 + 2 28 + 2 27 + 2 2 b) 2 3 2 27 + 3 2 5 c) 7 2 27 3 2 2 d) answer: b) + 4 2 27 + 3 2 5 d [5 ]: Decode your answer to b as an single precision IEEE floating-point number a) 2 7 -------- b) 2 5 -------- c) 2 5 -------- d) 3 256 3 256 287 2 256 2 287 -------- 256 answer: c) Grading: a) point for each component; b) point for each field; c), d) hit or miss for multiple choice.

Name: 3 e[5] What are the four basic addressing modes supported by the MIPS R3 instruction set? Draw a diagram of each. (Do not include the special cases that arise from setting one of the operands to zero.) register-addressing: value is contained in a register specified in the instruction Register base (or displacement) addressing immediate Register immediate addressing: value is contained in the instruction immediate PC-relative addressing: PC <- PC + sign_ext(imm6) address PC Points: for each type. -2 for lack of diagrams, or lack of description. Other addressing modes were also given credit, if labeled correctly.

Name: 4 Problem 2 (2 points). You have been running an important program over and over on a 33 MHz DEC 5 and you decide that you want to understand its performance. So you run it on a detailed simulator and collect the following instruction mix and breakdown of costs for each instruction type. Instruction Class Frequence (%) Cycles Arithmetic / logical 5 Load 2 2 Store 2 Jump Branch 3 2.a. Calculate the CPI and MIPS for this program. answer: CPI =.5 =.5 x +.2 x 2 +. x 2 +. + +. x 3, 22 MIPS Points: +6 for correct answer 2.b. Suppose you turn on the optimizer and it eliminates 2% of the arithmetic/logic instructions (i.e. % of the instructions overall), but does not affect the other instruction classes. What is the speedup on this program with the optimizer. (Be sure you state and use the correct definition of speedup and show your work.) a).93 b).7 c).4 d).55 e) none of these Answer: cycles per equivalent of average old instruction =.4 =.4 x +.2 x 2 +. x 2 +. + +. x 3. speedup =.5 /.4 =.5 Points: + 6 for correct answer 2c. Calculate the CPI and MIPS for the optimized version of this program. Show your work. Compare your result to that of 2a and explain the change. Answer CPI =.55, 2.2 MIPS. The program spends more of its time executing slow instruction, although there are fewer instructions overall. Points: +8 for correct answer

Name: 5 Problem 3. (25 points) Complete the skeleton of MIPS assembly language below, generated by GCC for the following C function. All jumps and branches are delayed. Simple pseudo-ops are used to make it more readable. Annotate the instructions to explain what they do in the C program. int scale (int *A, int n, int x) Register Usage { $4 - *A int i; $5 - n for (i=; i<n; i++) { $6 - x A[i] = A[i]*x; } }.ent scale scale: subu $sp,$sp,8 Adjust Stack pointer blez $5,$L3 test n =, if so fall through move $7,$ i = $L5: sll $3,$7,2 multiple i by 2 addu $3,$3,$4 address of A[i] lw $2,($3) fetcha[i] #nop mult $6,$2 A[i]*x mflo $8 extract low bits #nop addu $7,$7, increment i slt $2,$7,$5 test i<n bne $2,$,$L5 if i<n go to top of loop sw $8,($3) store A[i] <- A[i]*x $L3: addu $sp,$sp,8 restore stack j $3 return #nop.end scale Points: 3 points for Register Usage; 8 points for instruction fill-ins; 4 points for explanation on left side

Name: 6 Problem 4 (2 points): The Single-Cycle processor developed in class below (which was very similar to the one in the book) supports the instructions in the table below. (Note that, as in the virtual machine, the branch is not delayed.) Inst Adr <:5> <:5> <6:2> <2:25> Rt Rs Rd Imm6 Instruction<3:> imm6 4 PC Ext Adder Adder npc_sel PC RegDst Rd Rt Equal RegWr Rs Rt 5 5 5 = busw busa Rw Ra Rb -bit Registers busb imm6 6 Extender ALUctr 3 Data In ALU MemWr WrEn Adr Data MemtoReg ExtOp ALUSrc op rs rt rd shamt funct = MEM[ PC ] op rs rt Imm6 = inst Register Transfers ADDU R[rd] < R[rs] + R[rt]; PC < PC + 4 SUBU R[rd] < R[rs] R[rt]; PC < PC + 4 ORi R[rt] < R[rs] + zero_ext(imm6); PC < PC + 4 LW R[rt] < MEM[ R[rs] + sign_ext(imm6)]; PC < PC + 4 SW MEM[ R[rs] + sign_ext(imm6)] < R[rs]; PC < PC + 4 BEQ if ( R[rs] == R[rt] ) then PC < PC + sign_ext(imm6)] else PC < PC + 4 Consider adding the following instructions to our subset: ADDIU, AND, BLTZ, JAL. On the following pages, () write the register transfers for the new instructions, (2) modify the datapath to support these instructions and (3) specify the control points for each of the new instructions.

Name: 7 op rs rt rd shamt funct = MEM[ PC ] op rs rt Imm6 = inst Register Transfers ADDIU R[rt] < R[rs] + SignExt(Imm6) PC < PC + 4 AND R[rd] < R[rs] and R[rt]; PC < PC + 4 BLTZ if R[rs] 3 = then PC < PC + SignExt(Imm6) else PC < PC + 4 JAL R[3] < PC + 4 PC < PC 3..28 Imm26 No changes to the datapath are required the the three arithmetic/logical instructions, except the ALU needs to support AND. There is already the capability to sign extend immediates and to operate on pairs of registers. To support the BLTZ we need to: detect R[rs] <, this is just the sign bit of bus_a To support JAL, we need to: provide a path from the PC+4 adder onto the register input bus (bus_w) provide 3 as the destination register number. Im26 4 PC Ext Adder Adder Inst Adr Rs Rt Rd Imm6 3 npc_sel RegDst Rd Rt Equal 2 2 2 Rs Rt RegWr 5 5 5 = busw busa Rw Ra Rb -bit Registers busb pc2reg PC imm6 <2:25> 6 <6:2> <:5> Extender ExtOp <:5> LT ALUSrc Instruction<3:> ALUctr ALU MemWr WrEn Adr Data In Data MemtoReg

Name: 8 Problem 4 (cont) TABLE. Ext ALUsrc ALUCtr MemWr Mem2Reg PC2Reg RegDst RegWr npc ADDIU sign add AND x AND BLTZ x x x x x x lt JAL x x x x 2 2 Points: 8 points for register transfers; 8 points for alterations to datapath; 4 points for control signals

Name: 9 Problem 5 ( points) Write a series of instructions to MIPS instructions to perform a signed 64-bit SLT. The operands are passed in registers A:A and A3:A2 with the MSW in the higher numbered register. The result should be returned in register t with the same convention. Explain why your code works. /* t = a:a <? a3:a2 */ BNE a, a3, L: slt t, a, a3 sltu v, a, a2 L: Points: +5 for sltu for least significant word; +5 for understanding when to use sltu comparator on least significant word (when $a = $a3). No points were taken off if you did not use the delay slots efficiently.