ללא כותרת שקופית - The Blavatnik School of
Download
Report
Transcript ללא כותרת שקופית - The Blavatnik School of
שלבי ביצוע הוראת מכונה
( = FETCH )1קרא הוראה מהזיכרון ע"פ הכתובת שמכיל ה.PC-
( = DECODE )2פענח את הפקודה וקרא את האוגרים הנחוצים (אחד או
שניים).
( = EXECUTE )3בעזרת ה ALU-חשב את התוצאה ,או כתובת רצויה.
( = MEMORY )4השתמש בתוצאה לבצע במידת הצורך :או טעינה לזיכרון
( )Storeאו קריאה מהזיכרון (.)Load
( = WRITE BACK )5בצע במידת הצורך טעינה לאוגר.
במשך כל מחזור השעון קוראים
בסוף השעון כותבים
falling edge
cycle time
rising edge
קווי הבקרה -מיוצרים על פי השעון ,כל עליית שעון תשנה
בעקבותיה את קווי הבקרה (אם נדרש)
MIPS תיאור מפושט של מעבד
Data
PC
#register
Instruction
address
Registers
#register
Instruction
memory
ALU
#register
Data
memory
Data
I-type - וR-type החיבורים המתוארים תומכים בכל שלבי פקודות
add, sub, or, xor, and, slt, lw, sw, beq, j :אנו נתמוך בפקודות
bne, addi, :כמובן שנצטרך לדעת כיצד מוסיפים פקודות נוספות כמו למשל
jal, jr
וד שלושה שבועות
IF.Flush
Hazard
detection
unit
ID/EX
M
u
x
WB
Control
0
M
u
x
IF/ID
4
M
WB
EX
M
MEM/WB
WB
Shift
left 2
Registers
PC
EX/MEM
=
M
u
x
Instruction
memory
ALU
M
u
x
Sign
extend
M
u
x
Forwarding
unit
Data
memory
M
u
x
חלקים בסיסים של המחשב הדרושים לשלב ה:fetch-
Instruction
Address
Instruction
Instruction
Memory
Sum
Add
PC
כמובן שדרוש זיכרון פקודות ,רגיסטר לשמירת הכתובת
וכן adderלחשוב הכתובת הבאה
Write
FETCH -שלב ה
4
PC
Read
address
Instruction
Instruction
memory
Add
4
Adde
r
[31:26] 6
PC
Instruction
Memory
[25:21]=Rs 5
[20:16]=Rt 5
[15:11]=Rd 5
[5:0]=funct
ck
A CPU capable of
R-type instructions only
6
decode- יחידה זו דרושה לשלב ה.יחידת הרגיסטרים
)write back-(ולשלב ה
Read
register 1
מספרי האוגרים
Read
register 2
Read
data
1
Registers
Write
register
Data
Write
Data
Read
data 2
Arithmetic Logic operation
ALU operation
Read
register1
Instruction
Read
register2
Write
register
Write
Data
Read
data 1
ALU operation
Zero
ALU
result
Registers
Read
data 2
ALU
ALU
result
ALU
R-type הפעולה הבסיסית שנדגים הנה פקודת
4
Adde
r
[31:26] 6
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
ALU
[20:16]=Rt 5
[15:11]=Rd 5
[5:0]=funct
6
ck
ck
A CPU capable of
R-type instructions only
4
Adde
r
[31:26] 6
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
ALU
[20:16]=Rt 5
[15:11]=Rd 5
[5:0]=funct
6
ck
ck
A CPU capable of
R-type instructions only
The internal structure of the Register File
Rd reg 1 (= Rs)
32
5
32
32
32
32
write data
Read data 1
32
32
32
Rd reg 2 (= Rt)
5
32
32
32
32
Wr reg (= Rd)
Read data 2
32
5
E
RegWrite
קוראים משתי היציאות בוזמנית ערכים של שני רגיסטרים שונים
)כותבים לאחד הרגיסטרים האחרים (בעליית השעון הבאה
A CPU capable of R-type instructions only
4
Adde
r
[31:26] 6
RegWrite
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
ALU
[20:16]=Rt 5
[15:11]=Rd 5
ck
ck
A CPU capable of R-type instructions only
Instruction
Memory
Reg File
[25:21]=Rs 5
PC
ALU
[20:16]=Rt 5
[15:11]=Rd 5
ck
ck
A CPU capable of R-type instructions only
4
Instruction
Memory
P
C
Reg File
ALU
[25:21]=Rs 5
[20:16]=Rt 5
[15:11]=Rd 5
ck
ck
A CPU capable of R-type instructions only
4
Adde
r
[31:26] 6
RegWrite
[5:0]=funct
6
ALU
control
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
ALU
[20:16]=Rt 5
[15:11]=Rd 5
ck
ck
Load,Store בניית פעולות
Write
Read
address
Read
data
Write
address
16
Sign
extend
32
Data
memory
Write
data
Read
ממנו נקרא ואליו נכתובdata -כאן נדרש זיכרון ל
bit16 שהוא רקimm - של הsign extension כמו כן יש לבצע
A CPU capable of lw instructions only
4
Adde
r
[31:26] 6
add
RegWrite=1
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
5
ck
ck
[15:0]
16
Sext
16->32
D. Out
4
Adde
r
[31:26] 6
add
RegWrite=1
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
ALU
[20:16]=Rt 5
Address
5
ck
ck
[15:0]
16
Sext
16->32
A CPU capable of
lw instructions only
Data
Memory
D. Out
A CPU capable of lw instructions only
4
Adde
r
[31:26] 6
add
RegWrite=1
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
5
ck
ck
[15:0]
16
Sext
16->32
D. Out
A CPU capable of lw & sw instructions only
4
MeWrite=1
Adde
r
[31:26] 6
add
RegWrite=0
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
5
D.In
ck
ck
[15:0]
16
Sext
16->32
A CPU capable of R-type & lw instructions (principle)
4
Adde
r
[31:26] 6
add
RegWrite
[5:0]=funct
6
ALU
control
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
[15:11]=Rd 5
ck
ck
[15:0]
16
Sext
16->32
A CPU capable of R-type & lw instructions
4
Adde
r
[31:26] 6
add
RegWrite
[5:0]=funct
6
ALU
control
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
5
Rd
ck
[15:0]
16
ck
Sext
16->32
D. Out
A CPU capable of R-type & lw/sw instructions
4
MemWrite
Adde
r
[31:26] 6
add
RegWrite
[5:0]=funct
6
ALU
control
Reg File
PC
Instruction
Memory
[25:21]=Rs 5
Data
Memory
ALU
[20:16]=Rt 5
Address
D. Out
5
D.In
Rd
ck
[15:0]
16
ck
Sext
16->32
:Branch אלמנטים דרושים להוספת
Fetch - משלב הPC+4
Adder
In addresses, we always shift left by two bits
Read
register 1
Read
register 2
Instruction
Write
register
Write
Data
16
Sum
Shift
left 2
Branch
Target
Read
data 1
Registers
Read
data 2
Sigh
Extend
32
Zero
ALU
מועבר
ליחידת
הבקרה
כתוצאה
הלוגית
של
ההשוואה
שילוב כל הפקודות
M
u
x
ALU
Add
result
4
PC
Shift
left 2
Read
address
Read
register 1
Instruction
Read
register 2
Instruction
memory
ADD
Write
Read
data 1
Zero
ALU
Write Registers
Read
register
data 2
Write
Data
M
u
x
result
ALU
Read
address
Write
address
Data
memory
Write
data
Read
16
Sign
extend
32
Read
data
M
u
x
?CPU -איפה ה
Instruction
Memory
CPU
PC
Data
Memory
קווי בקרה
PCSrc
4
Shift
left 2
PC
Read
address
Instruction
Instruction
memory
M
u
x
Add
Add
Registers
Read
register 1
Read
Read
data 1
register 2
Write
register
Write
data
ALUSrc
Read
data 2
RegWrite
16
M
u
x
32
Sign
extend
ALU
result
3
ALU operation
Zero
ALU ALU
result
MemWrite
MemtoReg
Address
Write
data
Read
data
Data
memory
MemRead
M
u
x
Control
0
M
u
x
Add ALU
result
Add
4
Instruction [31– 26]
Control
Instruction [25– 21]
PC
Read
address
Instruction
memory
Instruction [15– 11]
Shift
left 2
RegDst
Branch
MemRead
MemtoReg
ALUOp
MemWrite
ALUSrc
RegWrite
Read
register 1
Instruction [20– 16]
Instruction
[31– 0]
1
0
M
u
x
1
Read
data 1
Read
register 2
Registers Read
Write
data 2
register
0
M
u
x
1
Write
data
Zero
ALU ALU
result
Address
Write
data
Instruction [15– 0]
16
Instruction [5– 0]
Sign
extend
32
ALU
control
d
Rea
a
dat
Data
memory
1
M
u
x
0
Control
Inputs
Op5
Op4
Op3
Op2
Op1
Op0
Outputs
R-format
Iw
sw
beq
RegDst
ALUSrc
MemtoReg
RegWrite
MemRead
MemWrite
Branch
ALUOp1
ALUOpO
Memto- Reg Mem Mem
Instruction RegDst ALUSrc
Reg
Write Read Write Branch ALUOp1 ALUp0
R-format
1
0
0
1
0
0
0
1
0
lw
0
1
1
1
1
0
0
0
0
sw
X
1
X
0
0
1
0
0
0
beq
X
0
X
0
0
0
1
0
1
ALU control
ALUOp
ALU control block
ALUOp0
ALUOp1
F3
F2
F (5– 0)
Operation2
Operation1
Operation
F1
Operation0
F0
ALU control output
000
AND
001
OR
010
add
110
subtract
111
set-on-less-than
(sign of rs-rt -> rd)
ALUOp
ALUOp1 ALUOp0
0
0
0
1
1
0
1
0
1
0
1
0
1
0
F5
X
X
X
X
X
X
X
Funct field
F4 F3 F2 F1
X X X X
X X X X
X 0 0 0
X 0 0 1
X 0 1 0
X 0 1 0
X 1 0 1
00 = lw, sw
01 = beq,
10 = arithmetic
Operation
F0
X
X
0
0
0
1
0
ALUop
010
110
010
110
000
001
111
פקודת הjump -
פירוש הפקודה:
J 101…101111011
הפקודה הבאה נמצאת בכתובת
0110…111101111
26 bits
2 bits
101 … 101111011
כתובת קפיצה במילים :
כתובת קפיצה בבתים :
00
תוספת 4ביטים אחרונים :
הקפיצה הסופית :
00
4 bits
101 … 101111011
101 … 101111011
0110
101 … 101111011
0110
Jump
Instruction [25– 0]
26
Shift
left 2
Jump address [31– 0]
28
0
1
M
u
x
M
u
x
ALU
Add result
1
0
Zero
ALU ALU
result
Address
PC+4 [31– 28]
Add
4
Instruction [31– 26]
Control
Shift
left 2
RegDst
Jump
Branch
Me mRead
Me mtoReg
ALUOp
Me mWrite
ALUSrc
RegWrite
Instruction [25– 21]
PC
Read
address
Instruction [20– 16]
Instruction
[31– 0]
Instruction
me mory
Read
register 1
Instruction [15– 11]
0
M
u
x
1
Read
data 1
Read
register 2
Registers Read
Write
data 2
register
0
M
u
x
1
Write
data
Write
data
Instruction [15– 0]
16
Instruction [5– 0]
Sign
extend
32
ALU
control
Read
data
Data
me mory
1
M
u
x
0