ECE232: Hardware Organization and Design

Similar documents
ECE232: Hardware Organization and Design

ECE331: Hardware Organization and Design

CS3350B Computer Architecture

Chapter 1. Computer Abstractions and Technology

EECS Computer Organization Fall Based on slides by the author and prof. Mary Jane Irwin of PSU.

Chapter 2A Instructions: Language of the Computer

Chapter 2 Instruction: Language of the Computer

MIPS Instruction Set Architecture (1)

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

EN164: Design of Computing Systems Lecture 09: Processor / ISA 2

Announcements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls

ECE260: Fundamentals of Computer Engineering

Instructions: Language of the Computer

CSCI 402: Computer Architectures. Instructions: Language of the Computer (1) Fengguang Song Department of Computer & Information Science IUPUI

CSEE 3827: Fundamentals of Computer Systems

Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

Architecture I. Computer Systems Laboratory Sungkyunkwan University

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

CS3350B Computer Architecture MIPS Introduction

מבנה מחשבים Amar Lior Based on lectures notes from Arie Schlesinger

CSCI 402: Computer Architectures. Instructions: Language of the Computer (1) Fengguang Song Department of Computer & Information Science IUPUI

Instructions: Language of the Computer

Instruction Set Principles and Examples. Appendix B

Computer Architecture. Lecture 2 : Instructions

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

Lecture 4: Instruction Set Architecture

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

Computer Organization MIPS ISA

ECE 154A Introduction to. Fall 2012

EC 413 Computer Organization

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

Operations, Operands, and Instructions

EE108B Lecture 2 MIPS Assembly Language I. Christos Kozyrakis Stanford University

Alternate definition: Instruction Set Architecture (ISA) What is Computer Architecture? Computer Organization. Computer structure: Von Neumann model

Typical Processor Execution Cycle

Math 230 Assembly Programming (AKA Computer Organization) Spring MIPS Intro

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

ECE331: Hardware Organization and Design

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

COMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?

Course Administration

CPE300: Digital System Architecture and Design

MIPS Memory Access Instructions

Computer Architecture

Lecture Topics. Announcements. Today: The MIPS ISA (P&H ) Next: continued. Milestone #1 (due 1/26) Milestone #2 (due 2/2)

INSTITUTO SUPERIOR TÉCNICO. Architectures for Embedded Computing

Review of instruction set architectures

CS 61C: Great Ideas in Computer Architecture Intro to Assembly Language, MIPS Intro

CSCI 402: Computer Architectures

ECE 486/586. Computer Architecture. Lecture # 6

COSC 6385 Computer Architecture. Instruction Set Architectures

Lecture 3 Machine Language. Instructions: Instruction Execution cycle. Speaking computer before voice recognition interfaces

Hardware Level Organization

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

Lecture 5: Instruction Set Architectures II. Take QUIZ 2 before 11:59pm today over Chapter 1 Quiz 1: 100% - 29; 80% - 25; 60% - 17; 40% - 3

Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University. See P&H Appendix , and 2.21

IC220 SlideSet #2: Instructions (Chapter 2)

CENG3420 Lecture 03 Review

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

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

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

Computer Organization and Programming

ECE331: Hardware Organization and Design

Computer Architecture

Instruction Set Architecture

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

COMPUTER ORGANIZATION AND DESIGN

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Chapter 2 Logic Gates and Introduction to Computer Architecture

Practical Malware Analysis

Chapter 2. Instruction Set Design. Computer Architectures. software. hardware. Which is easier to change/design??? Tien-Fu Chen

Computer Architecture Computer Architecture. Computer Architecture. What is Computer Architecture? Grading

Instruction Set Architecture

CS61C C/Assembler Operators and Operands Lecture 2 January 22, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)

CS3350B Computer Architecture Winter 2015

Computer Model. What s in a computer? Processor Memory I/O devices (keyboard, mouse, LCD, video camera, speaker, disk, CD drive, )

Computer Architecture 2/26/01 Lecture #

EC 413 Computer Organization

CS61C Machine Structures. Lecture 8 - Introduction to the MIPS Processor and Assembly Language. 9/14/2007 John Wawrzynek

CS3350B Computer Architecture MIPS Instruction Representation

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

Programmable Machines

Programmable Machines

RISC, CISC, and ISA Variations

Chapter 2. Instructions:

BASIC COMPUTER ORGANIZATION. Operating System Concepts 8 th Edition

Instruction Set Architectures. CS301 Prof. Szajda

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

Hakim Weatherspoon CS 3410 Computer Science Cornell University

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Computer Architecture, RISC vs. CISC, and MIPS Processor

Survey. Motivation 29.5 / 40 class is required

EECE 321: Computer Organization

CPU Architecture and Instruction Sets Chapter 1

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

Instruction Set Architecture (ISA)

CS64 Computer Organization

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

Transcription:

ECE232: Hardware Organization and Design Lecture 4: MIPS Instructions Adapted from Computer Organization and Design, Patterson & Hennessy, UCB

From Last Time Two values enter from the left (A and B) Need to perform (A+B)+A In -> X (Load A) In -> Y (Load B) A+B -> Y (A+B)+A -> Out Four steps and then repeat InPass OutPass In Out LoadX X Y LoadY Function ALU AluPass ECE232: MIPS Instructions-I 2

Building Blocks Tri-State Buffer Truth table Gated D-latch (based on static value of enable pin, E) input output E D Q Q Comment 0 X Q prev Q prev No change 1 0 0 1 Reset 1 1 1 0 Set ECE232: MIPS Instructions-I 3

Arithmetic Logic Unit Examine the functionality of this 74LS382 ALU chip datasheet http://pdf.datasheetcatalog.com/datasheet/nationalsemiconductor/ds009529.pdf Performs 8 functions ECE232: MIPS Instructions-I 4

Conventions In the world, there are all kinds of conventions that we take for granted. Some are more commonly shared than others: ECE232: MIPS Instructions-I 5

Unsigned Binary Integers Given an n-bit number x = x + Range: 0 to +2 n 1 n 1 n 2 1 0 n 12 + xn 22 +! + x12 x02 Example 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0 2 2 +1 2 1 +1 2 0 = 0 + + 8 + 0 + 2 + 1 = 11 10 Using 32 bits 0 to +4,294,967,295 Using 64 bits 0 to + 18,446,744,073,709,551,616 ECE232: MIPS Instructions-I 6

2s-Complement Signed Integers Bit 31 is sign bit 1 for negative numbers 0 for non-negative numbers ( 2 n 1 ) can t be represented Non-negative numbers have the same unsigned and 2scomplement representation Some specific numbers 0: 0000 0000 0000 1: 1111 1111 1111 Most-negative: 1000 0000 0000 Most-positive: 0111 1111 1111 Example (4 bits): 0111 à +7 1000 à 8 ECE232: MIPS Instructions-I 7

2s-Complement Signed Integers Given an n-bit number x = x + n 1 n 2 1 0 n 12 + xn 22 +! + x12 x02 Range: 2 n 1 to +2 n 1 1 Example 1111 1111 1111 1111 1111 1111 1111 1100 2 = 1 2 31 + 1 2 30 + + 1 2 2 +0 2 1 +0 2 0 = 2,147,483,648 + 2,147,483,644 = 4 10 Using 32 bits 2,147,483,648 to +2,147,483,647 ECE232: MIPS Instructions-I 8

Addressing words: Big or Small Endian Big Endian: address of most significant byte = word address (xx00 = Big End of word) IBM 360/370, Motorola 68k, MIPS, Sparc, HP PA (found in old Macintosh with PowerPC chip) Little Endian: address of least significant byte = word address (xx00 = Little End of word) Intel 80x86, DEC Vax, DEC Alpha (found in all modern PC computers: Mac and Windows) 3 2 1 0 little endian byte 0 msb lsb 0 1 2 3 big endian byte 0 ECE232: MIPS Instructions-I 9

Computer Organization 5 classic components of any computer Processor (CPU) (active) Control ( brain ) Datapath Computer Memory (passive) (where programs, & data live when running) Devices Input Output Keyboard, Mouse Disk (where programs, & data live when not running) Display, Printer The CPU Control fits in closely with datapath ECE232: MIPS Instructions-I 10

Program View of Memory Processor (CPU) Control Datapath Computer Memory Devices Input Output Memory viewed as a large, single -dimension array, with an address? 8 bits of data A memory address is an index into array The index points to a byte of memory - "Byte addressing" A 32-bit machine addresses memory by a 32-bit address Access bytes (8 bits), words (32 bits) or half-words 0 1 2 3 4 5 6... 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data ECE232: MIPS Instructions-I 11

Memory word addressing CPU Address Bus Memory Every word in memory has an address Today machines address memory as bytes, hence word addresses differ by 4 Memory[0], Memory[4], Memory[8], Word 0 (bytes 0 to 3) Word 1 (bytes 4 to 7) 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0xfffffff4 0xfffffffc 0xfffffffc Called the address of a word Memory 4GB Max (Typically 512MB-2GB) ECE232: MIPS Instructions-I 12

Registers Computer Processor (CPU) Control Memory Devices Input Datapath Registers Output Once a memory is fetched, the data must be placed somewhere in CPU Advantages of registers registers are faster than memory registers can hold variables and intermediate results memory traffic is reduced, so program runs faster code density improves (later) ECE232: MIPS Instructions-I 13

Registers code for A = B + C (This is not MIPS code, It is in English) load R1,B load R2,C add R3,R1,R2 store R3,A # R1 = B # R2 = C # R3 = R1+R2 # A = R3 Many current processors support 32 registers (MIPS) The more registers available, the fewer memory accesses will be necessary Registers can hold lots of intermediate values Instructions must include bits to specify which registers to operate on register address ECE232: MIPS Instructions-I 14

Instruction Set Architecture (ISA) Application (FireFox) Software Hardware Compiler Assembler Processor Operating System Memory (Unix; Windows) Datapath & Control Digital Design Circuit Design transistors, IC layout I/O system Instruction Set Architecture Key Idea: abstraction hide unnecessary implementation details helps us cope with enormous complexity of real systems ECE232: MIPS Instructions-I 15

The MIPS Instruction Set Used as the example throughout the book Stanford MIPS commercialized by MIPS Technologies (www.mips.com) Large share of embedded core market Applications in consumer electronics, network/storage equipment, cameras, printers, Typical of many modern ISAs See MIPS Reference Data tear-out card, and Appendices B and E ECE232: MIPS Instructions-I 16

Arithmetic Operations Add and subtract, three operands Two sources and one destination add a, b, c # a gets b + c All arithmetic operations have this form Design Principle 1: Simplicity favors regularity Regularity makes implementation simpler Simplicity enables higher performance at lower cost ECE232: MIPS Instructions-I 17

Arithmetic Example C or Java code: f = (g + h) - (i + j); Compiled MIPS code: add t0, g, h # temp t0 = g + h add t1, i, j # temp t1 = i + j sub f, t0, t1 # f = t0 - t1 ECE232: MIPS Instructions-I 18

Register Operands Arithmetic instructions use register operands MIPS has a 32 32-bit register file Use for frequently accessed data Numbered 0 to 31 32-bit data called a word Assembler names $t0, $t1,, $t9 for temporary values $s0, $s1,, $s7 for saved variables Design Principle 2: Smaller is faster c.f. (compare with) main memory: millions of locations ECE232: MIPS Instructions-I 19

Register Operand Example C or Java code: f = (g + h) - (i + j); f,, j in $s0,, $s4 Compiled MIPS code: add $t0, $s1, $s2 add $t1, $s3, $s4 sub $s0, $t0, $t1 ECE232: MIPS Instructions-I 20

Simplified Datapath Two register fetches in one cycle Load from memory Store to memory Registers A L U Data Memory From Register for SW To register for LW ECE232: MIPS Instructions-I 21

Memory Operands Main memory used for composite data Arrays, structures, dynamic data To apply arithmetic operations Load values from memory into registers Store result from register to memory Memory is byte addressed Each address identifies an 8-bit byte Words are aligned in memory Address must be a multiple of 4 MIPS is Big Endian Most-significant byte at least address of a word c.f. Little Endian: least-significant byte at least address ECE232: MIPS Instructions-I 22

Memory Operand Example 1 C code: g = h + A[8]; g in $s1, h in $s2, base address of A in $s3 Compiled MIPS code: Index 8 requires offset of 32 4 bytes per word lw $t0, 32($s3) # load word add $s1, $s2, $t0 offset base register ECE232: MIPS Instructions-I 23

Memory Operand Example 2 C code: A[12] = h + A[8]; h in $s2, base address of A in $s3 Compiled MIPS code: Index 8 requires offset of 32 lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 48($s3) # load word # store word ECE232: MIPS Instructions-I 24