Data paths for MIPS instructions

Similar documents
Merging datapaths: (add,lw, sw)

Processor (I) - datapath & control. Hwansoo Han

Chapter 4. The Processor

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

LECTURE 5. Single-Cycle Datapath and Control

Chapter 4. The Processor

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

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

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

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

Chapter 4. The Processor Designing the datapath

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

Systems Architecture

Introduction. Datapath Basics

Inf2C - Computer Systems Lecture Processor Design Single Cycle

ECE232: Hardware Organization and Design

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

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

The MIPS Processor Datapath

ECE260: Fundamentals of Computer Engineering

CPE 335 Computer Organization. Basic MIPS Architecture Part I

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

Faculty of Science FINAL EXAMINATION

Lecture 10: Simple Data Path

CENG 3420 Lecture 06: Datapath

Lecture Topics. Announcements. Today: Single-Cycle Processors (P&H ) Next: continued. Milestone #3 (due 2/9) Milestone #4 (due 2/23)

The Processor: Datapath & Control

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

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design

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

Chapter 4 The Processor 1. Chapter 4A. The Processor

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

LECTURE 6. Multi-Cycle Datapath and Control

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

Review: Abstract Implementation View

Systems Architecture I

Chapter 4. The Processor

The overall datapath for RT, lw,sw beq instrucution

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

CC 311- Computer Architecture. The Processor - Control

CS3350B Computer Architecture Quiz 3 March 15, 2018

Chapter 5: The Processor: Datapath and Control

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

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

CPE 335. Basic MIPS Architecture Part II

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

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

Single cycle MIPS data path without Forwarding, Control, or Hazard Unit

Single Cycle Datapath

CPU Organization (Design)

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

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

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

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

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Chapter 4. The Processor

CSE140: Components and Design Techniques for Digital Systems

ECE 486/586. Computer Architecture. Lecture # 7

Single-Cycle Examples, Multi-Cycle Introduction

Fundamentals of Computer Systems

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

CSEN 601: Computer System Architecture Summer 2014

Design of the MIPS Processor

Processor: Multi- Cycle Datapath & Control

Computer Hardware Engineering

CS 351 Exam 2 Mon. 11/2/2015

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

CS Computer Architecture Spring Week 10: Chapter

Topic #6. Processor Design

CSEE 3827: Fundamentals of Computer Systems

RISC Processor Design

Mapping Control to Hardware

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

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

Design of Digital Circuits 2017 Srdjan Capkun Onur Mutlu (Guest starring: Frank K. Gürkaynak and Aanjhan Ranganathan)

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

ECE260: Fundamentals of Computer Engineering

COMPUTER ORGANIZATION AND DESIGN

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

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

Laboratory Single-Cycle MIPS CPU Design (3): 16-bits version One clock cycle per instruction

Topic Notes: MIPS Instruction Set Architecture

The Processor: Datapath & Control

MIPS Coding Continued

Single Cycle Datapath

CpE242 Computer Architecture and Engineering Designing a Single Cycle Datapath


ECE369. Chapter 5 ECE369

Chapter 2: Instructions:

ENGN1640: Design of Computing Systems Topic 04: Single-Cycle Processor Design

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

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

Unsigned Binary Integers

Unsigned Binary Integers

Processor Design Pipelined Processor (II) Hung-Wei Tseng

are Softw Instruction Set Architecture Microarchitecture are rdw

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

Computer Hardware Engineering

Transcription:

You are familiar with how MIPS programs step from one instruction to the next, and how branches can occur conditionally or unconditionally. We next examine the machine level representation of how MIPS goes from one instruction to the next. We will examine how each MIPS instruction is decoded so that data is passed to the appropriate places (e.g. from register to memory, from memory to a register, from a register to another register, etc). By the end of this lecture and the next, you will have a basic understanding of how the combinational and sequential circuits that you learned at the beginning of this course are related to the MIPS instructions and programs that we have covered in more recent lectures. Data paths for MIPS instructions In this lecture and the next, we will assume that one instruction is executed in each clock cycle. This is known as the single cycle model. In the lecture following the study break, we will see the limitations of the single cycle model, and we will discuss how MIPS gets around it, namely by pipelining the instructions. Instruction fetch Both data and instructions are in. For an instruction to be executed, it first must be read out of. MIPS has a special program counter register () that holds the address of the current instruction being executed. As a MIPS programmer, you are not responsible for fetching the next instruction from memory. This done automatically. Let s have a look at how this is done. Consider the simple case of a non-branching instruction such as add or lw or sw. The address of the instruction that follows this non-branching instruction is, by default, the address of the current instruction plus (that is, plus bytes or one word). Because we are assuming that each instruction takes one clock cycle, at the end of clock cycle, is updated to +. The current instruction (add or lw or sw,...) is fetched by using to select a word from the text part of, namely the word containing the current instruction. Later in the course, we will see how this is done. For now, it is enough for you to understand that an address is sent to and the instruction at that address is read out of. To summarize, the contents of the (a bit address) is sent to and the instruction (also bits) starting at that address is read from. various parts of instruction (depends on R, I, J format) last updated: 23 rd Feb, 201 1 lecture notes c Michael Langer

Let s next look at several examples of instructions and consider the datapaths and how these are led. Data path for add What happens when the bit add instruction is read out of memory? Recall that an add instruction has R format: field op rs rt rd shamt funct numbits The opcode field and funct fields together encode that the operation is addition (rather than some other arithmetic or logical operation). The three register fields of the instruction specify which hold the operands and which register should receive the output of the ALU. Thus, the op code and funct fields are used to what data gets puts on what lines and when data gets written. I will say more about how the signals are determined next lecture. For now, we will concentrate on the datapaths, as shown in the figure below. opcode, funct 12 WriteEnable ("RegWrite") ALU op Here is what happens during an add instruction: new value is computed and written (at the end of clock cycle) instruction is read ( fetched ) from (details later in the course) two ReadReg and the WriteReg are selected (recall lecture ) signals for ALU operation are determined (to be discussed next lecture) last updated: 23 rd Feb, 201 2 lecture notes c Michael Langer

RegData values are read from two and input to ALU; ALU operation is performed result is written into WriteReg (at the end of clock cycle) The steps above can all be done in a single clock cycle, provided the clock interval is long enough that all circuits have stabilized (and they would need to designed to ensure this). For example, the ALU involves carry values which take time to ripple through. Data path for load word (lw) Recall that this instruction has I format: An example is: lw $s0, 2($t3) field op rs rt immediate numbits 1 Here is the data path (including the update!) opcode WriteEnable ("RegWrite") ALUop (data) 1 sign extend For lw, the first three steps are the same as in the add instruction, but the remaining steps are quite different. new value is computed (it is written at next clock pulse) instruction is read ( fetched ) from ReadReg and WriteReg selected and RegWrite is specified base address of word to be loaded is read from a register and fed to ALU offset (1 bit immediate field) is sign-extended and fed to ALU last updated: 23 rd Feb, 201 3 lecture notes c Michael Langer

signals are set up for ALU operation (see next lecture) ALU computes sum of base address and sign-extended offset; result is sent to word is read from and written into a register (end of clock cycle) Note that in the figure above I have colored the instruction segment (left) and the data segment (right) to remind you roughly where these segments are located and the fact that they don t overlap. Data path for store word (sw) The format for sw is the same as lw but the data path for sw is slightly different: opcode ALUop MemWrite (data) 1 sign extend new value is computed (it is written at next clock pulse) instruction is read ( fetched ) from two ReadReg are selected base address for word is read from a register and fed to ALU offset (1 bit immediate field) is sign-extended and fed to ALU signals are set up for ALU operation ALU computes sum of base address and sign-extended offset; result is sent to word is written into (at end of clock cycle) last updated: 23 rd Feb, 201 lecture notes c Michael Langer

Data path for bne Next let s look at the case that the current instruction is a conditional branch, for example, bne $s0 $s2, label which is also I format. This instruction is more interesting because the might not proceed to the next instruction in at the next clock cycle. To determine whether the branch condition is met, the bne instruction uses the ALU, and performs a subtraction on the two register arguments. If the result is not zero, then the two do not hold the same values and the program should take the branch. Otherwise, the program continues to the next default instruction. Specifically, if the result of the ALU subtraction is not zero, then P C := P C + + offset else P C := P C +. It may seem a bit strange that is added in both cases, but that s in fact what MIPS does. This makes sense when you consider the the datapath. The offset is relative to the current instruction address plus, rather than to the current instruction address. (See example on slides.) See the figure below for the datapath. The multiplexor in the upper part of the figure selects between + and ++offset. The selector signal depends on the bit output of the ALU, which has performed a subtraction using the two specified by the bne instruction. This bit ALU result is fed into a bit OR gate. The output of the OR gate is labelled NotZero in the figure. This NotZero signal is 1 if and only the subtraction is non-zero, that is, if the two do not have the same contents. Note that the branch is only taken if indeed the instruction is bne. In the figure, the NotZero signal is ANDed with a bne instruction signal that indicates it is indeed a bne instruction. (I have labelled the branch as bne instruction in the figure.) The branch is taken when both the NotZero signal is ON and the branch is ON (1). e.g. For an add instruction or any other R-format instruction, the branch signal would be OFF (0). One other detail worth noting. Instructions are word aligned in, namely the two lowest order bits of an instruction address always have the value 0. Thus, in the 1 bit address field of a conditional branch, MIPS doesn t waste these two bits by always setting them to 00. Instead, the 1 bit field represents an offset of the offset representation in binary. That is, the offset value is shifted by two bits to the left before it is added to +. Careful: no shift register is required for this. Instead, two 0 wires are inserted directly, and the sign extend circuit extends from 1 to 30 bits, so in total there are bits. Here are the steps of the bne instruction: holds the address of the current instruction instruction is read ( fetched ) from + value is computed value of + is added to sign-extended/shifted offset last updated: 23 rd Feb, 201 lecture notes c Michael Langer

+ + 0 M U 1 X NotZero opcode bne instruction ALUOp 1 sign extend and shift left by 2 bits ReadReg values are set signals are set up for subtraction in ALU RegData values are read from two into ALU ALU does subtraction and bit result is fed into giant OR gate, whose output we call NotZero NotZero is ANDed with a bne to select either + or ++offset, and selected value is written into (at end of clock pulse) Datapath for j (jump, J format) Recall that the jump instruction j has the following format. This gives 2 bits to say where we are jumping to. field op address numbits 2 You might think that 2 bits specify an offset from + just like the conditional branches. However, it is not done this way. Rather, the offset is from the address 0x*0000000, where * is the high order bits of the register, namely bits 28-31. Recall that the MIPS instructions of user program go up to but not including 0x10000000. Thus, all user instructions have 0000 as their highest last updated: 23 rd Feb, 201 lecture notes c Michael Langer

four bits i.e. 0x0******* in hexadecimal. MIPS doesn t always concatenate 0000 onto the front of a jump instruction, since there are kernel programs as well. Instructions in the kernel programs have addresses that are above 0x80000000. So jump instructions in the kernel do not take 0000 as their upper four bits. Rather, they take (1000) 2 as their upper four bits, i.e. 0x8. Moreover, because instructions are word aligned, the 2 bit field is used to specify bits 2-27. Bits 0 and 1 in an instruction address always have the value 00. [ 28 31] conca tenate M U X 28 Src [inst 0 2] shifted left by 2 bits [inst 2 31] last updated: 23 rd Feb, 201 7 lecture notes c Michael Langer