September 24 Test 1 review More programming

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

Goal: Write Programs in Assembly
ISA Issues; Performance Considerations. Testing / System Verilog: ECE385.
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.
Chapter 2 Instructions: Language of the Computer
Datorteknik DatapathControl bild 1 Designing a Single Cycle Datapath & Datapath Control.
331 W08.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 8: Datapath Design [Adapted from Dave Patterson’s UCB CS152.
1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic.
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.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
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.
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
CMPT 334 Computer Organization
순천향대학교 정보기술공학부 이 상 정 1 2. Instructions: Language of the Computer.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
1  1998 Morgan Kaufmann Publishers Machine Instructions: Language of the Machine Lowest level of programming, control directly the hardware Assembly instructions.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
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.
Computer Organization & Programming Chapter 6 Single Datapath CPU Architecture.
CHAPTER 6 Instruction Set Architecture 12/7/
 1998 Morgan Kaufmann Publishers MIPS arithmetic All instructions have 3 operands Operand order is fixed (destination first) Example: C code: A = B +
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
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.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Instruction Set Architecture Chapter 3 – P & H. Introduction Instruction set architecture interface between programmer and CPU Good ISA makes program.
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/
MIPS Instruction Set Advantages
CS2100 Computer Organisation
Instruction Set Architecture
MIPS Coding Continued.
ELEN 468 Advanced Logic Design
ECE3055 Computer Architecture and Operating Systems MIPS ISA
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
CS170 Computer Organization and Architecture I
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
CS170 Computer Organization and Architecture I
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Henk Corporaal TUEindhoven 2010
MIPS Instruction Encoding
ECE232: Hardware Organization and Design
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
The University of Adelaide, School of Computer Science
Systems Architecture I
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim
COMS 361 Computer Organization
Prof. Sirer CS 316 Cornell University
COMP541 Datapaths I Montek Singh Mar 18, 2010.
COMS 361 Computer Organization
COMS 361 Computer Organization
October 29 Review for 2nd Exam Ask Questions! 4/26/2019
MIPS Coding Continued.
Machine Instructions.
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
The Processor: Datapath & Control.
Instruction Set Architecture
Presentation transcript:

September 24 Test 1 review More programming Assignment 4 posted. Start EARLY. 12/3/2018 Comp 120 Fall 2001

Question 1 [10] Assume that multiply instructions take 12 cycles and account for 10% of the instructions in a typical program and that the other 90% of the instructions require an average of 4 cycles for each instruction. What percentage of time does the CPU spend doing multiplication? 12 * 0.1 / (12*0.1 + 4*0.9) = 25% 12/3/2018 Comp 120 Fall 2001

Question 2 [10] Consider a byte-addressable memory and an architecture that manipulates 2-byte words. What is the maximum number of words of memory available if the architecture has addresses that are 16 bits long? 2^16 bytes / (2 bytes/word) = 2^15 words = 32k 12/3/2018 Comp 120 Fall 2001

Question 3 [10] A ZIP disk holds 100 megabytes. A typical MP3 music file requires 128 kbits per second. How many minutes of music can you store on a single disk? 100 * 2^20 bytes * 2^3 bits/byte / (2^17 bits/sec * 60 sec/min) = 100*2^6/60 = 106.7 minutes 12/3/2018 Comp 120 Fall 2001

Question 4 1 [10] How many instructions that are 16 bits long fit in 32k bytes of memory? 32k / 2 = 16k 12/3/2018 Comp 120 Fall 2001

Question 5 1 [10] Two machines have the same clock rate. What can you say about their performance relative to one another? Nothing. They might have different ISA’s or different CPI’s. 12/3/2018 Comp 120 Fall 2001

Question 6 1 [10] A certain program executes 200 million instructions. On a 300MHz Pentium II it takes 3 seconds to run. What is the MIPS rating of the processor on this program? What is the average CPI? On a 500MHz Pentium III the program takes 1 second. What is the MIPS rating for this processor? What is the CPI? MIPS = 200/3 = 66.7, CPI = 300*3/200 = 4.5 MIPS = 200/1 = 200, CPI = 500*1/200 = 2.5 12/3/2018 Comp 120 Fall 2001

Question 7 [10] Consider the characteristics of two machines M1 and M2. M1 has a clock rate of 400Mhz. M2 has a clock rate of 500MHz. 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. How many millions of instructions per second (MIPS) does each machine execute on average? M1 MIPS = 400 / (0.4*2 + 0.3*3 + 0.2*4 + 0.1*5) = 133.3 M2 MIPS = 500 / (0.4*2 + 0.3*2 + 0.2*3 + 0.1*4) = 208.3 12/3/2018 Comp 120 Fall 2001

Question 8 1 [10] Which of the machines above is faster on average? By what factor? M2 is faster by a factor of 1.6 12/3/2018 Comp 120 Fall 2001

Question 9 [10] In a certain set of benchmark programs about every 4th instruction is a load instruction that fetches data from main memory. The time required for a load is 50ns. The CPI for all other instructions is 4. Assuming the ISA’s are the same, how much faster will the benchmarks run with a 1GHz clock than with a 500MHz clock? For 4 instructions the time is 50ns + 3*4/R, so the speedup is (50ns + 24ns) / (50ns + 12ns) = 1.19 or about 19%. 12/3/2018 Comp 120 Fall 2001

Question 10 1.[10] State Amdahl’s Law with an equation. Timproved = (Tunaffected + Taffected/improvement) 12/3/2018 Comp 120 Fall 2001

Grade Distribution 10~19: 1 20~29: 0 30~39: 2 40~49: 2 50~59: 3 10~19: 1 20~29: 0 30~39: 2 40~49: 2 50~59: 3 60~69: 4 70~79: 6 80~89: 13 90~99: 12 100: 2 READ THE BOOK! 12/3/2018 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 12/3/2018 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 12/3/2018 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? 12/3/2018 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. 12/3/2018 Comp 120 Fall 2001

Execution Example Program Counter Memory(32 bits) Memory(32 bits) 200 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers (32 bits) 6 1234 7 23 8 120 9 -314159 10 316 Instruction Register (32 bits) op rs rt rd shft func 6 bits 5 bits R op rs rt offset 6 bits 5 bits 16 bits I 12/3/2018 Comp 120 Fall 2001

Execution Example: Fetch(200) Program Counter Memory Memory 200 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers 6 1234 7 23 8 120 9 -314159 10 316 Instruction Register R 100011 01000 01001 0000000000000000 35 8 9 I 12/3/2018 Comp 120 Fall 2001

Execution Example: Execute(200) Program Counter Memory Memory 204 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers 6 1234 7 23 8 120 9 21 10 316 Instruction Register R 100011 01000 01001 0000000000000000 35 8 9 I 12/3/2018 Comp 120 Fall 2001

Execution Example: Fetch(204) Program Counter Memory Memory 204 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers 6 1234 7 23 8 120 9 21 10 316 Instruction Register 000000 01001 00111 00000 100000 9 7 32 R I 12/3/2018 Comp 120 Fall 2001

Execution Example: Execute(204) Program Counter Memory Memory 208 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers 6 1234 7 23 8 120 9 44 10 316 Instruction Register 000000 01001 00111 00000 100000 9 7 32 R I 12/3/2018 Comp 120 Fall 2001

Execution Example: Fetch(208) Program Counter Memory Memory 208 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 55 132 89 Registers 6 1234 7 23 8 120 9 44 10 316 Instruction Register R 101011 01000 01001 0000000000001000 43 8 9 I 12/3/2018 Comp 120 Fall 2001

Execution Example: Execute(208) Program Counter Memory Memory 212 200 10001101000010010000000000000000 LW $9, 0($8) 204 00000001001001110100100000100000 ADD $9,$9,$7 208 10101101000010010000000000001000 SW $9, 8($8) 212 112 8 116 13 120 21 124 34 128 44 132 89 Registers 6 1234 7 23 8 120 9 44 10 316 Instruction Register R 101011 01000 01001 0000000000001000 43 8 9 I 12/3/2018 Comp 120 Fall 2001

Control Decision making instructions alter the control flow, i.e., change the "next" instruction to be executed MIPS conditional branch instructions: bne $t0, $t1, Label beq $t0, $t1, Label Example: if (i==j) h = i + j; bne $s0, $s1, Label add $s3, $s0, $s1 Label: .... 12/3/2018 Comp 120 Fall 2001

Control MIPS unconditional branch instructions: j label Example: if (i!=j) beq $s4, $s5, Lab1 h=i+j; add $s3, $s4, $s5 else j Lab2 h=i-j; Lab1: sub $s3, $s4, $s5 Lab2: ... 12/3/2018 Comp 120 Fall 2001

So far: 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 bne $s4,$s5,L Next instr. is at Label if $s4 != $s5 beq $s4,$s5,L Next instr. is at Label if $s4 = $s5 j Label Next instr. is at Label Formats: R I J op rs rt rd shamt funct op rs rt 16 bit address op 26 bit address 12/3/2018 Comp 120 Fall 2001

Control Flow Board work: Binary Numbers We have: beq, bne, what about Branch-if-less-than? New instruction: if $s1 < $s2 then $t0 = 1 slt $t0, $s1, $s2 else $t0 = 0 Can use this instruction to build "blt $s1, $s2, Label" — can now build general control structures Note that the assembler needs a register to do this, — there are policy of use conventions for registers Board work: Binary Numbers 12/3/2018 Comp 120 Fall 2001

Policy of Use Conventions 12/3/2018 Comp 120 Fall 2001