ECE331: Hardware Organization and Design

Similar documents
ECE232: Hardware Organization and Design

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

ECE232: Hardware Organization and Design

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design

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

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC)

Chapter 2A Instructions: Language of the Computer

ECE331: Hardware Organization and Design

CS3350B Computer Architecture

Computer Architecture. MIPS Instruction Set Architecture

Instructions: Language of the Computer

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

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

Instructions: Language of the Computer

Computer Organization MIPS ISA

Computer Architecture. The Language of the Machine

Thomas Polzer Institut für Technische Informatik

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Computer Architecture

Review: MIPS Organization

ECE232: Hardware Organization and Design

Course Administration

CS3350B Computer Architecture MIPS Introduction

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

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

MIPS Instruction Set Architecture (1)

CS3350B Computer Architecture MIPS Instruction Representation

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

CENG3420 Lecture 03 Review

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

MIPS Assembly Programming

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

The MIPS Instruction Set Architecture

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

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

M2 Instruction Set Architecture

Computer Architecture. Chapter 3: Arithmetic for Computers

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

Arithmetic for Computers

Chapter 3. Arithmetic Text: P&H rev

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

ECE232: Hardware Organization and Design

ECE260: Fundamentals of Computer Engineering

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

MIPS Integer ALU Requirements

ECE 15B Computer Organization Spring 2010

Number Systems and Their Representations

Integer Multiplication and Division

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

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

Signed Multiplication Multiply the positives Negate result if signs of operand are different

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

Tailoring the 32-Bit ALU to MIPS

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

COMPUTER ORGANIZATION AND DESIGN

ECE260: Fundamentals of Computer Engineering

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

Chapter 2: Instructions:

MIPS Instruction Set

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

Unsigned Binary Integers

Unsigned Binary Integers

Review of instruction set architectures

Computer Science 61C Spring Friedland and Weaver. Instruction Encoding

EC 413 Computer Organization

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

ECE 154A Introduction to. Fall 2012

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

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

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

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

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

UCB CS61C : Machine Structures

ECE331: Hardware Organization and Design

CENG3420 L05: Arithmetic and Logic Unit

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

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

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

Levels of Programming. Registers

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

CS61C : Machine Structures

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

MIPS Reference Guide

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

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

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Arithmetic for Computers. Hwansoo Han

TDT4255 Computer Design. Lecture 4. Magnus Jahre

CS 4200/5200 Computer Architecture I

Lecture 8: Addition, Multiplication & Division

CS 61c: Great Ideas in Computer Architecture

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Transcription:

ECE331: Hardware Organization and Design Lecture 15: Midterm 1 Review Adapted from Computer Organization and Design, Patterson & Hennessy, UCB

Basics Midterm to cover Book Sections (inclusive) 1.1 1.5 2.1 2.8 3.1 3.5 4.1 4.5 MIPS programming Green sheet to be provided as part of the exam (only the first page will actually be needed) à You should know hexadecimal conversion No calculators or additional materials from you are necessary Just bring a writing implement and a method for making corrections Recommended: Pencil and Eraser Don t forget to eat lunch/dinner! Food is energy for your brain!! ECE331: Midterm Review 2

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) ECE331: Midterm Review 3

Datapath I/O A wire (or by extension, a bus) can be driven by only one tri-state at a time If InPass is active, AluPass must be inactive If AluPass is active, InPass must be inactive InPass OutPass LoadX X Y LoadY Function ALU AluPass ECE331: Midterm Review 4

Implementing the Control ROM Two values enter from the left (A and B) Need to perform (A+B)+A In -> X (Load A) - State 00 In -> Y (Load B) - State 01 A+B -> Y - State 10 (A+B)+A -> Out - State 11 Addr PS ROM 0100010100 00 1000001100 01 1101101010 10 0001100011 11 NS PS NS Function LoadX LoadY InPass AluPass OutPass 00 01 000 1 0 1 0 0 01 10 000 0 1 1 0 0 10 11 011 0 1 0 1 0 11 00 011 0 0 0 1 1 Control outputs ECE331: Midterm Review 5

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 Little Endian: address of least significant byte = word address (xx00 = Little End of word) Intel 80x86, DEC Vax, DEC Alpha msb 3 2 1 0 little endian byte 0 lsb 0 1 2 3 big endian byte 0 ECE331: Midterm Review 6

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 ECE331: Midterm Review 7

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 ECE331: Midterm Review 8

MIPS Registers and Usage Name Register number Usage $zero 0 the constant value 0 $at 1 reserved for assembler $v0-$v1 2-3 values for results and expression evaluation $a0-$a3 4-7 arguments $t0-$t7 8-15 temporary registers $s0-$s7 16-23 saved registers $t8-$t9 24-25 more temporary registers $k0-$k1 26-27 reserved for Operating System kernel $gp 28 global pointer $sp 29 stack pointer $fp 30 frame pointer $ra 31 return address ECE331: Midterm Review 9

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 Does not apply to floating point numbers!!! ECE331: Midterm Review 10

MIPS Arithmetic Instructions Instruction Example Meaning Comments add add $1,$2,$3 $1 = $2 + $3 3 operands; subtract sub $1,$2,$3 $1 = $2 $3 3 operands; add immediate addi $1,$2,100 $1 = $2 + 100 + constant; add unsigned addu $1,$2,$3 $1 = $2 + $3 3 operands; subtract unsigned subu $1,$2,$3 $1 = $2 $3 3 operands; add imm. unsign. addiu $1,$2,100 $1 = $2 + 100 + constant; multiply mult $2,$3 Hi, Lo = $2 x $3 64-bit signed product multiply unsigned multu$2,$3 Hi, Lo = $2 x $3 64-bit unsigned product divide div $2,$3 Lo = $2 $3, Lo = quotient, Hi = remainder Hi = $2 mod $3 divide unsigned divu $2,$3 Lo = $2 $3, Unsigned quotient & remainder Hi = $2 mod $3 Move from Hi mfhi $1 $1 = Hi Used to get copy of Hi Move from Lo mflo $1 $1 = Lo Used to get copy of Lo ECE331: Midterm Review 11

Sign Extension Representing a number using more bits Preserve the numeric value In MIPS instruction set addi: extend immediate value lb, lh: extend loaded byte/halfword Replicate the sign bit to the left c.f. unsigned values: extend with 0s Examples: 8-bit to 16-bit +2: 0000 0010 => 0000 0000 0000 0010 2: 1111 1110 => 1111 1111 1111 1110 ECE331: Midterm Review 12

I-Format vs. R-Format Instructions Compare with R-Format 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits op rs rt rd shamt funct R-Format 6 bits 5 bits 5 bits 16 bits op rs rt offset I-Format Note similarity! ECE331: Midterm Review 13

Binary Representation - Branch 6 bits 5 bits 5 bits 16 bits op rs rt offset Branch instructions use I-Format offset is added to PC when branch is taken beq r0, r1, offset has the effect: Conversion to byte offset if (r0==r1) pc = pc + 4 + (offset << 2) else pc = pc + 4; Offset is specified in instruction words (why?) What is the range of the branch target addresses? ECE331: Midterm Review 14

Binary Representation - Jump 6 bits 26 bits op address Jump Instruction uses J-Format (op=2) What happens during execution? PC = PC[31:28] : (IR[25:0] << 2) Concatenate upper 4 bits of PC to form complete 32-bit address Conversion to byte offset ECE331: Midterm Review 15

Storage Management on a Call/Return A new procedure must create space for all its local variables on the stack Arguments are copied into $a0-$a3; the jal is executed After the callee creates stack space, it updates the value of $sp Once the callee finishes, it copies the return value into $v0, frees up stack space, and $sp is incremented The caller can use the value in $v0 $t0-$t7 are not stored on the stack during procedure calls ECE331: Midterm Review 16

Full-Adder (FA) Examine the Full Adder table Cin x y Cin Cout S 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 Cout = x y + Cin (x + y) S = x y c + x yc + xy c + xyc = x y c x y l In general, for bit i: c i+1 = x i y i + c i (x i +y i ) where c i+1 = Cout, c i = Cin Cout Sum Half adder has 2 inputs. In principle HA is same as FA, with Cin set to 0. ECE331: Midterm Review 17

Parallel Adder: Ripple Carry In a parallel arithmetic unit All 2n input bits available at the same time Carry propagates from the FA to the right to FA to the left Carries ripple through all n FAs before we can claim that the sum outputs are correct and may be used in further calculations Each FA has a finite delay ECE331: Midterm Review 18

Example x3,x2,x1,x0=1111 y3,y2,y1,y0=0001 ΔFA - operation time - delay Assuming equal delays for sum and carry-out Longest carry propagation chain when adding two 4-bit numbers In synchronous arithmetic units - time allowed for adder's operation is worst-case delay - nδfa ECE331: Midterm Review 19

Single-Precision Range Exponents 00000000 and 11111111 reserved Smallest value Exponent: 00000001 actual exponent = 1 127 = 126 Fraction: 000 00 significand = 1.0 ±1.0 2 126 ±1.2 10 38 Largest value exponent: 11111110 actual exponent = 254 127 = +127 Fraction: 111 11 significand 2.0 ±2.0 2 +127 ±3.4 10 +38 ECE331: Midterm Review 20

Floating-Point Example Represent 0.75 0.75 = ( 1) 1 1.1 2 2 1 S = 1 Fraction = 1000 00 2 Exponent = 1 + Bias Single: 1 + 127 = 126 = 01111110 2 Double: 1 + 1023 = 1022 = 01111111110 2 Single: 1011111101000 00 Double: 1011111111101000 00 ECE331: Midterm Review 21

Floating-Point Addition Consider a 4-digit decimal example 9.999 10 1 + 1.610 10 1 1. Align decimal points Shift number with smaller exponent 9.999 10 1 + 0.016 10 1 2. Add significands 9.999 10 1 + 0.016 10 1 = 10.015 10 1 3. Normalize result & check for over/underflow 1.0015 10 2 4. Round and renormalize if necessary 1.002 10 2 ECE331: Midterm Review 22

Floating-Point Multiplication Now consider a 4-digit binary example 1.000 2 2 1 1.110 2 2 2 (0.5 0.4375) 1. Add exponents Unbiased: 1 + 2 = 3 Biased: ( 1 + 127) + ( 2 + 127) = 3 + 254 127 = 3 + 127 2. Multiply significands 1.000 2 1.110 2 = 1.1102 1.110 2 2 3 3. Normalize result & check for over/underflow 1.110 2 2 3 (no change) with no over/underflow 4. Round and renormalize if necessary 1.110 2 2 3 (no change) 5. Determine sign: +ve ve ve 1.110 2 2 3 = 0.21875 ECE331: Midterm Review 23

Datapath With Control (no jumps) op rs rt rd addr/ func ECE331: Midterm Review 24