Midterm I March 1, 2001 CS152 Computer Architecture and Engineering

Similar documents
Midterm I October 6, 1999 CS152 Computer Architecture and Engineering

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

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

Midterm I March 12, 2003 CS152 Computer Architecture and Engineering

CPU Design Steps. EECC550 - Shaaban

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

Initial Representation Finite State Diagram Microprogram. Sequencing Control Explicit Next State Microprogram counter

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

Designing a Multicycle Processor

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

CS152 Computer Architecture and Engineering. Lecture 8 Multicycle Design and Microcode John Lazzaro (

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath

COMP303 Computer Architecture Lecture 9. Single Cycle Control

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

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

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

CS61C : Machine Structures

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

CpE 442. Designing a Multiple Cycle Controller

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

Major CPU Design Steps

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

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

Lecture #17: CPU Design II Control

T F The immediate field of branches is sign extended. T F The immediate field of and immediate (andi) and or immediate (ori) is zero extended.

CPU Organization (Design)

The Processor: Datapath & Control

CS152 Computer Architecture and Engineering Lecture 13: Microprogramming and Exceptions. Review of a Multiple Cycle Implementation

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

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

Ch 5: Designing a Single Cycle Datapath

Working on the Pipeline

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

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

UC Berkeley CS61C : Machine Structures

UC Berkeley CS61C : Machine Structures

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

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

CS61C : Machine Structures

CS61C : Machine Structures

MIPS-Lite Single-Cycle Control

Lecture 6 Datapath and Controller

Grading Results Total 100

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

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

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

ECE 361 Computer Architecture Lecture 11: Designing a Multiple Cycle Controller. Review of a Multiple Cycle Implementation

361 multipath..1. EECS 361 Computer Architecture Lecture 10: Designing a Multiple Cycle Processor

CS61C : Machine Structures

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

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

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

UC Berkeley CS61C : Machine Structures

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

CS 152 Computer Architecture and Engineering. Lecture 12: Multicycle Controller Design

Systems Architecture I

CENG 3420 Lecture 06: Datapath

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

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

Single Cycle CPU Design. Mehran Rezaei

Review: Abstract Implementation View

CC 311- Computer Architecture. The Processor - Control

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

Implementing the Control. Simple Questions

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

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

CPU Organization Datapath Design:

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

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

ENE 334 Microprocessors

The Processor: Datapath & Control

University of California, Berkeley College of Engineering Department of Electrical Engineering and Computer Science

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

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

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

CPU Organization Datapath Design:

ECE4680 Computer Organization and Architecture. Designing a Pipeline Processor

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

Topic #6. Processor Design

Multicycle Approach. Designing MIPS Processor

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

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

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

CS3350B Computer Architecture Quiz 3 March 15, 2018

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

Initial Representation Finite State Diagram. Logic Representation Logic Equations

CPU Organization Datapath Design:

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

ECE369. Chapter 5 ECE369

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

Hardwired Control Unit Ch 16

Processor (I) - datapath & control. Hwansoo Han

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

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

Lets Build a Processor

CPE 335. Basic MIPS Architecture Part II

ECE 30, Lab #8 Spring 2014

Transcription:

University of California, Berkeley College of Engineering Computer Science Division EECS Spring 200 John Kubiatowicz Midterm I March, 200 CS52 Computer Architecture and Engineering Your Name: SID Number: Discussion Section: Problem Possible Score 20 2 20 3 30 4 30 Total

[ This page left for π ] 3.459265358979384626433879502884976939937505820974944 2

Problem : Performance Problem a: Name the three principle components of runtime that we discussed in class. How do they combine to yield runtime? Now, you have analyzed a benchmark that runs on your company s processor. This processor runs at 300MHz and has the following characteristics: Instruction Type Frequency (%) Cycles Arithmetic and logical 35 Load and Store 25 2 Branches 25 3 Floating Point 5 5 Your company is considering a cheaper, lower-performance version of the processor. Their plan is to remove some of the floating-point hardware to reduce the die size. The wafer on which the chip is produced has a diameter of 0cm, a cost of $2000, and a defect rate of / (cm 2 ). The manufacturing process has an 80% wafer yield and a value of 2 for α. Here are some equations that you may find useful: Su wafer diameter/22 Su wafer diameter dies/wafer die area 2u die area D defects per unit area u die area die yield wafer yieldu D ¹ The current procesor has a die size of 2mm 2mm. The new chip has a die size of 0mm 0mm, and floating point instructions will take 3 cycles to execute. Problem b: What is the CPI and MIPS rating of the original processor? 3

Problem c: What is the CPI and MIPS rating of the new processor? Problem d: What is the original cost per (working) processor? Problem e: What is the new cost per (working) processor? Problem f: Assume that we are considering the other direction of improving the original processor by increasing the speed of floating point. What is the best possible speedup that we could get, and what would the CPI and MIPS rating be of the new processor? 4

Problem 2: Parallel Prefix Assume the following characteristics for NAND gates: Input load: 20fF, Internal delay: TPlh=0.3ns, TPhl=0.6ns, Load-Dependent delay: TPlhf=.0020ns, TPhlf=.002ns Problem 2a: Suppose that we construct an XOR, as follows: A B Y Compute the standard parameters for the linear delay models for this complex gate, assuming the parameters given above for the NAND gate. Assume that a wire doubles the input capacitance of the gate that it is attached to: A Input Capacitance: B Input Capacitance: Load-dependent Delays: TPAYlhf: TPAYhlf: TPBYlhf: TPBYhlf: Maximum Internal delays for A Y: TPAYlh: TPAYhl: 5

An important operation that shows up in many different contexts is the parallel prefix circuit using XOR as the combining operation. This circuit takes as input a sequence of bits, such as: [ I 0, I, I 2, I 3, ] then outputs a new sequence, [O 0, O, O 2, O 3, ] which is the same length. The output bits are related to the input bits in the following fashion: [ O 0 =I 0, O =(I 0 I ), O 2 =(I 0 I I 2 ), O 3 =(I 0 I I 2 I 3 ), ] Each successive output bit is the XOR of the new input bit and the previous output bit. O O 0 The smallest parallel-prefix circuit has 2 inputs and two outputs. If this is intended to be part of a larger parallel prefix circuit, then we need carry in and carry out terminals such as shown to the right: C up C down Problem 2b: Using your answers from problem (2a), compute: Input capacitance: I 0 : I : C down: I I 0 Load Dependent Delays for both outputs: (as many parameters as appropriate): Internal delays for the critical path (identify the critical path and compute delays):. 6

Problem 2c: Now, put these 2-input blocks together to produce a 4-input block that takes I 0, I, I 2, and I 3, and C down and produces: O 0 = I 0 C down O = I I 0 C down O 2 = I 2 I I 0 C down O 3 = I 3 I 2 I I 0 C down C up = I 3 I 2 I I 0 Your goal is to minimize the output delay of each block. Compute the input capacitance for each input: Identify the critical path of your circuit and compute the unloaded delay for this path. 7

Problem 2d: Finally, show how the 4 input prefix circuit can be used as a building block to produce a 6- element prefix circuit that minimizes gate reuse and which has minimal delay. What is the critical path and how many XOR gates are in it? Hint: this is very similar to a carry-lookahead adder. Problem 2e: How many XOR gates are in the critical path of a 64-bit parallel-prefix circuit? 8

Problem 3: PI This problem is not as bad as it looks. 3a and 3b can be done without understanding the math. The book A History of π by Petr Beckmann is an amusing look at the history and politics behind the number PI. Among other things, this book shows several series that produce PI. One in particular is: π 4 4uarctan 5 arctan In this problem, we will compute part of this series: 239 arctan 5 7 x x 3 x 5 x 7 x 3 Fortunately for us, each term of the series is smaller that the previous one by at least 2 x. So, 2 this means that each term of arctan is smaller by at least 0. 04 and each term of 5 ¹ 5 ¹ 2 arctan is smaller by 5.8u0. Thus, the series converges really quickly. 239 ¹ 239 ¹ The secret to making this work is to note that each term in the series for PI is of the form /big number. Further, a lot of these numbers are related to each other. Consider: A0 x A0 B 0 x A0 A A B 3 2 3 x x 3 x 3 A A A 2 B 5 2 2 5 x x 5 x 5 arctan 2 x So, B B B... 0 Thus, all we need to do is figure out how to divide one number by another number for an arbitrary number of decimal places. Suppose that we have a procedure that produces an infinite stream of digits for the series A 0. Then, we can input that stream as an input to the divide algorithm that produces A (since it is A 0 divided by some integer like 25 or (239) 2. Further, we can send the stream of digits for A to produce A 2 and B. Etc. That is our trick.... 9

Recall how divide (in base 0) works The following shows a division of by 23: Suppose we had a procedure that produced each of the digits (zeros) in the dividend, one at a time. Consider the remainders as integers from the current decimal point. So, for instance, we have the remainders, 0, 00, 80, 0, 80, etc. At each stage, we multiply by ten, add the incoming digit (zero in the example), then This could be combined with the current remainder but multiplying the remainder by 0, adding the new digit (which is zero in this case), then seeing how much the result divides the answer. 23 0.04347826.00000000 0.0 0.0.00 0.92 0.080 0.069 0.00 0.0092 Remainders 0.0080 Here is complete pseudo code for computing one of the streams: 0.006 Stream(digitnum,incoming,oddnum,sign,xsquared,termID,maxtermID) { ARemainder = A_REMARRAY[termID]; ARemainder = ARemainder 0 + incoming; ; This is a quotient/remainder operation (ADigit, ARemainder) = ARemainder / xsquared; A_REMARRAY[termID] = ARemainder; BRemainder = B_REMARRAY[termID]; BRemainder = BRemainder 0 + Adigit; (BDigit, BRemainder) = BRemainder / oddnum; B_REMARRAY[termID] = BRemainder; AddInDigit(BDigit, digitnum, sign); If ((termid = maxtermid ) && (ADigit!= 0)) { A_REMARRAY[termID+] = 0; maxtermid++; } } If (termid < maxtermid) { Stream(digitnum, ADigit,(oddnum+2),-sign, xsquared, (termid+), maxtermid); } 0

Problem 3a: Write MIPS assembly for this pseudo code. Make sure to adhere to MIPS conventions. Assume that A_REMARRAY[] and B_REMARRAY[] are word arrays that are addressed via constants (assume that you can use the la pseudo instruction to load their addresses into registers. Also, assume that there are 7 argument registers ($a0 - $a6) for the sake of this problem. Note that AddInDigit is a procedure call.

Problem 3b: The procedure AddInDigit takes 3 arguments. A digit (a number from 0 to 9), a digit position (digitnum), and a sign. Assume that we have an infinite precision decimal number in memory, one digit per byte, starting at address FINALVALUE. Assume that digitnum specifies a byte offset from this address at which we need to add (sign =) or subtract (sign=-) the incoming digit. Write this procedure. Assume that the result must be still in decimal. Thus, if you add the digit at FINALVALUE[digitnum] and it overflows (is bigger than 9), then you must carry to the next most significant digit (at digitnum-). Same is true of subtract (when sign = -). 2

Problem 3c: Explain the initialization of the A_REMVALUE[] and B_REMVALUE[] arrays if we were going to compute 4 arctan. What is the purpose of the termid and maxtermid 5 ¹ parameters? Problem 3d: Explain the initialization of the FINALVALUE array: Problem 3e: Write pseudo-code to compute 4 arctan using stream(). Assume that the initialization in 5 ¹ (3c) and (3d) are accomplished.. 3

[ This page intentionally left blank] 4

Problem 4: New instructions for a multi-cycle data path PCWr PC PCWrCond Zero IorD MemWr 0 Mux RAdr Ideal Memory WrAdr Din Dout IRWr Instruction Reg Mem Data Reg RegDst Rs Rt Rt 0 Mux Rd 5 5 Mux 0 RegWr Ra Rb busa A Reg File Rw busw busb B << 2 ALUSelA 4 PCSrc 0 Mux 0 2 3 Mux 0 Zero ALU ALU Control ALU Out Imm 6 ExtOp Extend MemtoReg ALUOp The Multi-Cycle datapath developed in class and the book is shown above. In class, we developed an assembly language for microcode. It is included here for reference: Field Name Values For Field Function of Field Add ALU Adds ALU Sub ALU subtracts Func ALU does function code (Inst[5:0]) Or ALU does logical OR SRC PC PC st ALU input rs R[rs] st ALU input 4 4 2 nd ALU input rt R[rt] 2 nd ALU input SRC2 Extend sign ext imm6 (Inst[5:0]) 2 nd ALU input Extend0 zero ext imm6 (Inst[5:0]) 2 nd ALU input ExtShft 2 nd ALU input = sign extended imm6 << 2 rd-alu ALUout R[rd] ALU Dest rt-alu ALUout R[rt] rt-mem Mem input R[rt] Read-PC Read Memory using the PC for the address Memory Read-ALU Read Memory using the ALUout register for the address Write-ALU Write Memory using the ALUout register for the address MemReg IR Mem input IR PC Write ALU ALU value PCibm ALUoutCond If ALU Zero is true, then ALUout PC Seq Go to next sequential microinstruction Sequence Fetch Go to the first microinstruction Dispatch Dispatch using ROM ALUSelB 5

In class, we made our multicycle machine support the following six MIPS instructions: op rs rt rd shamt funct = MEM[PC] op rs rt Imm6 = MEM[PC] 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 + 4 + sign_ext(imm6) 00 else PC PC + 4 For your reference, here is the microcode for two of the 6 MIPS instructions: Label ALU SRC SRC2 ALUDest Memory MemReg PCWrite Sequence Fetch Add PC 4 ReadPC IR ALU Seq Dispatch Add PC ExtShft Dispatch RType Func rs rt Seq rd-alu Fetch BEQ Sub rs rt ALUoutCond Fetch In this problem, we are going to add four new instructions to this data path: jal <const> PC zero_ext(instr[25:0]) 00 R[3] PC + 4 add $rd, $rs, $rt if (R[rs]+ R[rt] doesn t overflow) then R[rd] R[rs] + R[rt] PC PC+4 Else EPC PC Cause 2 PC 0x80000080 mfc0 $rd, $rt if ($rt == 3) then R[rd] Cause Else if ($rt == 4) then R[rd] EPC PC PC+4 compmul $rd, $rs, $rt R[rd]=(R[rs] R[rt]) (R[rs+] R[rt+]) R[rd+]= (R[rs] R[rt])+(R[rs+] R[rt+]) PC PC+4 This math was a typo. The real way to compute complex multiply is: compmul $rd, $rs, $rt R[rd]=(R[rs] R[rt]) (R[rs+] R[rt+]) R[rd+]= (R[rs] R[rt+])+(R[rs+] R[rt]) PC PC+4 6

. The jal instruction is familiar to you from the normal MIPS instruction set. 2. The add instruction is a normal add except that it causes an overflow exception if there is overflow. You need to implement the EPC (error PC) and Cause registers. Just assume that EPC gets the PC of the bad instruction and Cause gets the number 2. 3. The mfc0 instruction is used to get the EPC and Cause values into normal registers 4. The compmul instruction does a complex multiply. It is assumed that the registers rd, rs, and rt are even registers and that the two source complex values are in R[rs], R[rs+] (real, imaginary) and R[rt], R[rt+] (real, imaginary), and that the results are put into R[rd] and R[rd+] (real,imaginary). Problem 4a: How wide are microinstructions in the original datapath (answer in bits and show some work!)? Problem 4b: Draw a block diagram of a microcontroller that will support the new instructions (it will be slightly different than that required for the original instructions). Include sequencing hardware, the dispatch ROM, the microcode ROM, and decode blocks to turn the fields of the microcode into control signals. Make sure to show all of the control signals coming from somewhere. (hint: The PCWr, PCWrCond, and PCSrc signals must come out of a block connected to thepcwrite field of the microinstruction). 7

Problem 4c: Describe/sketch the modifications needed to the datapath for the new instructions (jal, add, mfc0, and compmul). Asume that the original datapath had only enough functionality to implement the original 6 instructions. Try to add as little additional hardware as possible. Make sure that you are very clear about your changes. 8

Problem 4d: Describe changes to the microinstruction assembly language for these new instructions. How wide are your microinstructions now? Problem 4e: Write complete microcode for the new instructions. Include the Fetch and Dispatch microinstructions. If any of the microcode for the original instructions must change, explain how (Hint: since the original instructions did not use R[rd] as a register input, you must make sure that your changes do not mess up the original instructions). 9