CS3350B Computer Architecture Quiz 3 March 15, 2018

Similar documents
CS 351 Exam 2 Mon. 11/2/2015

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

Single Cycle CPU Design. Mehran Rezaei

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

Working on the Pipeline

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

CENG 3420 Lecture 06: Datapath

CS 110 Computer Architecture Single-Cycle CPU Datapath & Control

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

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

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

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

Lecture 7 Pipelining. Peng Liu.

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

Lecture #17: CPU Design II Control

MIPS-Lite Single-Cycle Control

The Processor: Datapath & Control

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

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

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

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

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

CS61C : Machine Structures

Processor (I) - datapath & control. Hwansoo Han

COMP303 Computer Architecture Lecture 9. Single Cycle Control

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

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

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

CSEN 601: Computer System Architecture Summer 2014

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath


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

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

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

CPU Organization (Design)

Computer Organization and Structure

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

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

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

LECTURE 5. Single-Cycle Datapath and Control

The MIPS Processor Datapath

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

Lecture 10: Simple Data Path

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

CSE 378 Midterm 2/12/10 Sample Solution

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

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

Pipeline design. Mehran Rezaei

UC Berkeley CS61C : Machine Structures

Laboratory Exercise 6 Pipelined Processors 0.0

Major CPU Design Steps

ECE232: Hardware Organization and Design

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

UC Berkeley CS61C : Machine Structures

Laboratory 5 Processor Datapath

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

Systems Architecture

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

CS 351 Exam 2, Fall 2012

Chapter 4. The Processor

Computer Architecture I Midterm I (solutions)

CPE 335 Computer Organization. Basic MIPS Architecture Part I

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

CS Computer Architecture Spring Week 10: Chapter

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Computer Hardware Engineering

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

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

Final Exam Spring 2017

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

ECE468 Computer Organization and Architecture. Designing a Single Cycle Datapath

CS61C : Machine Structures

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 4. The Processor

CS61C : Machine Structures

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

Lecture 6 Datapath and Controller

Static, multiple-issue (superscaler) pipelines

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

Chapter 4. The Processor

COMP2611: Computer Organization. The Pipelined Processor

CPU Design Steps. EECC550 - Shaaban

NATIONAL UNIVERSITY OF SINGAPORE

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

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

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

Designing a Multicycle Processor

Midterm I March 3, 1999 CS152 Computer Architecture and Engineering

Review: Abstract Implementation View

COMPUTER ORGANIZATION AND DESIGN

Grading Results Total 100

Processor Design Pipelined Processor (II) Hung-Wei Tseng

Mark Redekopp and Gandhi Puvvada, All rights reserved. EE 357 Unit 15. Single-Cycle CPU Datapath and Control

CS3350B Computer Architecture Winter 2015

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

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

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

Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

Transcription:

CS3350B Computer Architecture Quiz 3 March 15, 2018 Student ID number: Student Last Name: Question 1.1 1.2 1.3 2.1 2.2 2.3 Total Marks The quiz consists of two exercises. The expected duration is 30 minutes. All answers should be written in the answer boxes. MIPS Cheat Sheet Instruction Example Translation in C load word lw $s0, 4($s1) $s0 = Memory($s1+4) store word sw $s0, 4($s1) Memory($s1+4) = $s0 add add $s0, $s1, $s2 $s0 = $s1 + $s2 subtract sub $s0, $s1, $s2 $s0 = $s1 - $s2 add immediate addi $s0, $s1, 2 $s0 = $s1 + 2 subtract immediate subi $s0, $s1, 2 $s0 = $s1-2 shift left sll $s0, $s1, 2 $s0 = $s1 2 bits shift right srl $t2, $t2, 1 $t2 = $t2 / 2 branch on equal beq $s0, $s1, L if ($s0 == $s1) go to L branch on not equal bne $s0, $s1, L if ($s0!= $s1) go to L set on less than slt $s0, $s1, $s2 if ($s1 < $s2) $s0 = 1 else $s0 = 0 jump j L go to L jump register jr $s0 go to $s0 jump and link ja 250 go to 1000; $ra=pc+4 func 10 0000 10 0010 We don t care :-) op 00 0000 00 0000 00 1101 10 0011 10 1011 00 0100 00 0010 add sub ori lw sw beq jump RegDst 1 1 0 0 x x x ALUSrc 0 0 1 1 1 0 x MemtoReg 0 0 0 1 x x x RegWrite 1 1 1 1 0 0 0 MemWrite 0 0 0 0 1 0 0 npc sel 0 0 0 0 0 1? Jump 0 0 0 0 0 0 1 ExtOp x x 0 1 1 x x ALUctr<2:0> Add Subtract Or Add Add Equal x R-format op rs rt rd shamt funct add, sub I-format op rs rt immediate ori, lw, sw, beq J-format op target address jump Table 1: Control signals for some core MIPS instructions There are 3 types of pipeline hazards: 1

Structural hazards: Attempt to use the same resource by two different instructions at the same time Data hazards: Attempt to use data before it is ready in instructions involving arithmetic and data transfers. An instruction s source operand(s) are produced by a prior instruction still in the pipeline Control hazards: Attempt to make a decision about program control flow before the condition has been evaluated and the new PC target address calculated; branch instructions A first example of data hazard: Note: ALU-ALU forwarding is used. A second example of data hazard: Note: MEM-ALU forwarding is used. Exercise 1. [40 points] Consider the datapath shown in Figure 1. In this question, we study the following MIPS instruction: slti rt, rs, 17 # if (Reg[rs] < 17) Reg[rt] = 1 # else Reg[rt] = 0 2

Figure 1: The basic implementation of the datapath and control for a MIPS instruction. 1.1 Describe the five stages of the datapath for this instruction slti. Stage 1: fetch this instruction [1], increment PC [1] Stage 2: decode to determine it is an slti [1], then read register rs [1] Stage 3: compare value retrieved in Stage 2 with the integer 17 [2] Stage 4 Memory: idle Stage 5: write the result of Stage 3 (1 if rs < 17, 0 otherwise) into register rt [2] 3

1.2 Which blocks (PC, PC Ext, Adder by 4, Adder by PC Ext, Inst Memory, RegFile, Extender, ALU, Data Memory) in Figure 1 perform a useful function for this instruction slti? PC, Adder by 4, Inst Memory, RegFile, Extender, ALU 1.3 What are the values of the control signals generated by the controller in Figure 1 for this instruction slti? npc sel = 0 or +4 [2] RegDst = 0 or Rt [2] RegWr = 1 [2] ExtOp = 1 or signed [2] ALUsrc = 1 or imm [2] ALUctr = < [2] MemWr = 0 [2] MemtoReg = 0 or ALU [2] Exercise 2. [60 points] We would like to execute the following MIPS code on a 5-stage pipelined processor. The successive five stages of this pipeline are denoted by IF, DEC, EXE, MEM, WB. loop: lw $t0, 0($s1) # $t0=array element addu $t0, $t0, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result addi $s1, $s1, -4 # decrement pointer bne $s1, $0, loop # branch if $s1!= 0 where $s1 stores a base memory address of a 32-bit integer array with size of 9, and $s2 stores a number added to each element of the array. Note that forwarding and instruction re-ordering can be used to resolve data hazards and control hazards. 2.1 For the first iteration on a single pipelined processor, draw the pipeline execution diagram, such that the minimum amount of stalls is inserted in the pipelined execution. Also indicates what type of forwarding (ALU-ALU, ALU-MEM, MEM-ALU, MEM-MEM) it is if forwarding is used. 4

Clock Instructions 1 2 3 4 5 6 lw $t0, 0($s1) IF DEC EXE MEM (1) WB addi $s1, $s1, -4 IF DEC EXE (2) MEM WB Clock Instructions 3 4 5 6 7 8 9 addu $t0, $t0, $s2 IF DEC EXE (3) MEM WB sw $t0, 4($s1) IF DEC EXE MEM WB bne $s1, $0, loop IF DEC EXE MEM WB The sequence is right [4] and 9 clock cycles in total are used [2]. (1) MEM-ALU forwarding [2] (2) ALU-ALU forwarding (It is not necessary) (3) ALU-MEM forwarding [2] 2.2 Apply loop unrolling for 3 times and write down your MIPS code. 5

loop: lw $t0, 0($s1) # $t0=array element lw $t1, -4($s1) [1] # $t1=array element lw $t2, -8($s1) [1] # $t2=array element addu $t0, $t0, $s2 # add scalar in $s2 addu $t1, $t1, $s2 # add scalar in $s2 addu $t2, $t2, $s2 # add scalar in $s2 sw $t0, 0($s1) # store result sw $t1, -4($s1) [1] # store result sw $t2, -8($s1) [1] # store result addi $s1, $s1, -12 [1] # decrement pointer bne $s1, $0, loop # branch if $s1!= 0 2.3 Now we would like to schedule your loop unrolled MIPS code on a two-issue, 5-stage pipelined processor with the following constraints: the first issue deals only with ALU or branch instructions, the second issue deals only with data transfer (loads and stored), we wish to avoid pipeline stalls. Propose a schedule for the first iteration so as to achieve a high IPC (instructions per cycles). 6

ALU or branch Data transfer Clock Cycle loop: addi [1] lw [1] 1 nop [1] lw [1] 2 addu [1] lw 3 addu [1] sw [1] 4 addu sw [1] 5 bne [1] sw [1] 6 7 8 9 10 7