Wykład 5

Transkrypt

Wykład 5
PCWriteCond
PCSource
PCWrite
ALUOp
Outputs
IorD
ALUSrcB
MemRead
ALUSrcA
Control
MemWrite
RegWrite
MemtoReg
IRWrite
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
4
Write
data
0
M
u
x
1
16
Sign
extend
32
Shift
left 2
Jump
address [31-0]
Zero
ALU ALU
result
0
1 M
u
2 x
3
ALU
control
Instruction [5-0]
Architektura typu multi–cycle
x
2
PC [31-28]
0
M
u
x
1
A
28
1 u
ALUOut
• Idea sterowania mikroprogramowalnego opiera się na realizacji sterowania w
postaci pamięci o n-bitowych słowach zwanych mikroinstrukcjami, które reprezentują wartości linii sterujących mikroprocesora, i która jest adresowana przez
licznik mikroinstrukcji.
• W kolejnych cyklach zegara, mikroinstrukcje są podawane na wyjście pamięci
zapewniając prawidłową realizację każdej instrukcji.
• Sekwencje mikroinstrukcji realizujące wszystkie instrukcje procesora nazywa się
mikroprogramem.
• Niektóre mikroinstrukcje mogą być wspólne dla instrukcji mikroprocesora, co
ogranicza pamięć mikroprogramu, a liczba wszystkich mikroinstrukcji może być
równa liczbie stanów maszyny stanowej.
• Mikroprogram musi mieć możliwość zarówno wykonywania sekwencyjnego, jak
i wykonywania skoków bezwarunkowych i warunkowych wewnątrz mikrokodu, w
zależności od typu (opcode’u) wykonywanej instrukcji.
Microcode
storage
Datapath
control
outputs
Outputs
Input
1
Microprogram counter
Sequencing
control
Adder
Address select logic
Inputs from instruction
register opcode field
Mikroprogramowalna jednostka sterująca
1
Microprogram
counter
Sequencing
0
Jump
table 2
3 - Seq
2 - Jump Table 2
1 - Jump Table 1
0 - Fetch
Jump
table 1
Address
select block
Instruction opcode
Sterowanie mikroprogramu — Sequencing
Label
ALU
control
SRC1
SRC2
Add
Sub
Funct code
Labels from
jump tables
and label 0 (Fetch)
Reg
control
Memory
Read
Write ALU
Write MDR
PC
A
B
4
lw-st offset
branch offset
PCWrite
control
Sequencing
ALU
ALUOut-cond
Jump
Read PC
Read ALU
Write ALU
Linia mikroprogramu
Seq
Fetch (0)
Jump Table 1
Jump Table 2
ALU Op ALUSrcA
(2 bits)
MemRead
MemWrite
ALUSrcB RegWrite
MemToReg
IorD
(2 bits)
RegDst
IRWrite
PCWrite
PCWriteCond
PCSource (2 bits)
Sequencing
control (2 bits)
Label
ALU
control
SRC1
SRC2
Add
Sub
Funct code
Labels from
jump tables
and label 0 (Fetch)
Reg
control
Memory
B
4
lw-st offset
branch offset
Sequencing
ALU
ALUOut-cond
Jump
Read
Write ALU
Write MDR
PC
A
PCWrite
control
Read PC
Read ALU
Write ALU
Linie sterujące pól mikrokodu
Seq
Fetch (0)
Jump Table 1
Jump Table 2
Label
Fetch
ALU
control
Add
Add
SRC1
SRC2
PC
4
PC
branch
offset
Reg
control
Memory
PCWrite
control
Read PC
Read
Mikroprogram dla fazy Fetch i Decode
ALU
Sequencing
Seq
Jump
Table1
Label
Fetch
Mem1
ALU
control
SRC1
SRC2
Add
PC
4
Add
PC
Add
A
branch
offset
ls-sw
offset
Reg
control
Memory
PCWrite
control
Sequencing
Read PC
ALU
Seq
Jump
Table1
Jump
Table2
Read
LW2
Seq
ReadALU
WriteMDR
SW2
Rtype1
Fetch
WriteALU
Func cod
A
Fetch
B
Seq
WriteALU
Beq1
Sub
A
B
Jump1
Kompletny mikroprogram
Fetch
ALUOut
cond.
Fetch
Jump
Fetch
Jump Table 1
Opcode
Label
Jump Table 2
Opcode
Label
Rtype
Rtype1
Load
LW2
Jump
Jump1
Store
SW2
Beq
Beq1
Load
Mem1
Store
Mem1
Tablice skoków mikroprogramu
Sytuacje wyjątkowe — Exceptions/Interrupts
• Sytuacja wyjątkowa — nieoczekiwane zdarzenie, wymagające zmiany sekwencji wykonywanych instrukcji, tj. wywołania procedury
obsługi zdarzenia
• Dwa rozwiązania obsługi sytuacji wyjątkowych:
– skok do adresu związanego z daną sytuacją wyjątkową
– zapisanie do rejestru numeru sytuacji wyjątkowej i skok do wspólnego adresu procedury obsługi
• Realizacja sytuacji wyjątkowych (wariant 2)
– rejestr EPC (Exception Program Counter )
– rejestr Cause — numer sytuacji wyjątkowej
– linie sterujące CauseWrite, IntCause, EPCWrite
Realizacja sytuacji wyjątkowych
• nielegalna instrukcja — Cause=0 — próba wykonania instrukcji,
której pole opcode nie odpowiada żadnej instrukcji
• przepełnienie arytmetyczne — Cause=0 — generacja bitu overflow
przez sumator w czasie wykonywania instrukcji arytmetycznych
• adres wspólnej procedury obsługi $C0000000 do PC
CauseWrite
IntCause
EPCWrite
PCSource
ALUOp
PCWriteCond
PCWrite
IorD
Outputs
MemRead
MemWrite
ALUSrcB
Control
ALUSrcA
MemtoReg
IRWrite
RegWrite
Op
[5-0]
RegDst
0
26
Instruction [25-0]
PC
0
M
u
x
1
Shift
left 2
Instruction
[31-26]
Address
Memory
MemData
Read
register 1
Instruction
[20-16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Write
data
Instruction
register
Instruction
[15-0]
Memory
data
register
0
M
Instruction u
x
[15-11]
1
B
0
M
u
x
1
Zero
ALU ALU
result
ALUOut
1M
u
2 x
3
0
1
16
Sign
extend
32
Shift
left 2
3
EPC
0
4
Write
data
u
x
PC [31-28]
0
M
u
x
1
A
1M
2
CO 00 00 00
Instruction
[25-21]
Instruction
[15-0]
28
Jump
address [31-0]
0
M
u
x
1
ALU
control
Instruction [5-0]
Implementacja sytuacji wyjątkowych w architekturze multi-cycle
Cause
Instruction decode/
Register fetch
1
Instruction fetch
0
MemRead
ALUSrcA = 0
IorD = 0
IRWrite
ALUSrcB = 01
ALUOp = 00
PCWrite
PCSource = 00
ALUSrcA = 0
ALUSrcB = 11
ALUOp = 00
(Op
W')
= 'L
6
ALUSrcA = 1
ALUSrcB = 00
ALUOp = 00
8
ALUSrcA = 1
ALUSrcB = 00
ALUOp = 10
EQ
')
'B
=
p
Branch
completion
ALUSrcA = 1
ALUSrcB = 00
ALUOp = 01
PCWriteCond
PCSource = 01
Jump
completion
9
PCWrite
PCSource = 10
p
(O
=
Memory
access
3
')
W
'S
(Op = 'LW')
(O
')
'SW
Execution
(O
=
Op
or (
r)
the
=o
Memory address
computation
2
p
(O
e)
-typ
R
p=
(Op = 'J')
Start
Memory
access
5
MemRead
IorD = 1
R-type completion
7
MemWrite
IorD = 1
11
RegDst = 1
RegWrite
MemtoReg = 0
Overflow
IntCause = 1
CauseWrite
ALUSrcA = 0
ALUSrcB = 01
ALUOp = 01
EPCWrite
PCWrite
PCSource = 11
10
IntCause = 0
CauseWrite
ALUSrcA = 0
ALUSrcB = 01
ALUOp = 01
EPCWrite
PCWrite
PCSource = 11
Write-back step
4
Overflow
RegWrite
MemtoReg = 1
RegDst = 0
Sterowanie z uwzględnieniem sytuacji wyjątkowych