September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

Goal: Write Programs in Assembly
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
Chapter 2.
Chapter 2 Instructions: Language of the Computer Part III.
1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic.
Instructions Set Bo Cheng Instruction Set Design An Instruction Set provides a functional description of a processor. It is the visible.
9/16/2004Comp 120 Fall September 16 Assignment 4 due date pushed back to 23 rd, better start anywayAssignment 4 due date pushed back to 23 rd, better.
331 W02.1Spring 05 Announcements  HW1 is due on this Friday  Appendix A (on CD) is very helpful to HW1.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
The Processor 2 Andreas Klappenecker CPSC321 Computer Architecture.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
1  1998 Morgan Kaufmann Publishers Chapter 3 Text in blue is by N. Guydosh Updated 1/27/04 Instructions: Language of the Machine.
ECE 4436ECE 5367 ISA I. ECE 4436ECE 5367 CPU = Seconds= Instructions x Cycles x Seconds Time Program Program Instruction Cycle CPU = Seconds= Instructions.
1  2004 Morgan Kaufmann Publishers Chapter 2. 2  2004 Morgan Kaufmann Publishers Instructions: Language of the Machine We’ll be working with the MIPS.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
순천향대학교 정보기술공학부 이 상 정 1 2. Instructions: Language of the Computer.
1 CS/EE 362 Hardware Fundamentals Lecture 10 (Chapter 3: Hennessy and Patterson) Winter Quarter 1998 Chris Myers.
1 Computer Architecture COSC 3430 Lecture 3: Instructions.
1  1998 Morgan Kaufmann Publishers Machine Instructions: Language of the Machine Lowest level of programming, control directly the hardware Assembly instructions.
Chapter 2 Instructions: Language of the Computer Part I.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
CWRU EECS 3221 Language of the Machine EECS 322 Computer Architecture Instructor: Francis G. Wolff Case Western Reserve University.
Computer Architecture CSE 3322 Lecture 2 NO CLASS MON Sept 1 Course WEB SITE crystal.uta.edu/~jpatters.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
Computer Organization Rabie A. Ramadan Lecture 3.
EE472 – Spring 2007P. Chiang, with Slide Help from C. Kozyrakis (Stanford) ECE472 Computer Architecture Lecture #3—Oct. 2, 2007 Patrick Chiang TA: Kang-Min.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
1  1998 Morgan Kaufmann Publishers Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow.
CHAPTER 2 Instruction Set Architecture 3/21/
Computer Architecture & Operations I
Computer Architecture & Operations I
MIPS Assembly.
A Closer Look at Instruction Set Architectures
COMPUTER ARCHITECTURE & OPERATIONS I
Instruction Set Architecture
Morgan Kaufmann Publishers
ECE3055 Computer Architecture and Operating Systems MIPS ISA
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
MIPS Assembly.
CS170 Computer Organization and Architecture I
CSCI206 - Computer Organization & Programming
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
The University of Adelaide, School of Computer Science
Systems Architecture Lecture 5: MIPS Instruction Set
Henk Corporaal TUEindhoven 2010
MIPS assembly.
The University of Adelaide, School of Computer Science
September 24 Test 1 review More programming
Computer Architecture
COMS 361 Computer Organization
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
COMS 361 Computer Organization
COMS 361 Computer Organization
Machine Instructions.
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CPU Structure CPU must:
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Instruction Set Architecture
Presentation transcript:

September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim 2/22/2019 Comp 120 Fall 2001

2 2. [10] Consider a byte-addressable memory and an architecture that manipulates 4-byte words. What is the maximum number of words of memory available if the architecture has 13 bit addresses? 2^13 bytes / (2^2 bytes/word) = 2^11 words = 2048 2/22/2019 Comp 120 Fall 2001

3 3. [5] How many bits are in a megabyte? 2^20 bytes/megabyte * 2^3 bits/byte = 2^23 bits/megabyte = 8 megabits = 8,388,608 2/22/2019 Comp 120 Fall 2001

4 4. [3] How many MIPS instructions fit in 32k bytes of memory? 32 = 2^5 k = 2^10 32k = 2^5 * 2^10 = 2^15 MIPS instructions are 4 bytes = 2^2 2^15 / 2^2 = 2^13 instructions = 8k = 8192 2/22/2019 Comp 120 Fall 2001

5 (CPI * I * T) (CPI * I / R) (I / (M * 10^6)) (C * T) (C / R) 5. [12] Give as many different formulas as you can for execution time using the following variables. Each equation should be minimal; that is, it should not contain any variable that is not needed. CPI, R=clock rate, T=cycle time, M=MIPS, I=number of instructions in program, C=number of cycles in program. (CPI * I * T) (CPI * I / R) (I / (M * 10^6)) (C * T) (C / R) (C / (CPI * M * 10^6)) 2/22/2019 Comp 120 Fall 2001

6 6. [10] Consider the characteristics of two machines M1 and M2. M1 has a clock rate of 500Mhz. M2 has a clock rate of 600MHz. There are 4 classes of instructions (A-D) in the instruction set. In a set of benchmark programs, the frequency of each class of instructions is shown in the table. What is the average CPI for each machine? M1 = 0.4*2 + 0.25*3 + 0.25*3 + 0.1*5 = 2.8 M2 = 0.4*2 + 0.25*2 + 0.25*3 + 0.1*4 = 2.45 Instruction Class Frequency M1 CPI M2 CPI A 40% 2 B 25% 3 C D 10% 5 4 2/22/2019 Comp 120 Fall 2001

7 [10] How much faster is M2 than M1? (2.8 / 500) / (2.45 / 600) = 1.37 37% faster. 2/22/2019 Comp 120 Fall 2001

8 8. [5] What is the cycle time of each machine? M1 = 1/500MHz = 2ns = 2*10^-9 s M2 = 1/600MHz = 1.67 ns = 1.67 * 10^-9 s 2/22/2019 Comp 120 Fall 2001

9 9. [10] If we make a low power version of M2 with a lower clock rate, what clock rate will we need to match the performance of M1? 2.8 / 500 = 2.45 / X X = 437.5MHz 2/22/2019 Comp 120 Fall 2001

10 10. [15] You are going to enhance a machine, and there are two possible improvements: either make multiply instructions run 4 times faster than before, or make memory access instructions run 2 times faster than before. You repeatedly run a program that takes 100 seconds to execute. Of this time, 20% is used for multiplication, 50% for memory access instructions, and 30% for other tasks. What will be the speedup if you improve only multiplication? What will be the speedup if you improve only memory access? What will be the speedup if both improvements are made? Speedup if we improve only multiplication = 100 / (30 + 50 + 20/4) = 100/85 = 1.18 Speedup if we only improve memory access = 100 / (30 + 50/2 + 20) = 100/75 = 1.33 Speedup if both improvements are made = 100 / (30 + 50/2 + 20/4) = 100/60 =1.67 2/22/2019 Comp 120 Fall 2001

12 12. [3] How many bytes of memory are used by an array of 1000 pointers on the MIPS architecture? 1000 pointers * 32 bits/address / 8 bits/byte = 4000 bytes 2/22/2019 Comp 120 Fall 2001

Grade Distribution 2/22/2019 Comp 120 Fall 2001

SPIM Demonstration 2/22/2019 Comp 120 Fall 2001

Programming the Machine Chapter 3 Programming the Machine 2/22/2019 Comp 120 Fall 2001

Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We’ll be working with the MIPS instruction set architecture similar to other architectures developed since the 1980's used by NEC, Nintendo, Silicon Graphics, Sony Design goals: maximize performance and minimize cost, reduce design time 2/22/2019 Comp 120 Fall 2001

MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B + C MIPS code: add $s0, $s1, $s2 (associated with variables by compiler) 2/22/2019 Comp 120 Fall 2001

MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code: add $t0, $s1, $s2 add $s0, $t0, $s3 sub $s4, $s5, $s0 Operands must be registers, only 32 registers provided Design Principle: smaller is faster. Why? 2/22/2019 Comp 120 Fall 2001

Registers vs. Memory Arithmetic instructions operands must be registers, — only 32 registers provided Compiler associates variables with registers What about programs with lots of variables? Processor I/O Control Datapath Memory Input Output 2/22/2019 Comp 120 Fall 2001

Memory Organization Viewed as a large, single-dimension array, with an address. A memory address is an index into the array "Byte addressing" means that the index points to a byte of memory. 8 bits of data 1 8 bits of data 2 8 bits of data char memory[256*1024*1024]; 3 8 bits of data 4 8 bits of data 5 8 bits of data 6 8 bits of data ... 2/22/2019 Comp 120 Fall 2001

Memory Organization Bytes are nice, but most data items use larger "words" For MIPS, a word is 32 bits or 4 bytes. 232 bytes with byte addresses from 0 to 232-1 230 words with byte addresses 0, 4, 8, ... 232-4 Words are aligned i.e., what are the least 2 significant bits of a word address? 32 bits of data 4 32 bits of data Registers hold 32 bits of data 8 32 bits of data 12 32 bits of data ... 2/22/2019 Comp 120 Fall 2001

Endians? What order are the bytes inside the word? Is byte 0 the high-order bits of word 0? Or is it the low order bits? “Big Endian” byte 0 is high-order bits [0 1 2 3] Macintosh, SPARC “Little Endian” byte 0 is low-order bits [3 2 1 0] Intel, DECStation When would I care? 2/22/2019 Comp 120 Fall 2001

Instructions Load and store instructions Example: C code: A[8] = h + A[8]; MIPS code: lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3) Store word has destination last Remember arithmetic operands are registers, not memory! 2/22/2019 Comp 120 Fall 2001

So far we’ve learned: MIPS — loading words but addressing bytes — arithmetic on registers only Instruction Meaning add $s1, $s2, $s3 $s1 = $s2 + $s3 sub $s1, $s2, $s3 $s1 = $s2 – $s3 lw $s1, 100($s2) $s1 = Memory[$s2+100] sw $s1, 100($s2) Memory[$s2+100] = $s1 2/22/2019 Comp 120 Fall 2001

Machine Language Board work: Binary Numbers Instructions, like registers and words of data, are also 32 bits long Example: add $t0, $s1, $s2 registers have numbers, $t0=8, $s1=17, $s2=18 Instruction Format: 000000 10001 10010 01000 00000 100000 op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Board work: Binary Numbers 2/22/2019 Comp 120 Fall 2001

Machine Language Consider the load-word and store-word instructions, What would the regularity principle have us do? New principle: Good design demands a compromise Introduce a new type of instruction format I-type for data transfer instructions other format was R-type for register Example: lw $t0, 32($s2) 35 18 9 32 op rs rt 16 bit number Where's the compromise? 2/22/2019 Comp 120 Fall 2001

Stored Program Concept Instructions are bits Programs are stored in memory — to be read or written just like data Fetch & Execute Cycle Instructions are fetched and put into a special register Bits in the register "control" the subsequent actions Fetch the “next” instruction and continue Processor Memory memory for data, programs, compilers, editors, etc. 2/22/2019 Comp 120 Fall 2001