Multi-Cycle Processor and Control Unit

Download Report

Transcript Multi-Cycle Processor and Control Unit

‫מחשב בעל ריבוי מחזורים‬
‫• נשבור את ביצוע הפקודות למספר שלבים‬
‫• בכל מחזור שעון נבצע רק שלב אחד‬
‫• מספר משתנה של מחזורים לביצוע פקודות‬
‫• יותר מהיר מאשר מחשב בעל מחזור יחיד‬
‫• ניתן להשתמש מחדש ביחידות פונקציונליות (בשלבים בהן הן‬
‫אינן עסוקות בתפקידן ה"מקורי")‬
‫• נזדקק לרגיסטרים חדשים לשמירת ערכי ביניים (בין מחזורי‬
‫שעון)‬
‫• נזדקק לבקר ‪( FSM‬בניגוד לבקר הצירופי שהספיק למחשב‬
‫בעל מחזור יחיד)‬
‫‪1‬‬
‫‪December 2013‬‬
‫ מסלול הנתונים‬:‫מבנה עקרוני‬
Instruction
register
PC
Address
Data
A
Register #
Instruction
Memory
or data
Data
December 2013
ALU
Registers
Memory
data
register
ALUOut
Register #
B
Register #
2
‫השינויים במסלול הנתונים‬
‫• חסכון בחומרה‪ :‬זיכרון משותף לנתונים ופקודות‬
‫– כי לא משתמשים בהם בו זמנית‬
‫• חסכון בחומרה‪ ALU :‬יחיד לכל החישובים‬
‫– אריתמטיקה‪ ,‬כתובות נתונים‪ ,‬כתובות קפיצה (מותנית או לא)‪ ,‬הגדלת‬
‫ה‪ – PC-‬כולם קורים בשלבים שונים‬
‫• מחיר בחומרה‪ :‬רגיסטרים של ערכי ביניים‬
‫– אוגר הפקודה )‪Instruction Register (IR‬‬
‫– אוגר הזיכרון )‪Memory Data Register (MDR‬‬
‫– אוגרי ‪ B,A‬בכניסות ל‪ALU-‬‬
‫– אוגר ‪ ALUout‬ביציאה מה‪ALU-‬‬
‫• מחיר בחומרה‪ :‬תוספת בוררים‬
‫‪3‬‬
‫‪December 2013‬‬
‫שני סוגי רגיסטרים‬
‫• רגיסטרים המכילים נתונים בין ביצוע של פקודה אחת‬
‫ושל הבאה אחריה‬
‫– ‪Register File‬‬
‫– ‪PC‬‬
‫• גלויים למתכנת‪ ,‬פונים איליהם בתכנית ‪ASSEMBLY‬‬
‫• רגיסטרים המכילים נתונים רק במהלך ביצוע פקודה‬
‫אחת‪ ,‬בין מחזור שעון אחד לשני‬
‫• אינם גלויים למתכנת‬
‫‪4‬‬
‫‪December 2013‬‬
)‫מסלול הנתונים (תמונה חלקית‬
PC
0
M
u
x
1
Address
Memory
MemData
Write
data
Instruction
[25– 21]
Read
register 1
Instruction
[20– 16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Instruction
[15– 0]
Instruction
register
Instruction
[15– 0]
Memory
data
register
December 2013
0
M
Instruction u
x
[15– 11]
1
A
B
4
Write
data
0
M
u
x
1
16
Sign
extend
0
M
u
x
1
32
Shift
left 2
Zero
ALU ALU
result
ALUOut
0
1 M
u
2 x
3
Same ALU is used
for all additions
5
‫ אותות בקרה‬+ ‫מסלול הנתונים‬
IorD
PC
0
M
u
x
1
MemRead MemWrite
IRWrite
RegDst
RegWrite
Instruction
[25– 21]
Address
Memory
MemData
Write
data
Instruction
register
Instruction
[15– 0]
Memory
data
register
0
M
u
x
1
Read
register 1
Read
Read
data 1
register 2
Registers
Write
Read
register
data 2
Instruction
[20– 16]
Instruction
[15– 0]
ALUSrcA
0
M
Instruction u
x
[15– 11]
1
A
B
4
Write
data
0
M
u
x
1
16
Sign
extend
32
Shift
left 2
Zero
ALU ALU
result
ALUOut
0
1 M
u
2 x
3
ALU
control
Instruction [5– 0]
MemtoReg
December 2013
ALUSrcB ALUOp
6
‫הוספת התמיכה בקפיצות‬
PCWriteCond
PCSource
PCWrite
IorD
Outputs
ALUSrcB
MemRead
MemWrite
Control
ALUSrcA
RegWrite
MemtoReg
IRWrite
ALUOp
Op
[5– 0]
RegDst
0
M
26
Instruction [25– 0]
PC
0
M
u
x
1
Shift
left 2
Instruction
[31-26]
Address
Memory
MemData
Write
data
Instruction
[25– 21]
Read
register 1
Instruction
[20– 16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Instruction
[15– 0]
Instruction
register
Instruction
[15– 0]
Memory
data
register
0
M
Instruction u
x
[15– 11]
1
B
0
M
u
x
1
16
Sign
extend
32
Shift
left 2
x
2
Zero
ALU ALU
result
ALUOut
0
4
Write
data
1 u
PC [31-28]
0
M
u
x
1
A
28
Jump
address [31-0]
1 M
u
2 x
3
ALU
control
Instruction [5– 0]
December 2013
7
‫שני המחזורים הראשונים זהים לכל הפקודות‬
‫‪ – FETCH .1‬הבאת הפקודה שה‪ PC-‬מצביע עליה מזכרון הפקודות‬
‫‪IR = Memory[PC] .1‬‬
‫‪PC = PC+4 .2‬‬
‫‪ – DECODE .2‬פענוח הפקודה ו‪ – READ-‬קריאת ‪ 2‬רגיסטרים‬
‫(השימוש בהם יהיה בהתאם לפקודה)‪ ,‬וגם‪ :‬חישוב ספקולטיבי של‬
‫כתובת היעד של קפיצה מותנית‬
‫‪A = Reg[IR[25…21]] .1‬‬
‫‪B = Reg[IR[20…16]] .2‬‬
‫‪ALUOut = PC + (signextend(IR[15…0]) << 2) .3‬‬
‫‪8‬‬
‫‪December 2013‬‬
Execute
:‫מחזור שלישי‬
:)R-type( ALU ‫• ביצוע פקודת‬
ALUOut = A op B –
:) load / store ‫• חישוב כתובת זכרון (עבור פקודות‬
ALUOut = A + signextend(IR[15…0]) –
:‫• השלמת קפיצה מותנית‬
(Speculation) If (A = B)
PC = ALUOut
–
:‫• ביצוע קפיצה בלתי מותנית‬
PC = PC[31…28] || (IR[25…0]<<2) –
December 2013
9
Memory :‫מחזור רביעי‬
: Load ‫• בפקודת‬
MDR = Memory[ALUOut] –
: Store ‫• בפקודת‬
Memory[ALUOut] = B –
: ‫(– כתיבה חזרה לרגיסטר‬R-type) ALU ‫• סיום פקודת‬
Reg[IR[15…11]] = ALUOut –
December 2013
10
Write-back :‫מחזור חמישי‬
: Load ‫• השלמת ביצוע‬
Reg[IR[20…16]] = MDR –
December 2013
11
‫סיכום‬
Registers Data Transfer
Step name
Instruction fetch
Action for R-type
instructions
Instruction
decode/register fetch
Action for memory-reference
Action for
instructions
branches
IR = Memory[PC]
PC = PC + 4
A = Reg [IR[25-21]]
B = Reg [IR[20-16]]
ALUOut = PC + (sign-extend (IR[15-0]) << 2)
Execution, address
computation, branch/
jump completion
ALUOut = A op B
ALUOut = A + sign-extend
(IR[15-0])
Memory access or R-type
completion
Reg [IR[15-11]] =
ALUOut
Load: MDR = Memory[ALUOut]
or
Store: Memory [ALUOut] = B
Memory read completion
December 2013
if (A ==B) then
PC = ALUOut
Action for
jumps
PC = PC [31-28] II
(IR[25-0]<<2)
Load: Reg[IR[20-16]] = MDR
12
‫שאלות לדוגמה‬
‫• כמה מחזורים ידרשו לביצוע הקוד להלן ?‬
‫)‪$t2, 0($t3‬‬
‫)‪$t3, 4($t3‬‬
‫‪$t2, $t3, Label #assume not‬‬
‫‪$t5, $t2, $t3‬‬
‫)‪$t5, 8($t3‬‬
‫‪...‬‬
‫‪lw‬‬
‫‪lw‬‬
‫‪beq‬‬
‫‪add‬‬
‫‪sw‬‬
‫‪Label:‬‬
‫• מה מתבצע במחזור השמיני של התכנית ?‬
‫• באיזה מחזור מתבצע החיבור של ‪? $t2+$t3‬‬
‫‪13‬‬
‫‪December 2013‬‬
‫מכונת המצבים של הבקר‬
Start
Instruction fetch/decode and register fetch
(Figure 5.37)
Memory access
instructions
(Figure 5.38)
December 2013
R-type instructions
(Figure 5.39)
Branch instruction
(Figure 5.40)
Jump instruction
(Figure 5.41)
14
‫ שני המצבים הראשונים‬:‫מכונת המצבים‬
Instruction decode/
Register fetch
Instruction fetch
(Fig. 5.37)
0
1
ALUSrcA = 0
ALUSrcB = 11
ALUOp = 00
(Op = 'JMP')
Start
MemRead
ALUSrcA = 0
IorD = 0
IRWrite
ALUSrcB = 01
ALUOp = 00
PCWrite
PCSource = 00
Memory reference FSM
(Figure 5.38)
R-type FSM
(Figure 5.39)
Branch FSM
(Figure 5.40)
Jump FSM
(Figure 5.41)
15
Instruction Fetch
PCWriteCond
1 0
1
PCSource
PCWrite
IorD
Outputs
ALUSrcB
MemRead
MemWrite
Control
IRWrite
ALUSrcA
RegWrite
MemtoReg
1
00
00
01
0
ALUOp
Op
[5– 0]
RegDst
0
M
26
Instruction [25– 0]
PC
0
M
u
x
1
Shift
left 2
Instruction
[31-26]
Address
Memory
MemData
Write
data
Instruction
[25– 21]
Read
register 1
Instruction
[20– 16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Instruction
[15– 0]
Instruction
register
Instruction
[15– 0]
Memory
data
register
0
M
Instruction u
x
[15– 11]
1
B
0
M
u
x
1
16
Sign
extend
32
Shift
left 2
x
2
Zero
ALU ALU
result
ALUOut
0
4
Write
data
1 u
PC [31-28]
0
M
u
x
1
A
28
Jump
address [31-0]
1 M
u
2 x
3
ALU
control
Instruction [5– 0]
December 2013
16
Instruction Decode + Register Fetch
PCWriteCond
PCSource
PCWrite
IorD
Outputs
ALUSrcB
MemRead
MemWrite
Control
ALUSrcA
RegWrite
MemtoReg
IRWrite
00
11
0
ALUOp
Op
[5– 0]
RegDst
0
M
26
Instruction [25– 0]
PC
0
M
u
x
1
Shift
left 2
Instruction
[31-26]
Address
Memory
MemData
Write
data
Instruction
[25– 21]
Read
register 1
Instruction
[20– 16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Instruction
[15– 0]
Instruction
register
Instruction
[15– 0]
Memory
data
register
0
M
Instruction u
x
[15– 11]
1
B
0
M
u
x
1
16
Sign
extend
32
Shift
left 2
x
2
Zero
ALU ALU
result
ALUOut
0
4
Write
data
1 u
PC [31-28]
0
M
u
x
1
A
28
Jump
address [31-0]
1 M
u
2 x
3
ALU
control
Instruction [5– 0]
December 2013
17
)Moore( ‫מכונת המצבים השלמה‬
Instruction fetch
(Figs. 5.38-41)
Start
Memory address
computation
MemRead
ALUSrcA = 0
IorD = 0
IRWrite
ALUSrcB = 01
ALUOp = 00
PCWrite
PCSource = 00
6
(Op = 'LW')
ALUSrcA = 1
ALUSrcB = 10
ALUOp = 00
ALUSrcA = 0
ALUSrcB = 11
ALUOp = 00
Branch
completion
8
ALUSrcA =1
ALUSrcB = 00
ALUOp= 10
Memory
access
3
1
Execution
2
Memory
access
5
MemRead
IorD = 1
Instruction decode/
register fetch
(Op = 'J')
0
Jump
completion
9
ALUSrcA = 1
ALUSrcB = 00
ALUOp = 01
PCWriteCond
PCSource = 01
PCWrite
PCSource = 10
R-type completion
7
MemWrite
IorD = 1
RegDst = 1
RegWrite
MemtoReg = 0
Write-back step
4
RegDst = 0
RegWrite
MemtoReg =1
18
Cycles-Per-Instruction :‫ניתוח הביצועים‬
CPI = 1 :‫• במחשב בעל מחזור שעון יחיד‬
‫ תלוי בסוג‬CPI ,‫• במחשב בעל ריבוי מחזורים‬
:‫הפקודה‬
Load: 5 cycles –
Store: 4 cycles –
ALU: 4 cycles –
Branch: 3 cycles –
Jump: 3 cycles –
December 2013
19
‫שיפור הביצועים הודות לריבוי מחזורים‬
‫• לפי פילוג הפקודות (מן השיעור הקודם)‪:‬‬
‫– ‪CPI = 24%*5+12%*4+44%*4+18%*3+2%*3 = 4.02‬‬
‫• שיפור יחסית למקרה הגרוע בו לכל הפקודות אותו‬
‫מספר מחזורים‪CPI = 5 :‬‬
‫• אבל לכאורה המחשב בעל מחזור יחיד היה "טוב"‬
‫יותר‪? ! CPI = 1 :‬‬
‫• המחשב בעל ריבוי מחזורים יהיה מהיר יותר אם הזמן‬
‫הממוצע של ביצוע פקודה קצר יותר‪:‬‬
‫– זמן ביצוע פקודה‪ :‬זמן מחזור שעון × ‪CPI‬‬
‫– ‪4.02 × TMC < 1 × TSC‬‬
‫‪20‬‬
‫‪‬‬
‫‪TMC < TSC / 4.02‬‬
‫‪December 2013‬‬
‫שיפור הביצועים הודות לריבוי מחזורים‬
‫• אידיאלית‪ ,‬חילקנו את הביצוע לחמישה חלקים ולכן‬
‫השעון אמור להיות מהיר יותר פי חמש (‪)TMC = TSC / 5‬‬
‫– אבל קשה לחלק באופן מאוזן—השלב האיטי ביותר מכתיב את‬
‫זמן המחזור‬
‫– הוספת רגיסטרים בין השלבים מוסיפה גם כן תקורת זמן‬
‫מסוימת‬
‫• במקרה האידאלי‪ ,‬השיפור המקסימלי במהירות הביצוע‪:‬‬
‫‪5 / 4.02 = 1.24‬‬
‫‪21‬‬
‫‪December 2013‬‬
‫מימוש מכונת המצבים‬
PCWrite
PCWriteCond
IorD
MemRead
MemWrite
IRWrite
Control logic
MemtoReg
PCSource
Control signals
ALUOp
Outputs
ALUSrcB
ALUSrcA
RegWrite
RegDst
NS3
NS2
NS1
NS0
Instruction register
opcode field
December 2013
Next state
S0
S1
S2
S3
Op0
Op1
Op2
Op3
Op4
Op5
Inputs
State register
22
‫מימוש הבקר ע"י ‪ROM‬‬
‫• כניסות‪:‬‬
‫– ‪ 6‬סיביות שדה ‪opcode‬‬
‫– ‪ 4‬סיביות משתני מצב‬
‫– סה"כ ‪ 10‬סיביות‪ ,‬כלומר ‪ 210=1024‬מילים‬
‫• יציאות‪:‬‬
‫– ‪ 16‬אותות בקרה‬
‫– ‪ 4‬סיביות המצב הבא‬
‫– סה"כ ‪ 20‬סיביות למילה‬
‫• מימוש ע"י ‪1024 × 20 = 20 Kbits :ROM‬‬
‫‪23‬‬
‫‪December 2013‬‬
‫הקטנת ה‪ROM-‬‬
‫• נפצל את ה‪ ROM -‬לשתי טבלאות‪:‬‬
‫– רק ‪ 4‬סיביות מצב קובעות ‪ 16‬יציאות בקרה‪24×16=256 :‬‬
‫‪bits‬‬
‫– ‪ 10‬סיביות קובעות מה המצב הבא (‪ 4‬סיביות)‪210×4=4K :‬‬
‫– יחד‪ 4.25K ,‬סיביות ‪ROM‬‬
‫‪24‬‬
‫‪December 2013‬‬
‫מימוש יעיל יותר של ה‪FSM -‬‬
‫• מימוש ע"י ‪ ROM‬איננו יעיל‪:‬‬
‫– מכיל את כל הצירופים האפשריים של סיביות הבקרה וקוד המצב הבא‬
‫– במקרים רבים ידוע בדיוק מהו המצב הבא‬
‫– בהרבה מקרים זה פשוט הכתובת הבאה ב‪ROM-‬‬
‫– אבל סיביות רבות ב‪ ROM-‬מכילות את כתובת המצב הבא‪...‬‬
‫• ניתן להשתמש בשערים או ‪ PLA‬כאשר ה‪ ROM-‬לא מלא‬
‫במיוחד‬
‫• רעיון נוסף‪ :‬נשתמש במונה (‪ )+1‬למקרים של "הכתובת הבאה‬
‫ב‪"ROM-‬‬
‫• נוסיף אות בקרה "‪ "AddrCtl‬לקבוע האם להשתמש בתוצאת‬
‫המונה‬
‫• מאוד דומה ל‪ PC-‬של המחשב‪...‬‬
‫‪25‬‬
‫‪December 2013‬‬
PLA ‫ מימוש‬- State 0
Op5
Op4
Op3
Op2
Op1
Op0
S3
S2
S1
S0
State 0:
Instruction Fetch
Next state 1:
Instruction Decode
PCWrite
PCWriteCond
IorD
MemRead
MemWrite
IRWrite
MemtoReg
PCSource1
PCSource0
ALUOp1
ALUOp0
ALUSrcB1
ALUSrcB0
ALUSrcA
RegWrite
RegDst
NS3
NS2
NS1
NS0
26
PLA ‫ מימוש‬- State 2
Op5
Op4
Op3
lw opcode = 35
Op2
Op1
sw opcode = 43
Op0
S3
S2
State 2:
Memory Address
Operation
State 5:
MemWrite
S1
S0
PCWrite
PCWriteCond
IorD
MemRead
MemWrite
IRWrite
MemtoReg
PCSource1
PCSource0
ALUOp1
ALUOp0
ALUSrcB1
ALUSrcB0
ALUSrcA
RegWrite
RegDst
NS3
NS2
NS1
NS0
State 3:
MemRead
27
‫גודל ה‪PLA-‬‬
‫• גודל ‪( :PLA‬כניסות ‪ +‬יציאות) × (מכפלות)‬
‫– (‪ 510 = )17( × )20 + 10‬שערים‬
‫• מדוע ה‪ PLA-‬כה יעיל?‬
‫– שיתוף מכפלות‬
‫– מכיל רק לוגיקה שמייצרת יציאות פעילות‬
‫– מנצל ערכי ‪don’t care‬‬
‫• ניתן גם כאן לצמצם שטח על ידי פיצול לשני ‪PLAs‬‬
‫‪28‬‬
‫‪December 2013‬‬
‫שימוש במונה לכתובת המצב הבא‬
Control unit
PLA or ROM
Outputs
16
Input
PCWrite
PCWriteCond
IorD
MemRead
MemWrite
IRWrite
BWrite
MemtoReg
PCSource
ALUOp
ALUSrcB
ALUSrcA
RegWrite
RegDst
AddrCtl
4
1
State
4
Adder
4
Op[5– 0]
Address select logic
6
2
‫מחליף את הזכרון‬
4K ‫בגודל‬
‫כל מצב יודע לאן הוא‬
‫ סדרתי‬:‫אמור להמשיך‬
,‫או לטבלת קפיצה‬
‫כפונקציה של המצב‬
)‫הנוכחי (מיקרו פקודה‬
‫את זה נדרש לתכנן‬
Instruction register
opcode field
December 2013
29
‫ייעול בחירת המצב הבא‬
‫• כזכור‪ ,‬בדיאגרמת המצבים יש רק שני מקומות עם‬
‫פיצול‪:‬‬
‫‪0‬‬
‫‪1J‬‬
‫‪BEQ‬‬
‫‪L/S‬‬
‫‪R‬‬
‫‪2‬‬
‫‪6 8 9‬‬
‫‪SW‬‬
‫‪LW‬‬
‫‪3 5 7‬‬
‫‪4‬‬
‫• לכן נשתמש בשתי טבלאות קפיצה‬
‫‪30‬‬
‫‪December 2013‬‬
‫מעגל בחירת הכתובת‬
PLA or ROM
4
4
1
State
Adder
3
4
Mux
2 1
4
2
0
0
Dispatch ROM 2
AddrCtl
4
4
Dispatch ROM 1
6
Address select logic
Op
6
Instruction register
opcode field
December 2013
31
‫טבלאות בחירת הכתובת‬
1 ‫ לקפיצה ממצב מספר‬1 ‫• טבלה‬
2 ‫ לקפיצה ממצב מספר‬2 ‫• טבלה‬
Dispatch ROM 1
Dispatch ROM 2
Op
Name
Value
0
R-type
6
2
jmp
9
Op
Name
Value
4
beq
8
35
Lw
3
35
lw
2
43
Sw
5
43
sw
2
December 2013
32
‫בקרת בחירת הכתובת‬
State number
Address control action
Value of
AddrCtl
0
Increment
3
1
Use dispatch ROM 1
1
2
Use dispatch ROM 2
2
3
Increment
3
4
Go to state 0
0
5
Go to state 0
0
6
Increment
3
7
Go to state 0
0
8
Go to state 0
0
9
Go to state 0
0
December 2013
33
"‫קוד‬-‫בקר "מיקרו‬
Control unit
Microcode memory
Outputs
Input
PCWrite
PCWriteCond
IorD
MemRead
MemWrite
IRWrite
BWrite
MemtoReg
PCSource
ALUOp
ALUSrcB
ALUSrcA
RegWrite
RegDst
AddrCtl
Datapath
1
Microprogram counter
Adder
Op[5– 0]
Address select logic
Instruction register
opcode field
December 2013
34
‫מיקרו‪-‬קוד‬
‫• מונה מיקרו‪-‬תכנית (‪ ,)mPC‬דומה למונה התוכנית (‪)PC‬‬
‫• מספר מיקרו‪-‬פקודות מבוצעות על מנת לממש פקודת מכונה‬
‫אחת‬
‫– שם אחר‪ :‬מיקרו‪-‬תכנית‪ ,‬או מיקרו‪-‬סברוטינה‬
‫• קל יותר לממש פקודות מסובכות ע"י קטעי מיקרו‪-‬תכנית מאשר‬
‫ע"י דיאגרמת המצבים‬
‫– דיאגרמות מצבים נעשות קשות לקריאה (ולכן מועדות לשגיאות)‬
‫– כותבים מיקרו‪-‬קוד סימבולי ומשתמשים במיקרו‪-‬אסמבלר‪ .‬אין צורך לנהל‬
‫סיביות משעממות‬
‫• מרבית המחשבים ממומשים בצורה זו‬
‫– לפעמים המיקרו‪-‬קוד מאוכסן ב‪ ROM-‬או ממומש ב‪PLA-‬‬
‫– לפעמים המיקרו‪-‬קוד מאוכסן ב‪ RAM-‬ואז ניתן גם לשנותו ‪ /‬לשדרגו‬
‫• למה בכלל חשוב לשדרג מיקרו‪-‬קוד?‬
‫‪35‬‬
‫‪December 2013‬‬
‫תכנית‬-‫הבקר בצורת מיקרו‬
1
0
L/S
2
LW
R
BEQ
J
6 8 9
SW
3 5 7
4
STATE
0
1
2
3
4
5
6
7
8
9
Label
Fetch
Mem1
LW2
ALU
control
Add
Add
Add
SRC1
PC
PC
A
Register
control
SRC2
4
Extshft Read
Extend
PCWrite
Memory
control
Read PC ALU
Read ALU
Write MDR
SW2
Rformat1 Func code A
Write ALU
B
Write ALU
BEQ1
JUMP1
Subt
December 2013
A
B
ALUOut-cond
Jump address
Sequencing
Seq
Dispatch 1
Dispatch 2
Seq
Fetch
Fetch
Seq
Fetch
Fetch
Fetch
36
‫פקודה‬-‫פורמט מיקרו‬
Field name
ALU control
SRC1
SRC2
Value
Add
Subt
Func code
PC
A
B
4
Extend
Extshft
Read
ALUOp = 10
ALUSrcA = 0
ALUSrcA = 1
ALUSrcB = 00
ALUSrcB = 01
ALUSrcB = 10
ALUSrcB = 11
Write ALU
RegWrite,
RegDst = 1,
MemtoReg = 0
RegWrite,
RegDst = 0,
MemtoReg = 1
MemRead,
lorD = 0
MemRead,
lorD = 1
MemWrite,
lorD = 1
PCSource = 00
PCWrite
PCSource = 01,
PCWriteCond
PCSource = 10,
PCWrite
AddrCtl = 11
AddrCtl = 00
AddrCtl = 01
AddrCtl = 10
Register
control
Write MDR
Read PC
Memory
Read ALU
Write ALU
ALU
PC write control
ALUOut-cond
jump address
Sequencing
Signals active
ALUOp = 00
ALUOp = 01
Seq
Fetch
Dispatch 1
Dispatch 2
December 2013
Comment
Cause the ALU to add.
Cause the ALU to subtract; this implements the compare for
branches.
Use the instruction's function code to determine ALU control.
Use the PC as the first ALU input.
Register A is the first ALU input.
Register B is the second ALU input.
Use 4 as the second ALU input.
Use output of the sign extension unit as the second ALU input.
Use the output of the shift-by-two unit as the second ALU input.
Read two registers using the rs and rt fields of the IR as the register
numbers and putting the data into registers A and B.
Write a register using the rd field of the IR as the register number and
the contents of the ALUOut as the data.
Write a register using the rt field of the IR as the register number and
the contents of the MDR as the data.
Read memory using the PC as address; write result into IR (and
the MDR).
Read memory using the ALUOut as address; write result into MDR.
Write memory using the ALUOut as address, contents of B as the
data.
Write the output of the ALU into the PC.
If the Zero output of the ALU is active, write the PC with the contents
of the register ALUOut.
Write the PC with the jump address from the instruction.
Choose the next microinstruction sequentially.
Go to the first microinstruction to begin a new instruction.
Dispatch using the ROM 1.
Dispatch using the ROM 2.
37
‫ התמונה הכללית‬:‫חלופות הבקרה‬
Initial
representation
Finite state
diagram
Microprogram
Sequencing
control
Explicit next
state function
Microprogram counter
+ dispatch ROMS
Logic
representation
Logic
equations
Truth
tables
Implementation
technique
Programmable
logic array
Read only
memory
December 2013
38
‫השוואת מחזור יחיד לריבוי מחזורים‬
‫• מחשב בעל מחזור שעון יחיד‬
‫– יותר חומרה‬
‫– יותר איטי‬
‫– אולי פחות הספק‬
‫• מחשב בעל ריבוי מחזורי שעון‬
‫– חסכון בחומרה (אבל יותר רגיסטרים)‬
‫– יותר מהיר‬
‫– יותר הספק‪ :‬פעולות ספקולטיביות‬
‫• בקר מתוחכם‬
‫– מיקרו‪-‬קוד קבוע או ניתן לשדרוג‬
‫‪39‬‬
‫‪December 2013‬‬