1 הקדמה מה נלמד ? כיצד מחשב בנוי. כיצד לנתח ביצועי מחשב. נושאים המשפיעים על מעבדים חדשים (cache, pipeline ) הספר המלווה Computer Organization & Design.

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

Goal: Write Programs in Assembly
Lecture 5: MIPS Instruction Set
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.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
Chapter 2 Instructions: Language of the Computer
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Embedded Systems in Silicon TD5102 MIPS Instruction Set Architecture Henk Corporaal Technical University.
1 Chapter 3: Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g.,
1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic.
1 Warning! Unlike the previous lessons, for today's lesson you will have to listen, think and even understand (for the exam, of course). Individuals with.
MIPS Architecture CPSC 321 Computer Architecture Andreas Klappenecker.
1 Chapter Introduction Language of the Machine We’ll be working with the MIPS instruction set architecture –similar to other architectures developed.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
1 CSE SUNY New Paltz Chapter 3 Machine Language Instructions.
1 / 52 איפה אנחנו ולאן ממשיכים?? מבנה מחשבים  Arithmetic Single/multicycle Datapaths IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
RISC Concepts, MIPS ISA and the Mini–MIPS project
1 הקדמה מה נלמד ? כיצד מחשב בנוי. כיצד לנתח ביצועי מחשב. נושאים המשפיעים על מעבדים חדשים (cache, pipeline ) הספר המלווה Computer Organization & Design.
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.
1 איפה אנחנו ולאן ממשיכים?? מבנה מחשבים  Arithmetic Single/multicycle Datapaths IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB IFetchDcdExecMemWB.
1 שלבי ביצוע הוראת מכונה (1) FETCH = קרא הוראה מהזיכרון ע " פ הכתובת שמכיל ה -PC. (2) DECODE = פענח את הפקודה וקרא את האוגרים הנחוצים ( אחד או שניים ).
1  2004 Morgan Kaufmann Publishers Chapter 2. 2  2004 Morgan Kaufmann Publishers Instructions: Language of the Machine We’ll be working with the MIPS.
Processor Design 5Z032 Instructions: Language of the Computer Henk Corporaal Eindhoven University of Technology 2011.
שלבי ביצוע הוראת מכונה (1) FETCH = קרא הוראה מהזיכרון ע " פ הכתובת שמכיל ה -PC. (2) DECODE = פענח את הפקודה וקרא את האוגרים הנחוצים ( אחד או שניים ). (3)
1 ׃1998 Morgan Kaufmann Publishers פקודת ה- jump 4 bits 26 bits 2 bits 00 : כתובת קפיצה במילים : כתובת קפיצה בבתים … …
MIPS Instruction Set Advantages
ISA-2 CSCE430/830 MIPS: Case Study of Instruction Set Architecture CSCE430/830 Computer Architecture Instructor: Hong Jiang Courtesy of Prof. Yifeng Zhu.
순천향대학교 정보기술공학부 이 상 정 1 2. Instructions: Language of the Computer.
1 EGRE 426 Fall 09 Handout Pipeline examples continued from last class.
1 CS/EE 362 Hardware Fundamentals Lecture 10 (Chapter 3: Hennessy and Patterson) Winter Quarter 1998 Chris Myers.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
1  1998 Morgan Kaufmann Publishers Machine Instructions: Language of the Machine Lowest level of programming, control directly the hardware Assembly instructions.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
1 Copyright 1998 Morgan Kaufmann Publishers, Inc. All rights reserved. MIPS Assembly language In computer programs we have : Data Instructions (Arithmetic.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA.
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.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
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.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic3: Instructions, The Language of the Machine José Nelson Amaral.
1 ECE3055 Computer Architecture and Operating Systems Lecture 3 MIPS ISA Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia.
MIPS Instruction Set Advantages
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
Computer Architecture & Operations I
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
CS170 Computer Organization and Architecture I
The University of Adelaide, School of Computer Science
MIPS coding.
Instructions - Type and Format
Henk Corporaal TUEindhoven 2010
ECE232: Hardware Organization and Design
September 24 Test 1 review More programming
COMS 361 Computer Organization
MIPS Coding Continued.
MIPS coding.
Machine Instructions.
Instruction Set Architecture
Presentation transcript:

1 הקדמה מה נלמד ? כיצד מחשב בנוי. כיצד לנתח ביצועי מחשב. נושאים המשפיעים על מעבדים חדשים (cache, pipeline ) הספר המלווה Computer Organization & Design The hardware/software interface, David A. Patterson and John L. Hennsy. Second Edition

2 שפת מכונה שפת מכונה - הפקודות שהמחשב מכיר. אסמבלי - נוח יותר לקריאה. - אבסטרקציה. - מעבר חד חד ערכי משפת המכונה. שפת C - נוח יותר לתיכנות. - לא מעבר חד חד ערכי. - תלוי קומפיילר ואופטימיזציה - Portable מתי מתכנתים באסמבלי ?

3 Instruction Set Architecture דמיון רב בין שפות המכונה השונות נלמד את שפת המכונה של מעבד ה- MIPS שפותח בתחילת שנות ה- 80 ( משתמשים בו ב- Silicon Graphics,NEC,Sony ). RISC v. CISC –Reduced Instruction Set Computer - MIPS – Complex Instruction Set Computer המוטו “ פחות זה יותר “

4 כלל תכנון מספר 1: Simplicity favors Regularity פעולות אריתמטיות MIPS addi a,b,100 # a=b+100 add a,b,c # a=b+c 8086 ADD EAX,B # EAX= EAX+B

5 כלל תכנון מס’ 2: Smaller is faster פעולות אריתמטיות רק על רגיסטרים. האופרנדים יכולים להיות רגיסטר או קבוע אחד. סה”כ יש 32 רגיסטרים. spilling רגיסטר word = 32 bits = 4 bytes קונבנציות $1,$2 … $s0,$s C משתנים של $t1,$t2 … - משתנים זמניים דוגמא: f=(g+h)-(k+j) #$s0=f, $s1=g, $s2=h, $s3=k, $s4=j add $t0,$s1,$s2 add $t1,$s3,$s4 sub $s0, $t0, $t1

6 Policy of Use Conventions

7 הזיכרון הזיכרון - מערך גדול. כתובת לזיכרון - אינדקס למערך. Byte addressing - האינדקס בבתים. גודל הזיכרון המכסימלי 2 30 words = 2 32 bytes bits of data

8 פניה לזיכרון פקודות Load and Store טוענים מילה אבל הכתובת בזיכרון היא בבתים - LW lw $s1,100($s2) # $s1=Memory[$s2+100] sw $s1,100($s2) # Memory[$s2+100]=$s1

9 קריאה של byte ישנם גם פקודות כמו (lb (load byte ו - (sb(store byte שימושי לקריאת char: גודל byte ב - ASCII American Standard Code For information Interchange ב - Unicode - גודל char הוא 2 בתים.

10 ASCII

11 גישה לזיכרון while (save[i]!=k) do i=i+j ; save: array [ ] of word Loop: muli $9,$19,4 # Temporary reg $9:=i*4 lw $8,save($9) # Temporary reg $8:=save[i] bne $8,$21,Exit # Goto Exit if save[i]<>k add $19,$19,$20 # i:=i+j j Loop # Goto Loop bits of data Save

12 הפקודות ב- MIPS בגודל זהה של 32 ביט. ב פקודות בגודל משתנה מ-1 עד ל-17 בתים. : דוגמא add $s1,$s2,$s3 # $s1=$17,$s2=$18, $s3=$19 פורמט הפקודה מסוג R-type op rs rt rdshamtfunct op - opecoders - register source rt- register source no 2rd - register destination funct - function shamt - shift amount שפת המכונה

13 צמצום מספר סוגי הפקודות השונים. דמיון בין הפקודות. Example: lw $s1, 32($s2) # $s1 =$17, $s2= op rs rt 16 bit number כלל תכנון מס’ 3 : תכנון טוב דורש לעיתים פשרות op rs rt rdshamtfunct op rs rt 16 bit address op 26 bit address RIJRIJ

14 התוכנית נשמרת בזיכרון בדיוק כמו נתונים ביצוע תוכנית רגיסטר מיוחד PC - Program Counter שומר את כתובת הפקודה הבאה. קוראים מילה שלמה מהזיכרון. מקדמים את ה - PC. ProcessorMemory memory for data, programs, compilers, editors, etc. התוכנית בזיכרון

15 Jump - קפיצה “ אבסולוטית ” ללא תנאים j label Branch - קפיצה יחסית מותנת bne $1,$2,label# $1!=$2 go to 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:... Branch vs Jump

16 Instructions: bne $t4,$t5,Label Next instruction is at Label if $t4!= $t5 beq $t4,$t5,Label Next instruction is at Label if $t4 = $t5 j Label Next instruction is at Label Formats: מכאן branch - קפיצה יחסית בגבולות 16^2 מילים. הנחה: רוב ה- branches יהיו קפיצות לוקאליות. Beq $s1,$s2,25 # if ($s1 ==$s2) go to PC *4 op rs rt 16 bit address op 26 bit address IJIJ Addresses in Branches and Jumps

17 דוגמא לקידוד

18 כלל שחשוב לזכור : מקודדים MIPS באסמבלי של כתובת code במילים כתובת data בבתים ניגש לזיכרון הוא מבקש את הכתובת בבתים MIPS כאשר מעבד

19 if $s1 < $s2 then $t0 = 1 slt $t0, $s1, $s2 else $t0 = 0 ניתן לבנות את blt: blt $s0,$s1, Less slt $t0,$s0,$s1 # $t0 gets 1 if $s0<$s1 bne $t0,$zero, Less # go to Less if $t0 != 0 blt היא Psedoinstruction Branch-if-less-than?

20 כלל תכנון מס’ 4 : בנה את המקרה השכיח - מהיר הרבה פעולות ארתמטיות מתבצעות עם קבועים קטנים. קבועים גדולים addi $29, $29, lui $t0, ori $t0,$t0,

21 לסיכום

22 RISC v. CISC I - מספר פקודות בתוכנית T - אורך מחזור שעון CPI - מספר מחזורים לפקודה RISC: I T CPI CISC: I T CPI

23 תרגיל שאלה 1: לפניך קוד הכתוב ב-C, ושני תרגומים שלו לשפת האסמבלי של MIPS: while (save[i]!=k) do i=i+j ; save:array [ ] of word $19 מתפקד כ-i, $20 כ-j ו-$21 כ-k. תרגום ראשון: Loop: muli $9,$19,4 # Temporary reg $9:=i*4 lw $8,save($9) # Temporary reg $8:=save[i] bne $8,$21,Exit # Goto Exit if save[i]<>k add $19,$19,$20 # i:=i+j j Loop # Goto Loop Exit:

24 המשך תרגיל תרגום שני: muli $9,$19,4# Temporary reg $9:=i*4 lw $8,save($9)# Temporary reg $8:=save[i] bne $8,$21,Exit# Goto Exit if save[i]<>k Loop: add $19,$19,$20# i:=i+j muli $9,$19,4# Temporary reg $9:=i*4 lw $8,save($9)# Temporary reg $8:=save[i] beq $8,$21,Loop# Goto Loop if save[i]=k Exit: שאלה: בהנחה שהלולאה מתבצעת 10 פעמים, מה מספר הפקודות שמתבצעות בכל אחד מהתרגומים?

25 Compiler A.asm B.asm compiler A.obj B.obj linker C.lib (c.obj) P.exe loader Memory

26 Assembler B.asm compiler A.obj B.obj s:.word 3,4 j k lw $1,s ($2) k: add $1,$2,$3 m:.word 2 sw 7, m($3) A.asm 3 4 j 2 lw $1,0($2) add $1,$2,$3 2 sw 7,0($3) sw 7,0($3) j 3 lw $1,4($2) add $1,$2,$3 linker P.exe

27 קובץ Object ב- Unix Object file header text segment data segment relocation information symbol table debugging information

28 מבנה הזיכרון מחסנית משתנים דינמים משתנים סטטים קוד שמור