Tutorial #10 MIPS commands

Slides:



Advertisements
מצגות קשורות
אוגרים ומונים – Registers & Counters
Advertisements

אוגרים ומונים – Registers & Counters
קורס ניהול ידע מפגש 3 - פורטלים 2know.kmrom.com.
מבנה מחשבים ספרתיים זיכרון מטמון - המשך
תרגול מס' 1: מנהלות חזרה על ארכיטקטורת ה- MIPS
תגובות חמצון -חיזור ודוגמאות מחיי היום יום
תוכנה 1 תרגול 13 – סיכום.
Trends in Periodic Table Properties
על הסתיו ועוד, בגן ה"תמרים" בעכו שם הגננות: מירב קדוש אלה נאמן
תרגול 11 מלכודות בניית ה-Debugger
Operating Systems 2019, I. Dinur , D. Hendler and M. Kogan-Sadetsky
לולאות Department of Computer Science-BGU 19 יולי 19.
The Partnership tree in ECP- Austin עץ השותפות באוסטין
טקס פתיחת "גינת השותפות" בעכו
Isotopes and Atomic Mass
OOO Execution of Memory Operations
Marina Kogan Sadetsky –
אלקטרושליליות ופולריות הקשר
משואה כימית של שריפת פחם (תגובה עם חמצן)
Jump tables, review questions
מודל דחיית זוגות אלקטרונים של קליפת הערכיות
תכנות בשפת C תרגול 11 רשימות מקושרות מבנים
הפרויקט השנתי בהנדסת תוכנה Git and GitHub
Present Perfect Simple
תירגול 11: מיונים וחיפוש בינארי
תרכובות עם יונים פוליאטומים בחיי היום יום
יסודות מבני נתונים תרגול 13: עץ פורש מינימלי - Minimum Spanning Tree (MST)
זאב וקסמן פישר מנהל ישראגריד 15/11/11
חוק שימור החומר The Law of Conservation of Mass indicates that in an
Out Of Order Execution (Part 1)
The Dolphin Class International Forest of Support
חג פורים שמח ומבדח מגן פרפר....תפן שם הגננת: מאיה פלס
מבני נתונים תרגול 3 ליאור שפירא.
OOO Execution of Memory Operations
Akiba Academy of Dallas Presents
Short Documentation from “Yom Hatzmaut” activities in ECP – Austin TX תיעוד קצר מהפעילויות בגיל הרך בבית הספר היהודי באוסטין טקסס לקראת יום העצמאות.
האם אתם יודעים כיצד כותבים מגילה?
Carry Save Adder (CSA).
מוטיבציה והשוואה בין מבני נתונים שלמדנו
“ The Borrowed Hanukkah Latkes” Dalmatian class-Austin
Direction of induced current
מבוסס על שקפים מאת יאן ציטרין
זיכרון מטמון 1 מבנה מחשבים ספרתיים
זיכרון מטמון 2 מבנה מחשבים ספרתיים
שם הגננת: עדנה סרי The teacher: Edna Seri
הכנה למבחן.
מבנה מחשבים ספרתיים זכרון וירטואלי מבוסס על תרגול של מורן גביש
Computer Architecture and System Programming Laboratory
בתרכובות יוניות יש קשרים יונים
תיעוד מפעילויות ראש השנה בגן "פרפר נחמד" –עכו-תש"ע
Branch Prediction בעריכת אורן קצנגולד Updated by Franck Sala.
Branch Prediction Oren Katzengold, Franck Sala, Elad Shtiegmann.
Elements and Symbols יסודות וסמלים מהם יסודות? gold carbon aluminum
Marina Kogan Sadetsky –
Emech at 1 + W = Emech at 2 mgh1 = mgh2
What is Chemistry? מהי כימיה? Chemistry is the study of matter and its
קומבינטוריקה למדעי-המחשב EULER GRAPHS גרפים אויילרים
מבוא למדעי המחשב סמסטר ב' – 2008 מרצה: יעל סיגל מתרגל: ענבל בודובסקי.
הכנת שמן זית וארכיאולוגיה בגן "ארגמן" עכו Preparing olive oil and Archeology at “Argaman” kindergarten in Akko שם הגננת: נטלי גוריבודסקי שם הסייעת :
גן "יסמין "עכו שם הגננת: מרגלית פוגל שם הסייעת: זיוה אוזן
“Augustus and his smile” “"חיוכו של נסיך
מבוסס על שקפים מאת יאן ציטרין
תרגול מס' 2: Data and Control Hazards
OOO Execution of Memory Operations
מבנה מחשבים ספרתיים תרגול מס' 4: זכרון מטמון 2.
שם הגננת:אתי ברכפלד קיבוץ סער
עקרונות תכנות מונחה עצמים תרגול 9:C++ - תרגילים
יינון המים In the ionization of water,
Engineering Programming A
תמליל מצגת:

Tutorial #10 MIPS commands 234262 Tutorial #10 MIPS commands 234262 – © Yohai Devir 2007 Technion - IIT

MIPS overview MIPS is a simple processor: All arithmetic operations are done with registers only. Memory access is done with only two instructions – LW\ SW. The MIPS is a 32-bit machine. The instructions are 32-bits long. Register file (RF), with 32 registers of 32 bits each (5 bit for the number) Memory address size – 32 bits. We’ll work in resolution of words – 32 bit each. 234262 – © Yohai Devir 2007 Technion - IIT

Registers There are registers which are denoted by R0, R1,…R31. Register 0 is read-only and its value is 0 (R0 ≡ 0). The PC (Program Counter) is a special register. The PC points to the next instruction to be executed. In some places register K is marked as $K (i.e. R8 ≡ $8) 234262 – © Yohai Devir 2007 Technion - IIT

Memory (maximal) size 230 words of 32 bits each. Each word has a 32-bit address, the two LSB bits of the address are ’00’. Memory can be accessed by LW or SW commands only. 234262 – © Yohai Devir 2007 Technion - IIT

MIPS - מבנה כללי MEM 234262 – © Yohai Devir 2007 Technion - IIT 5 IR[d] 5 IR[t] 5 IR[s] 4 NREG1 WDATA 5 Rs Rt 6 12 IR[OP+FUN] NREG2 16 IR[IM] WNREG ZERO REG FILE 4 SIGN EXT C1 C3 WR I T E 6 IR[OP] ALUout B P C 1 2 IR[XI] 26 PC[31:28] C2 R E A D ADDR MEMout MEM A L U 234262 – © Yohai Devir 2007 Technion - IIT

הבקר 234262 – © Yohai Devir 2007 Technion - IIT C1 6 IR[OP] R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U MEM REG FILE I R M 6 M 3 M 4 234262 – © Yohai Devir 2007 Technion - IIT

ALU C3 ZERO A L U ALUout 234262 – © Yohai Devir 2007 Technion - IIT

יחידת ה- MEMORY MEM 234262 – © Yohai Devir 2007 Technion - IIT R E A D WR I T E ADDR MEMout MEM WDATA 234262 – © Yohai Devir 2007 Technion - IIT

יחידת ה- RF 234262 – © Yohai Devir 2007 Technion - IIT WDATA WNREG WR I T E WDATA WNREG NREG1 NREG2 Rs Rt 31*32 WRITE NREG1 REG FILE Rs NREG2 Rt WNREG WDATA 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Dima Elenbogen 2010 Technion - IIT מבנה ה- RF Rs R31 R1 Nreg1 נתב כתיבה נתב קריאה #1 נתב קריאה #2 Nreg2 WNreg WData WRITE Rt הערה: הנתבים צירופיים!

Instructions 3 types of instructions, each kind with a fixed structure: Type R (Register) Type I (Immediate) Type J (Jump) 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לכל הפקודות – שלב fetch IR ← Mem[PC] PC ← PC + 4 M 5 M 1 A L U P C M 2 ADDR MEMout MEM WDATA ALUout I R M 6 4 ALUout

Type I OP Rs Rt IM OPeration Source \ Target Registers IMmediate 6 bit 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT BNE R31,R8,loop1 OP Rs Rt IM 4 31 8 ? 6 bit 5 bit 16 bit Branch on Not Equal Semantic: if R31≠R8, the next instruction to be executed is the on which is stored in the memory at label ‘loop1’ BEQ branches if EQual

BNE PCnew  (BNEaddr +4) (BNEaddr ) + IM x 4 We want to branch to address 00…001000. However, this a 32bit address while having only 16bit of IM. Most branches are to “nearby” addresses.  We can put address relative to the PC. 2 LSB bits are ’00 (Why?)  No need to specify the 2 LSBs. We’ll see this later: After bringing the intruction (before really reading it) the PC is incremented in 4 bytes. PCnew  (BNEaddr +4) (BNEaddr ) + IM x 4 234262 – © Yohai Devir 2007 Technion - IIT

לכל הפקודות – שלב decode 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לכל הפקודות – שלב decode C1 is decoding IR[OP] Rs is being read Rt is being read BPC ← PC + SX(Imm)*4 C1 6 IR[OP] B P C ALUout M 5 6 A L U 5 IR[s] Rs NREG1 REG FILE 5 IR[t] NREG2 Rt ALUout I R 16 IR[IM] 4 SIGN EXT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT BNE R31,R8,loop1 Fetch Decode 3- EX) if (!zero) PC ← BPC C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R Rt M 6 4 SIGN EXT 16 IR[IM] 4 ALUout

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Type R OP Rs Rt Rd shamt func 6 bit 5 bit OPeration Source \ Target \ Destination Register SHift AMounT FUNCtion Rs מיועד לקריאה בלבד Rt מיועד לקריאה ולכתיבה (לכתיבה בחלק של פקודות מסוג I) Rd מיועד לכתיבה בלבד ומופיע בפקודות מסוג R בלבד

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

ADD R11,R22,R31 22 31 11 32 OP Rs Rt Rd shamt func 22 31 11 32 6 bit 5 bit Semantic: R11  R22 + R31 OP Rs Rt Rd shamt func 6 bit 5 bit OP Rs Rt Rd shamt func 000000 10110 11111 01011 00000 100000 6 bit 5 bit 234262 – © Yohai Devir 2007 Technion - IIT

פקודה מסוג R – add R11,R22,R31 MEM A L U 5 IR[s] NREG1 REG FILE Rs P C M 2 ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R Rt M 6 M 3 WNREG 5 IR[d] 4 M 4 WDATA ALUout 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT פקודה מסוג R – add R11,R22,R31 Fetch Decode 3- EX) ALUout <= Rs + Rt 4-WB) Rd ← ALUout 12 IR[OP+FUN] C3 M 5 M 1 A L U P C M 2 ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R M 3 Rt M 6 WNREG 5 IR[d] 4 M 4 WDATA ALUout

פקודה מסוג I – addi R11,R22,-12 8 22 11 -12 MEM OP Rs Rt IM 6 bit 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] I R M 6 M 3 WNREG 4 M 4 WDATA SIGN EXT 16 IR[IM] ALUout 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT פקודה מסוג I – addi R11,R22,-12 Fetch Decode 3- EX) ALUout <= Rs + SX(Imm) 4-WB) Rt ← ALUout M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] I R M 6 M 3 WNREG 4 M 4 WDATA SIGN EXT 16 IR[IM] ALUout

LW R23,300(R3) OP Rs Rt IM 35 3 23 300 6 bit 5 bit 16 bit Load Word Semantic: Read the word located in the memory address of [R3] + 300 (not 303 !!!) and write it to R23 NOTE: Rs is the Base register Rt is the register to write to. 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT פקודה LW – LW R23, 300(R3) Fetch Decode 3- EX) ALUout <= Rs + SX(Imm) 4-MEM) MEMout <= Mem[ALUout] 5-WB) Rt ← MEMout M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] I R Rt M 6 M 3 WNREG 4 M 4 WDATA SIGN EXT 16 IR[IM] ALUout

SW R7,200(R6) OP Rs Rt IM 43 6 7 200 6 bit 5 bit 16 bit Load Word Semantic: Writes the word located in R7 to the memory address of [R6] + 200 (not 206!!!) NOTE: Rs is the Base register Rt is the read from. 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT פקודה SW – SW R7, 200(R6) Fetch Decode 3- EX) ALUout <= Rs + SX(Imm) 4-MEM) Mem[ALUout] ← Rt M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R Rt M 6 4 SIGN EXT 16 IR[IM] ALUout

Type J OP XI OPeration eXtended Immediate Unconditional jumps 6 bit 26 bits OPeration eXtended Immediate Unconditional jumps 2 LSBs are ’00’. No need to specify them. 4 MSBs are taken from PC 234262 – © Yohai Devir 2007 Technion - IIT

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT J 0xCF44 4444 OP XI 2 0x03D1 1111 6 bit 26 bits Assume that there is a J instruction in the following address : 0xCE125678: J 0xCF444444 It jumps to a specific address. Semantic: PCnew  PC[upper 4 MSBs] || XI || 00

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT פקודת J – J 0xCF44 4444 C1 6 IR[OP] M 1 P C M 2 ADDR MEMout MEM WDATA I R 4 PC[31:28] Fetch Decode 3- EX) PC ← PC[31:28] || XI*4 2 IR[XI] 26 ב-EX ה-ALU לא בשימוש, אך עדיין עליו לבצע איזשהו חישוב סרק על מנת למנוע אות סטטוס zero מזוהם. למשל, ALUout <= PC + 4

FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) ALUout  f (Rs, SX(IM)) f מצוין ב- IR[OP] ALUout  f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) MEMout  MEM(ALUout) Rt  ALUout Rd  ALUout OP= ’J’ PC[27:0]  4  XI FETCH FETCH FETCH Rt  MEMout FETCH FETCH 234262 – © Yohai Devir 2007 Technion - IIT

MIPS - מבנה כללי MEM 234262 – © Yohai Devir 2007 Technion - IIT C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R M 3 Rt M 6 WNREG 4 5 IR[d] 4 M 4 PC[31:28] WDATA 2 SIGN EXT IR[XI] 26 16 IR[IM] 4 ALUout 234262 – © Yohai Devir 2007 Technion - IIT

לא כל הבוררים מוכרחים להיות אדישים! 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לא כל הבוררים מוכרחים להיות אדישים! בפועל כל ה-MUX-ים במעבד הם אדישים. אבל לא כולם מוכרחים להיות כאלה: אדום – חייב להיות אדיש סגול – תלוי במימוש של הזיכרון (האם הפלט לוגי כשלא קוראים ולא כותבים) ירוק – רשאי להיות לא אדיש M 5 M 1 M 2 M 6 M 3 M 4 אותות בקרה לבוררים האדומים חייבים להגיע ישירות מתוך FF-ים חסרי ספחות סטטיות של הבקר!

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT אדישות הבוררים C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 I R Rt M 6 M 3 WNREG 4 5 IR[d] 4 M 4 PC[31:28] WDATA 2 SIGN EXT IR[XI] 26 16 IR[IM] 4 ALUout אותות בקרה לבוררים האדומים חייבים להגיע ישירות מתוך FF-ים חסרי ספחות סטטיות של הבקר!

מימוש פקודת JAL Stores PC in Register 31 and then jumps to given address. Semantic: R31  PC PC  address הצע קידוד לפקודה בצע שינויים בשרטוט המעבד רשום את תכנית הפעולה של הפקודה

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT JAL 0xEF44 4444 OP XI 3 0x03D1 1111 6 bit 26 bits Jump And Link Assume that there is a JAL instruction in the following address : 0xEE125678: J 0xEF444444 Stores PC in Register 31 and then jumps to given address. Semantic: R31  PC PC  PC[upper 4 MSBs] || XI || 00

JAL – פיתרון פשוט אם כי יקר 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT JAL – פיתרון פשוט אם כי יקר C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 Rt I R M 6 M 3 31 WNREG 4 5 4 5 IR[d] M 4 PC[31:28] WDATA 2 32 SIGN EXT IR[XI] 26 16 IR[IM] 4 ALUout

JAL – פיתרון פשוט אם כי יקר 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT JAL – פיתרון פשוט אם כי יקר Fetch Decode 3- EX) R31 ← PC PC ← PC[31:28] || XI*4 I R M 3 5 IR[d] 5 IR[t] 5 IR[s] 4 NREG1 WDATA 5 Rs Rt 6 12 IR[OP+FUN] NREG2 16 IR[IM] WNREG ZERO REG FILE 4 SIGN EXT C1 C3 WR I T E 6 IR[OP] ALUout B P C 1 2 IR[XI] 26 PC[31:28] C2 R E A D ADDR MEMout MEM A L U 31 32

JAL – פיתרון זול אם כי מתוחכם 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT הרעיון: ננצל מסלול צירופי מ-PC ל-M4 העובר דרך ALU. כלומר, נבצע: R31 ← PC + 0 בעיה: ערך 0 היינו יכולים לקרוא מ-R0 אבל אין בקידוד הפקודה קבוע 0 ולכן לא נוכל לקרוא את R0 (אלא אם נוסיף MUX לפני Nreg1). פיתרון: נשתמש בזהות: PC + 0 ≡ PC + 4 – 4 I R M 3 5 IR[d] 5 IR[t] 5 IR[s] 4 NREG1 WDATA 5 Rs Rt 6 12 IR[OP+FUN] NREG2 16 IR[IM] WNREG ZERO REG FILE 4 SIGN EXT C1 C3 WR I T E 6 IR[OP] ALUout B P C 1 2 IR[XI] 26 PC[31:28] C2 R E A D ADDR MEMout MEM A L U 31

JAL – פיתרון זול אם כי מתוחכם 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Fetch // PC ← α + 4, Decode 3- EX1) PC ← PC + 4 // PC ← α + 8 4- EX2) ALUout <= PC – 4 // ALUout <= α + 4 5- WB) R31 ← ALUout // R31 ← α + 4 PC ← PC[31:28] || XI*4 // J כמו // α is the address of the current (JAL) command I R M 3 5 IR[d] 5 IR[t] 5 IR[s] 4 NREG1 WDATA 5 Rs Rt 6 12 IR[OP+FUN] NREG2 16 IR[IM] WNREG ZERO REG FILE 4 SIGN EXT C1 C3 WR I T E 6 IR[OP] ALUout B P C 1 2 IR[XI] 26 PC[31:28] C2 R E A D ADDR MEMout MEM A L U 31

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Pre-fetch C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 4 5 IR[d] 4 M 4 PC[31:28] WDATA 2 SIGN EXT IR[XI] 26 16 IR[IM] 4 ALUout

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT תיזכורת: שלב fetch IR ← Mem[PC] PC ← PC + 4 M 5 M 1 A L U P C M 2 ADDR MEMout MEM WDATA ALUout I R M 6 4 ALUout

לדוגמא: pre-fetch בסיום של add R11,R22,R31 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לדוגמא: pre-fetch בסיום של add R11,R22,R31 3- EX) ALUout <= Rs + Rt 4-WB) Rd ← ALUout 12 IR[OP+FUN] C3 M 5 A L U 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 5 IR[d] M 4 WDATA

לדוגמא: pre-fetch בסיום של add R11,R22,R31 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לדוגמא: pre-fetch בסיום של add R11,R22,R31 IR ← Mem[PC] PC ← PC + 4 3- EX) ALUout <= Rs + Rt 4-WB) Rd ← ALUout כנגד 12 IR[OP+FUN] C3 M 5 M 1 A L U P C M 2 ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 5 IR[d] 4 M 4 WDATA ALUout

לדוגמא: pre-fetch בסיום של add R11,R22,R31 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לדוגמא: pre-fetch בסיום של add R11,R22,R31 3- EX) RWD ←Rs + Rt 4-WB) Rd ← RWD IR ← Mem[PC] PC ← PC + 4 add pre-fetch 12 IR[OP+FUN] C3 M 5 M 1 A L U P C M 2 ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs ALUout 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 5 IR[d] 4 M 4 RWD WDATA ALUout

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Prefetch שימו לב כי pre-fetching לא מתרחש תוך כדי ביצוע פקודות: קפיצה והסתעפות SW C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 4 5 IR[d] 4 M 4 PC[31:28] WDATA RWD 2 SIGN EXT IR[XI] 26 16 IR[IM] 4 ALUout

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT FETCH IR  (PC)MEM PC  PC+4 DECODE REG2  Rt ;REG1  Rs BPC  PC + 4  SX(IM ) OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP OP= ’BEQ’ ALUout  Rs + SX(IM) RWD ← f (Rs, SX(IM)) f מצוין ב- IR[OP] RWD ← f (Rs, Rt) f מצוין ב- IR[FUN] ALUout  Rs  Rt IF(Rs=Rt) PC  BPC OP= ’SW’ OP= ‘LW’ FETCH (כתיבה בזיכרון) MEM(ALUout)  Rt (קריאה) RWD ← MEM(ALUout) Rt  RWD IR ← MEM(PC) PC ← PC + 4 Rt  RWD IR ← MEM(PC) PC ← PC + 4 OP= ’J’ PC[27:0]  4  XI FETCH DECODE DECODE FETCH שימו לב כי pre-fetching לא מתרחש תוך כדי ביצוע פקודות: קפיצה והסתעפות SW

Prefetch (ניסיון נוסף) 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Prefetch (ניסיון נוסף) מה היה קורה אילו היינו שמים את הרגיסטר RWD ביציאה של ה-ALU? I R M 3 5 IR[d] 5 IR[t] 5 IR[s] 4 NREG1 WDATA 5 Rs Rt 6 12 IR[OP+FUN] NREG2 16 IR[IM] WNREG ZERO REG FILE 4 SIGN EXT C1 C3 WR I T E 6 IR[OP] B P C 1 2 IR[XI] 26 PC[31:28] C2 R E A D ALUout ADDR MEMout MEM A L U RWD

Prefetch (ניסיון נוסף עם שיפור) 234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT Prefetch (ניסיון נוסף עם שיפור) אחרי שינוי קל שלא עולה כלום מקבלים פיתרון סביר אם כי חלש יותר. הפיתרון הראשון איפשר prefetching גם בסוף ביצוע LW. C1 R E A D WR I T E WR I T E 6 IR[OP] 12 IR[OP+FUN] C3 C2 ZERO B P C ZERO M 5 M 1 P C M 2 A L U ADDR MEMout MEM WDATA 5 IR[s] NREG1 REG FILE Rs 5 IR[t] NREG2 Rt I R M 6 M 3 WNREG 4 5 IR[d] 4 M 4 PC[31:28] WDATA 2 SIGN EXT IR[XI] 26 16 IR[IM] 4 RWD ALUout