Binvert Operation (add, and, or) M U X

Similar documents
Faculty of Science FINAL EXAMINATION

Merging datapaths: (add,lw, sw)

Data paths for MIPS instructions

CS3350B Computer Architecture Quiz 3 March 15, 2018

CS 351 Exam 2 Mon. 11/2/2015

CS 251, Winter 2019, Assignment % of course mark

Assignment 1 solutions

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

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

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

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


CS 251, Winter 2018, Assignment % of course mark

Review: Abstract Implementation View

The MIPS Processor Datapath

LECTURE 5. Single-Cycle Datapath and Control

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

CS 230 Practice Final Exam & Actual Take-home Question. Part I: Assembly and Machine Languages (22 pts)

Chapter 5 Solutions: For More Practice

CS 61C: Great Ideas in Computer Architecture. Lecture 11: Datapath. Bernhard Boser & Randy Katz

Chapter 2: Instructions:

Chapter 4. The Processor

Computer System Architecture Midterm Examination Spring 2002

Lecture 8: Data Hazard and Resolution. James C. Hoe Department of ECE Carnegie Mellon University

Review of the Machine Cycle

University of Jordan Computer Engineering Department CPE439: Computer Design Lab

Chapter 4. The Processor

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

CENG 3420 Lecture 06: Datapath

CSE 378 Midterm Sample Solution 2/11/11

CS3350B Computer Architecture

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

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

LECTURE 9. Pipeline Hazards

CSEN 601: Computer System Architecture Summer 2014

CS222: MIPS Instruction Set

CS2100 Computer Organisation Tutorial #10: Pipelining Answers to Selected Questions

EC 413 Computer Organization - Fall 2017 Problem Set 3 Problem Set 3 Solution

Chapter 4 The Processor

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

MIPS Coding Continued

CS Computer Architecture Spring Week 10: Chapter

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

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Programming the processor

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

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

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

CPE 335 Computer Organization. Basic MIPS Architecture Part I

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

Instruction word R0 R1 R2 R3 R4 R5 R6 R8 R12 R31

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

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

Processor (I) - datapath & control. Hwansoo Han

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

ECE 3056: Architecture, Concurrency, and Energy of Computation. Sample Problem Sets: Pipelining

Chapter 4. The Processor

Chapter 4 The Processor 1. Chapter 4B. The Processor

Lecture 10: Simple Data Path

CS3350B Computer Architecture Winter 2015

MIPS PROJECT INSTRUCTION SET and FORMAT

Chapter 3 Arithmetic for Computers

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

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

Systems Architecture

CSE140: Components and Design Techniques for Digital Systems

Lecture 9: Disassembly

Introduction. Datapath Basics

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

CS3350B Computer Architecture MIPS Introduction

Pipelining. lecture 15. MIPS data path and control 3. Five stages of a MIPS (CPU) instruction. - factory assembly line (Henry Ford years ago)

Perfect Student CS 343 Final Exam May 19, 2011 Student ID: 9999 Exam ID: 9636 Instructions Use pencil, if you have one. For multiple choice

CS 61c: Great Ideas in Computer Architecture

CSE 378 Midterm 2/12/10 Sample Solution

CENG 5133 Computer Architecture Design Spring Sample Exam 2

1 Hazards COMP2611 Fall 2015 Pipelined Processor

COMPUTER ORGANIZATION AND DESIGN

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

ECE260: Fundamentals of Computer Engineering

CS 352H Computer Systems Architecture Exam #1 - Prof. Keckler October 11, 2007

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

NATIONAL UNIVERSITY OF SINGAPORE

EXERCISE 3: DLX II - Control

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

ECE260: Fundamentals of Computer Engineering

The University of Alabama in Huntsville Electrical & Computer Engineering Department CPE Test II November 14, 2000

Mips Code Examples Peter Rounce

Chapter 4. The Processor

Lecture 5: Procedure Calls

Computer Organization and Structure

Static, multiple-issue (superscaler) pipelines

Block diagram view. Datapath = functional units + registers

Laboratory Exercise 6 Pipelined Processors 0.0

CS232 Final Exam May 5, 2001

Computer Architecture Experiment

Computer Organization

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

Transcription:

Exercises 5 - IPS datapath and control Questions 1. In the circuit of the AL back in lecture 4, we included an adder, an AND gate, and an OR gate. A multiplexor was used to select one of these three values. This circuit was repeated for n bits. Binvert Ci Operation (add, and, or) Ai Bi + Consider the IPS instruction slt (set if less than). This instruction takes two register arguments and writes a value 0x00000001 into the destination register if the first argument is less than the second, and it writes value 0x00000000 to the destination register otherwise. What would you need to add to the above circuit so it also could perform the slt instruction? Note that the answer depends on whether we are considering bit 0 or bits 1-31 since the output value is always 0 in the latter case when the instruction is slt. Hint: the slt case condition to be added to the. 2. Give four different ways in which an address is computed or obtained as part of a IPS instruction. 3. [This question was from the final exam in 2012.] For each of the three IPS instructions below: Specify as much of the machine code of the instruction as you can, showing how many bits are in each field and leaving unknown fields blank. Draw the datapath and controls for a single cycle implementation of the instruction; only include parts of the datapath that are used in the instruction; specify the bit width of any lines you draw in the datapath, and specify any known values. (a) addi $15, $0, -8 # add immediate (b) sltu $16, $15, $0 # set less than (unsigned) (c) jalr $16, $15 # special version of jump and link whereby you # jump to the address specified in a register and # also store return value

Exercises 5 - IPS datapath and control 4. Identify the hazards in the the following if-then-else sequence. Describe how to resolve these hazards using as few nop instructions as possible. if: slt $t0, $s0, $s1 bne $t0, $0, else lw $s3, 0($sp) add $s3, $s3, $s4 j endif else: sub $s3, $s3, $s4 endif: and $t0, $0, $0 or $t1, $0, $0

Solutions 1. [odified June 2016] The AL consists of 32 circuits such as shown below. For the slt instruction and for bit 0, we want the circuit to output a 1 if the less than condition is true and 0 otherwise. The remaining bits should output 0 for an slt instruction. How can both of these be achieved? The slt instruction compares two argument registers. For simplicity let s call these registers s 1 and s 2. The circuit should subtract s 2 from s 1, and then check if the result is negative. To compute the subtraction, the slt instruction must set the Binvert control to 1, just like the sub instruction does. To determine if s 1 s 2 < 0, check the adder output for bit 31. So, bit 31 of the adder output is used as sltvalue. See green label below. For bit 0, the fourth input is sltvalue, i.e. it takes value 1 if s 1 < s 2, and it takes value 0 otherwise. For bits 1-31, the fourth input to the is always a 0 value. sltvalue (bit 31 only) Binvert Ci Operation (add, and, or, slt ) Ai Bi + Cout sltvalue (for bit 0) or 0 (for bits 1-31)

2. (a) read from a register 3. (a) (b) sum a base and an offset, as in a load or store word instruction (c) sum PC+4 and an offset, as in a conditional branch (d) concatenate the upper four bits of PC with a positive offset (this is similar to 3.) as in the j instruction. Here are a few details that should be explicit in your solution. I-format partition with the appropriately labelled fields of each. The values 15 and 0 are coded in 5 bits each in the two register slots. fetch stage: PC register to emory (instructions) and the 32 bit instruction is read out and decomposed into the I-format fields. P C P C + 4 lines into and out of registers are labelled with bit numbers sign extend the immediate argument from 16 to 32 bits the value read from the register is fed to the AL, along with the sign extended value; result is written into a register

(b) The datapath here is similar to (a) so I ll only mention the key difference: sltu is R format so the partition of the instruction into fields is different. You need to know how many bits are in each field. The rs, rt, rd fields are 15 (011111), 0 (00000), 16 (10000). Note that the slt details from Question 1 are not explicit here since those details are within the AL.

(c) The datapath for the jalr instruction is a combination of jr and jal datapaths which I sketched out in class. You might use an I format or an R format for this. (The correct answer is R format but there is no way to know that.) If you assumed I format, then the rs register (source) register 15 (01111) is read out and fed into the PC, and the destination register would be rt and would have the value 16 (10000). This is where PC + 4 is written. If you assumed R format, then the rs register (source) register 15 (01111) is read out and fed into the PC, and the destination register would be rd and would have the value 16 (10000). This is where PC + 4 is written. PC is updated with the 32 bit value from the source register. To keep the figure simple, I have not bothered with the for selecting the PC write. The PC+4 value is written into a register so there should be a line from the PC to the register. (I have not bothered with a there, but in general there would be one.)

4. There are four (pipeline) hazards to be identified here. (a) (data hazard) The result of slt is not known until the WB stage, but it is needed by the bne instruction. The value is known after the AL stage of slt and must forwarded to the AL stage of the bne instruction. (b) (control hazard) The lw and add instructions will be fetched while the bne is decoded and goes through the AL, respectively. The lw and add instructions should only be executed if bne condition is not met. If the branch condition is met, then the WriteReg control of the lw and add instructions should be set to 0. They will still go through the pipeline but they won t write back. (c) (data hazard) The lw instruction gets a word from emory but this only happens at the end of the E stage. This value is needed at the AL stage of the add instruction. Thus, a nop needs to be inserted between lw and add. You mayt have been tempted to move the or instruction in there, instead of nop. But this is incorrect since add is conditioned on the branch, but or is not conditioned on the branch. (d) (control hazard) The sub enters the pipeline after j but it shouldn t be executed. So we can (re)set its RegWrite control to 0 so it doesn t write in the WB stage.