tutorial #10 mips commands 234262 – © yohai devir 2007 technion - iit

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

Post on 19-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

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

Tutorial #10

MIPS commands

234262

234262 – © Yohai Devir 2007Technion - IIT

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

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 2007Technion - IIT

MIPS overview

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

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 2007Technion - IIT

Registers

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

(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 2007Technion - IIT

Memory

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

3 types of instructions, each kind with a fixed structure:

Type R (Register) Type I (Immediate) Type J (Jump)

234262 – © Yohai Devir 2007Technion - IIT

Instructions

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

Tutorial #11

Multicycle MIPS

234262

234262 – © Yohai Devir 2007Technion - IIT

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

234262 – © Yohai Devir 2007Technion - IIT

MIPSמבנה כללי -

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

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

234262 – © Yohai Devir 2007Technion - IIT

הבקר

A

L

U M

6

M5

REG

FILE

M4

M3

I

R

M2

M1

P

C

MEM

BPC

12 IR[OP+FUN]

ZERO

C1

C3

WRITE

6 IR[OP]

ZEROC2

WRITE

READ

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

234262 – © Yohai Devir 2007Technion - IIT

ALU

A

L

U

ZERO

C3

ALUout

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

234262 – © Yohai Devir 2007Technion - IIT

MEMORYיחידת ה- WRITE

READ

ADDR MEMout

MEM

WDATA

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

234262 – © Yohai Devir 2007Technion - IIT

RFיחידת ה-

NREG1

WDATA

Rs

Rt NREG2

WNREG

REG

FILE

WRITE

WDATA

WNREG

NREG1

NREG2

Rs

Rt

31*32

WRITE

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

RFמבנה ה-

Rs

R31R1

Nreg1

נתב כתיב

ה

נתב קריאה

#1

נתב קריאה

#2

Nreg2

WNreg

WData

WRITE

Rt

234262 – © Dima Elenbogen 2010 Technion - IIT

הערה: הנתבים צירופיים!

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

fetchלכל הפקודות – שלב

I

R

M5

M

6

A

L

U

4

ALUout

P

C

M1

M2

ALUout

ADDR MEMout

MEM

WDATA

• IR ← Mem[PC]• PC ← PC + 4

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

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

OPerationSource \ Target RegistersIMmediate

234262 – © Yohai Devir 2007Technion - IIT

Type IOP Rs Rt IM6 bit 5 bit 5 bit 16 bit

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

Branch on Not EqualSemantic:

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 R31,R8,loop1OP Rs Rt IM

4 31 8 ?6 bit 5 bit 5 bit 16 bit

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

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

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.

234262 – © Yohai Devir 2007Technion - IIT

BNE

(BNEaddr )PCnew (BNEaddr +4) + IM x 4

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

decodeלכל הפקודות – שלב

I

R

5 IR[t]

5 IR[s] NREG1Rs

Rt

M5

M

6

A

L

U

NREG2

REG

FILE

16 IR[IM]

4

SIGNEXT

C1

6 IR[OP]

ALUout

BPC

P

C

ALUout

• C1 is decoding IR[OP]• Rs is being read• Rt is being read• BPC ← PC +

SX(Imm)*4

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

OPerationSource \ Target \ Destination RegisterSHift AMounTFUNCtion

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

Type ROP Rs Rt Rd shamt func6 bit 5 bit 5 bit 5 bit 5 bit 6 bit

Rs מיועד לקריאה בלבד Rt מיועד לקריאה ולכתיבה (לכתיבה בחלק של פקודות מסוג I(Rd מיועד לכתיבה בלבד ומופיע בפקודות מסוג Rבלבד

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

Semantic: R11 R22 + R31

234262 – © Yohai Devir 2007Technion - IIT

ADD R11,R22,R31OP Rs Rt Rd shamt func

0 22 31 11 0 326 bit 5 bit 5 bit 5 bit 5 bit 6 bit

OP Rs Rt Rd shamt func

000000 10110 11111 01011 00000 1000006 bit 5 bit 5 bit 5 bit 5 bit 6 bit

OP Rs Rt Rd shamt func6 bit 5 bit 5 bit 5 bit 5 bit 6 bit

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

234262 – © Yohai Devir 2007Technion - IIT

R – addפקודה מסוג R11,R22,R31

ADDR MEMout

MEM

WDATA

I

R M35 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

A

L

U

NREG2

WNREG

REG

FILE4

ALUout

P

C

M1

M2

ALUout

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

R – addפקודה מסוג R11,R22,R31

ADDR MEMout

MEM

WDATA

I

R M35 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

A

L

U

NREG2

WNREG

REG

FILE4

ALUout

P

C

M1

M2

ALUout

12 IR[OP+FUN] C3

1) Fetch2) Decode3- EX) ALUout <= Rs + Rt4-WB) Rd ← ALUout

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

234262 – © Yohai Devir 2007Technion - IIT

-,I – addi R11,R22פקודה מסוג 12

I

R M3

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

M

6

16 IR[IM]

WNREG

REG

FILE 4

SIGNEXT

ALUout

P

C

M1

M2

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

OP Rs Rt IM

8 22 11 -126 bit 5 bit 5 bit 16 bit

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

-,I – addi R11,R22פקודה מסוג 12

I

R M3

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

M

6

16 IR[IM]

WNREG

REG

FILE 4

SIGNEXT

ALUout

P

C

M1

M2

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

1) Fetch2) Decode3- EX) ALUout <= Rs + SX(Imm)4-WB) Rt ← ALUout

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

BEQ – BEQפקודת R11,R22,loop

I

R

5 IR[t]

5 IR[s] NREG1

M5 Rs

Rt M

6

NREG2

16 IR[IM]

ZERO

REG

FILE 4

4

SIGNEXT

ALUout

BPC

P

C

M1

M2

ZEROC2

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

1) Fetch2) Decode3- EX) if (zero) PC ← BPC

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

234262 – © Yohai Devir 2007Technion - IIT

הבקר

A

L

U M

6

M5

REG

FILE

M4

M3

I

R

M2

M1

P

C

MEM

BPC

12 IR[OP+FUN]

ZERO

C1

C3

WRITE

6 IR[OP]

ZEROC2

WRITE

READ

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

Load WordSemantic:

Read the word located in the memory address of [R3] + 300 (not 303 !!!) and write it to R23

NOTE: Rs is the Base registerRt is the register to write to.

234262 – © Yohai Devir 2007Technion - IIT

LW R23,300(R3)OP Rs Rt IM

35 3 23 3006 bit 5 bit 5 bit 16 bit

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

,LW – LW R23פקודה 300(R3)

I

R M3

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

16 IR[IM]

WNREG

REG

FILE 4

SIGNEXT

ALUout

P

C

M1

M2

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

1) Fetch2) Decode3- EX) ALUout <= Rs + SX(Imm)4-MEM) MEMout <= Mem[ALUout]5-WB) Rt ← MEMout

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

Load WordSemantic:

Writes the word located in R7 to the memory address of [R6] + 200 (not 206!!!)

NOTE: Rs is the Base registerRt is the read from.

234262 – © Yohai Devir 2007Technion - IIT

SW R7,200(R6)OP Rs Rt IM

43 6 7 2006 bit 5 bit 5 bit 16 bit

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

SW – SW R7, 200(R6)פקודה

I

R

5 IR[t]

5 IR[s] NREG1

M5 Rs

Rt M

6

16 IR[IM]

REG

FILE 4

SIGNEXT

ALUout

P

C

M1

M2

ALUout

NREG2 ADDR MEMout

MEM

WDATA

A

L

U

1) Fetch2) Decode3- EX) ALUout <= Rs + SX(Imm)4-MEM) Mem[ALUout] ← Rt

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

OPerationeXtended Immediate

Unconditional jumps2 LSBs are ’00’. No need to specify them.4 MSBs are taken from PC

234262 – © Yohai Devir 2007Technion - IIT

Type JOP XI6 bit 26 bits

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

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 0xCF44 4444OP XI

2 0x03D1 11116 bit 26 bits

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

J – J 0xCF44 4444פקודת

I

R

P

C

M1

M2

IR[XI] 26

PC[31:28]

4

C1

6 IR[OP]

2

0

ADDR MEMout

MEM

WDATA 1) Fetch2) Decode3- EX) PC ← PC[31:28] || XI*4

ה-EXב- ALU עליו עדיין אך בשימוש, לא למנוע מנת על סרק חישוב איזשהו לבצע

סטטוס למשל, zeroאות מזוהם. ALUout <= PC + 4

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

234262 – © Yohai Devir 2007Technion - IIT

IR (PC)MEM

PC PC+4

REG2 Rt ;REG1 RsBPC PC + 4 SX(IM )

FETCH

PC[27:0] 4 XI

FETCH

OP= ’J’

ALUout Rs Rt IF(Rs=Rt) PC BPC

FETCH

OP= ’BEQ’

DECODE

ALUout f (Rs, Rt)

f -מצוין ב IR[FUN]

FETCH

ALUout Rs + SX(IM)

OP = ’LW’ or ‘SW’

ALUout f (Rs, SX(IM))

f -מצוין ב IR[OP]

I מסוג OP

(קריאה)MEMout MEM(ALUout)

(כתיבה בזיכרון)MEM(ALUout) Rt

Rt MEMout

FETCH

FETCH

Rt ALUout

FETCH

OP= ’SW’ OP= ‘LW’

Rd ALUout

R מסוג OP

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

234262 – © Yohai Devir 2007Technion - IIT

MIPSמבנה כללי -

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5

Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT לא כל הבוררים מוכרחים להיותאדישים!

M3

M4

M5

M

6

M1

M2

•- ה כל .MUXבפועל אדישים- הם במעבד ים•: כאלה להיות מוכרחים כולם לא אבל

אדיש– אדום להיות חייב(סגול כותבים– ) ולא קוראים כשלא לוגי הפלט האם הזיכרון של במימוש תלויאדיש– ירוק לא להיות רשאי

-ים חסרי ספחות סטטיות FFחייבים להגיע ישירות מתוך אדומים אותות בקרה לבוררים ה•של הבקר!

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

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

הבוררים אדישות

-ים חסרי ספחות סטטיות FFחייבים להגיע ישירות מתוך אדומים אותות בקרה לבוררים ה•של הבקר!

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

Jump And Link

Assume that there is a JAL instruction in the following address :

0xEE125678: JAL 0xEF444444

Stores PC in Register 31 and then jumps to given address.

Semantic:R31 PCPC PC[upper 4 MSBs] || XI || 00

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

JAL 0xEF44 4444OP XI

3 0x03D1 11116 bit 26 bits

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

JALפיתרון פשוט אם כי יקר –

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U5

31

32

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

JALפיתרון פשוט אם כי יקר –

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U5

31

32

1) Fetch2) Decode3- EX) R31 ← PC

PC ← PC[31:28] || XI*4

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

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U5

31

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

JALפיתרון זול אם כי מתוחכם – -:הרעיון מ צירופי מסלול -PCננצל דרך M4ל : ALUהעובר , נבצע. R31כלומר

← PC + 0 ולכן לא נוכל 0 אבל אין בקידוד הפקודה קבוע R0 היינו יכולים לקרוא מ-0ערך : בעיה

לקרוא).Nreg1 לפני MUX (אלא אם נוסיף R0את

PC + 0 ≡ PC + 4 – 4נשתמש בזהות: : פיתרון

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

I

R M3

5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:2

8]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U531

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

JALפיתרון זול אם כי מתוחכם – 1) Fetch // PC ← α + 4, 2) Decode3- EX1) PC ← PC + 4 // PC ← α + 84- EX2) ALUout <= PC – 4 // ALUout <= α + 45- WB) R31 ← ALUout // R31 ← α + 4

PC ← PC[31:28] || XI*4 // J כמו

// α is the address of the current (JAL) command

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

Pre-fetch

I

R M3 5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

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

fetchתיזכורת: שלב

I

R

M5

M

6

A

L

U

4

ALUout

P

C

M1

M2

ALUout

ADDR MEMout

MEM

WDATA

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

• IR ← Mem[PC]• PC ← PC + 4

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

add R11,R22,R31 בסיום של pre-fetchלדוגמא:

I

R M35 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

A

L

U

NREG2

WNREG

REG

FILE

ALUout

12 IR[OP+FUN] C3

3- EX) ALUout <= Rs + Rt4-WB) Rd ← ALUout

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

add R11,R22,R31 בסיום של pre-fetchלדוגמא:

ADDR MEMout

MEM

WDATA

I

R M35 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

A

L

U

NREG2

WNREG

REG

FILE4

ALUout

P

C

M1

M2

ALUout

12 IR[OP+FUN] C3

3- EX) ALUout <= Rs + Rt4-WB) Rd ← ALUout

• IR ← Mem[PC]• PC ← PC + 4 כנג

ד

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

add R11,R22,R31 בסיום של pre-fetchלדוגמא:

ADDR MEMout

MEM

WDATA

I

R M35 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

M5 Rs

Rt M

6

A

L

U

NREG2

WNREG

REG

FILE4

ALUout

P

C

M1

M2

ALUout

12 IR[OP+FUN] C3

3- EX) RWD ←Rs + Rt4-WB) Rd ← RWD

IR ← Mem[PC]PC ← PC + 4

WDATA

RWD

add

pre-fetch

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

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

Prefetch

I

R M3 5 IR[d]

5 IR[t]

5 IR[s]

M4

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

לא מתרחש תוך כדי ביצוע פקודות:pre-fetchingשימו לב כי קפיצה והסתעפות•• SW

RWD

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

OP= ’BEQ’OP = ’LW’ or ‘SW’ I מסוג OP R מסוג OP

IR (PC)MEM

PC PC+4

REG2 Rt ;REG1 RsBPC PC + 4 SX(IM )

FETCH

PC[27:0] 4 XI

FETCH

OP= ’J’

ALUout Rs Rt IF(Rs=Rt) PC BPC

FETCH

DECODE

RWD ← f (Rs, Rt)

f -מצוין ב IR[FUN]

DECODE

ALUout Rs + SX(IM) RWD ← f (Rs, SX(IM))

f -מצוין ב IR[OP]

(קריאה)RWD ← MEM(ALUout

)

(כתיבה בזיכרון)MEM(ALUout) Rt

FETCH

Rt RWDIR ← MEM(PC)

PC ← PC + 4

DECODE

OP= ’SW’ OP= ‘LW’

Rd RWDIR ← MEM(PC)

PC ← PC + 4

234262 – © Yohai Devir 2007 Dima Elenbogen 2010 Technion - IIT

לא מתרחש תוך כדי ביצוע פקודות:pre-fetchingשימו לב כי קפיצה והסתעפות•• SW

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

Prefetch מימוש תוך ניצול – BPC

I

R M3 5 IR[d]

5 IR[t]

5 IR[s]

M7

NREG1

WDATA

M5 Rs

Rt M

6

12 IR[OP+FUN]

NREG2

16 IR[IM]

WNREG

ZERO

REG

FILE 4

4

SIGNEXT

C1

C3

WRITE

6 IR[OP]

ALUout

BPC

P

C

M1

M2

ZERO

IR[XI] 26

PC[31:28]

C2

2

0

4

WRITE

READ

ALUout

ADDR MEMout

MEM

WDATA

A

L

U

.BPC הבקר יודע האם ניתן לשכוח את הכתובת השמורה ב-3 החל במחזור •.BPC מקבל את כל ערכיו מ-Wdata מכיוון ש-M4 ניתן לוותר בכלל על בורר •.RWD כך שימלא גם את תפקידו של BPC! הסבנו את 0 עלות השינויים: •

234262 – © Yohai Devir 2007 Dima Elenbogen 2011 Technion - IIT