ECE 15B Computer Organization Spring 2011

Similar documents
Chapter 4. The Processor

CS61C Machine Structures. Lecture 13 - MIPS Instruction Representation I. 9/26/2007 John Wawrzynek. www-inst.eecs.berkeley.

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.

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

Chapter 4. The Processor

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

Introduction. Datapath Basics

Processor (I) - datapath & control. Hwansoo Han

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

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

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

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

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

CS61C : Machine Structures

Unsigned Binary Integers

Unsigned Binary Integers

Chapter 4. The Processor Designing the datapath

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

CS 4200/5200 Computer Architecture I

Chapter 4. The Processor

CSEE 3827: Fundamentals of Computer Systems

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

ECE232: Hardware Organization and Design

Computer Architecture

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

CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats

EN2910A: Advanced Computer Architecture Topic 02: Review of classical concepts

CS/COE1541: Introduction to Computer Architecture

Systems Architecture

CS 61c: Great Ideas in Computer Architecture

CS61C : Machine Structures

ECE 486/586. Computer Architecture. Lecture # 7

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

ECE 154A Introduction to. Fall 2012

MIPS%Assembly% E155%

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

CS3350B Computer Architecture MIPS Instruction Representation

CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats

ECE260: Fundamentals of Computer Engineering

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

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

Topic Notes: MIPS Instruction Set Architecture

Chapter 4. The Processor

LECTURE 2: INSTRUCTIONS

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

ECE260: Fundamentals of Computer Engineering

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Review of Last Lecture. CS 61C: Great Ideas in Computer Architecture. MIPS Instruction Representation II. Agenda. Dealing With Large Immediates

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

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

Lec 13: Linking and Memory. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

The MIPS Processor Datapath

CS222: MIPS Instruction Set

CSE 378 Midterm 2/12/10 Sample Solution

Instruction Set Architecture

Systems Architecture I

MIPS Coding Continued

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

COMPUTER ORGANIZATION AND DESIGN

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

MIPS (SPIM) Assembler Syntax

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

Computer Science 61C Spring Friedland and Weaver. Instruction Encoding

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

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

COMPUTER ORGANIZATION AND DESIGN

ECE232: Hardware Organization and Design

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

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


Reduced Instruction Set Computer (RISC)

Thomas Polzer Institut für Technische Informatik

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

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

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

UCB CS61C : Machine Structures

CSSE 232 Computer Architecture I. I/O and Addressing

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

CS3350B Computer Architecture

MIPS Instruction Set Architecture (2)

EE108B Lecture 3. MIPS Assembly Language II

M2 Instruction Set Architecture

Lecture 9: Disassembly

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

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

Reminder: tutorials start next week!

Computer Architecture

Instruction Set Architecture. "Speaking with the computer"

ECE260: Fundamentals of Computer Engineering

Reduced Instruction Set Computer (RISC)

Transcription:

ECE 15B Computer Organization Spring 2011 Dmitri Strukov Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy,

Agenda Instruction formats Addressing modes Advanced dconcepts

Instruction formats

Simple datapath picture Let s add more details on this figure to see why instruction Let s add more details on this figure to see why instruction decoding could be simple and to see what is happening with for different instructions

High Level Language Program (e.g., C) Compiler Assembly Language Program (e.g.,mips) Assembler Machine Language Program (MIPS) Machine Interpretation Hardware Architecture Description (e.g., block diagrams) Architecture Implementation Logic Circuit Description (Circuit Schematic Diagrams) Below the Program temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; lw $t0, 0($2) lw $t1, 4($2) sw $t1, 0($2) sw $t0, 4($2) 0000 1001 1100 0110 1010 1111 0101 1000 1010 1111 0101 1000 0000 1001 1100 0110 1100 0110 1010 1111 0101 1000 0000 1001 0101 1000 0000 1001 1100 0110 1010 1111

One to one mapping Assembly instruction lw $t0, 0($2) Binary code 0000 1001 1100 0110 1010 1111 0101 1000 One assembly instruction = 32 bit vector always 32 bits Macro or pseudo instruction > one line of code Examples: shift and rotate from Quiz 1 rol $a0, $a1, $a2 subu $t0, $0, $a2 srlv $t0, $a1, $t0 sllv $a0, $a1, $a2 or $a0, $a0, $t0

Datapath With Control

Instruction formats R format: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits I format: op rs rt constant or address 6 bits 5 bits 5 bits 16 bits J format: op address 6 bits 26 bits

R format Example op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits add $t0, $s1, $s2 note the order! (green card) special $s1 $s2 $t0 0 add 0 17 18 8 0 32 000000 10001 10010 01000 00000 100000 00000010001100100100000000100000 2 = 02324020 16

R Type Instruction

Instruction formats R format: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits I format: op rs rt constant or address 6 bits 5 bits 5 bits 16 bits J format: op address 6 bits 26 bits

Load Instruction

Instruction formats R format: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits I format: op rs rt constant or address 6 bits 5 bits 5 bits 16 bits J format: op address 6 bits 26 bits

Target Addressing Example Loop code from earlier example Assume Loop at location 80000 Loop: sll $t1, $s3, 2 80000 0 0 19 9 4 0 add $t1, $t1, $s6 80004 0 9 22 9 0 32 lw $t0, 0($t1) 80008 35 9 8 0 bne $t0, $s5, Exit 80012 5 8 21 2 addi $s3, $s3, 1 80016 8 19 19 1 j Loop 80020 2 20000 Exit: 80024

Branch on Equal Instruction

MIPS PC relative or branch addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant oraddress 6 bits 5 bits 5 bits 16 bits PC relative addressing Target address = PC + offset 4 PC already incremented dby 4 by this time

Instruction formats R format: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits I format: op rs rt constant or address 6 bits 5 bits 5 bits 16 bits J format: op address 6 bits 26 bits

Target Addressing Example Loop code from earlier example Assume Loop at location 80000 Loop: sll $t1, $s3, 2 80000 0 0 19 9 4 0 add $t1, $t1, $s6 80004 0 9 22 9 0 32 lw $t0, 0($t1) 80008 35 9 8 0 bne $t0, $s5, Exit 80012 5 8 21 2 addi $s3, $s3, 1 80016 8 19 19 1 j Loop 80020 2 20000 Exit: 80024

Datapath With Jumps Added

Pseudodirect or Jump Addressing Jump (j and jal) targets could be anywhere in text segment Encode full address in instruction op address 6 bits 26 bits (Pseudo)Direct jump addressing Target address = PC 31 28 : (address 4)

Implementing Jumps Jump 2 address 31:26 25:0 Jump uses word address Update PC with concatenation of Top 4 bits of old PC 26 bit jump address 00 Need an extra control signal decoded from opcode

Branching Far Away If branch target is too far to encode with 16 bit offset, assembler rewrites the code Example beq $s0,$s1, L1 bne $s0,$s1, L2 j L1 L2:

Note on the PC incrementing Technical term for auto incrementation of PC is delayed branch By default in SPIM delayed branch is not checked. To see you SPIM settings look at simulator settings You can also check it by loading code to SPIM to check main : bne $s0, $s0, main

Loading constant values to registers Any immediate is 16 bit To load 32 bits constant one can use addi, sll + addi or better way to use lui rd, const (load upper immediate)

Specific Addressing Mode in MIPS

Various specific addressing modes in other ISAs Absolute address Immediate data Inherent address Register direct Register indirect Base register Register indirect with index register Register indirect with index register and displacement Register indirect with index register scaled Absolute address with index register Memory indirect Program counter relative

Example: Basic x86 Addressing Modes Two operands per instruction Source/dest operand Register Register Register Memory Memory Memory addressing modes Address inregister Address = R base + displacement Second source operand Register Immediate Memory Register Immediate Address = R + scale base 2 R index (scale = 0, 1, 2, or 3) Address = R base + 2 scale R index + displacement

Advanced Topics: Code density examples

Recent study (2009)

Code density examples

Advanced topics: Pipelining

Datapath With Control

Pipelining Analogy Pipelined laundry: overlapping execution Parallelism improves performance Four loads: Speedup = 8/3.5 = 2.3 Non stop: Speedup p = 2n/0.5n + 1.5 4 = number of stages

Pipeline registers Need registers between stages To hold information produced in previous cycle

Multi Cycle Pipeline Diagram Traditional form

Advanced topics: Cache design basics

Datapath With Control

Principle of Locality Programs access a small proportion popoto of their address space at any time Temporal locality Items accessed recently are likely to be accessed again soon e.g., instructions i in a loop, induction i variables ibl Spatial locality Items near those accessed recently entl are likely to be accessed soon E.g., g, sequential instruction access, array data

Taking Advantage of Locality Memory hierarchy Store everything on disk Copy recently accessed (and nearby) b)items from disk to smaller DRAM memory Main memory Copy more recently accessed (and nearby) items from DRAM to smaller SRAM memory Cache memory attached to CPU

Direct Mapped Cache Location determined by address Direct mapped: only one choice (Block address) modulo (#Blocks in cache) #Blocks is a power of 2 Use low order address bits

Tags and Valid Bits How do we know which particular block is stored in a cache location? Store block address as well as the data Actually, only need the high order bits Called the tag What if there is no data in a location? Valid bit: 1 = present, 0 = not present Initially 0

Example: Direct mapped cache