Chapter

Transkrypt

Chapter
Przetwarzanie potokowe
– pipilining
(część B)
Slajdy są tłumaczeniami (z pewnymi przeróbkami) slajdów do podręcznika Hennessyego i Pattersona ,,Computer Organisation and Design''
§4.6 Pipelined Datapath and Control
MIPS – podział procesora
MEM
WB
Chapter 4 — The Processor — 2
Rejestry ,,potokowe''

Dodajemy rejestry rodzielające fazy

informacje wyprodukowane cykl wcześniej
Chapter 4 — The Processor — 3
IF dla Load, Store, …
Chapter 4 — The Processor — 4
ID dla Load, Store, …
Chapter 4 — The Processor — 5
EX dla Load
Chapter 4 — The Processor — 6
MEM dla Load
Chapter 4 — The Processor — 7
WB dla Load
Zły
numer
rejestru
Chapter 4 — The Processor — 8
Poprawione połączenia
Chapter 4 — The Processor — 9
EX dla Store
Chapter 4 — The Processor — 10
MEM dla Store
Chapter 4 — The Processor — 11
WB dla Store
Chapter 4 — The Processor — 12
Diagram ,,wielocyklowy''

Pokazuje wykorzystanie jednostek CPU
Chapter 4 — The Processor — 13
Diagram ,,wielocyklowy''

Postać tradycyjna
Chapter 4 — The Processor — 14
Diagram ,,jednocyklowy''

Pokazuje stan potoku w danym cyklu
Chapter 4 — The Processor — 15
Sygnały sterujące
Chapter 4 — The Processor — 16
Jednostka sterująca

Sygnały sterujące na podstawie rozkazu

Tak jak w implementacji jednocyklowej
Chapter 4 — The Processor — 17
Jednostka sterująca
Chapter 4 — The Processor — 18

Rozważmy program:
sub
and
or
add
sw

$2, $1,$3
$12,$2,$5
$13,$6,$2
$14,$2,$2
$15,100($2)
Hazardy można rozwiązać forwardingiem

§4.7 Data Hazards: Forwarding vs. Stalling
Hazardy danych dla rozkazów ALU
Jak wykryć kiedy forwarding jest potrzebny?
Chapter 4 — The Processor — 19
Zależności i forwardowanie
Chapter 4 — The Processor — 20
Warunki forwardowania

Numery rejestrów wędrują w potoku


Numery rejestrów dla ALU w fazie EX:


np., ID/EX.RegisterRs = numer rejestru Rs w
rejestrze potokowym ID/EX
ID/EX.RegisterRs, ID/EX.RegisterRt
Hazard danych gdy:
1a. EX/MEM.RegisterRd = ID/EX.RegisterRs
1b. EX/MEM.RegisterRd = ID/EX.RegisterRt
2a. MEM/WB.RegisterRd = ID/EX.RegisterRs
2b. MEM/WB.RegisterRd = ID/EX.RegisterRt
Forward.
z
EX/MEM
Forward
z
MEM/WB
Chapter 4 — The Processor — 21
Warunki forwardowania

Ale tylko, gdy poprzedni rozkaz zapisuje
do rejestru!


EX/MEM.RegWrite, MEM/WB.RegWrite
I tylko, gdy Rd dla tego rozkazu nie jest
rejestrem $zero

EX/MEM.RegisterRd ≠ 0,
MEM/WB.RegisterRd ≠ 0
Chapter 4 — The Processor — 22
Ścieżki forwardowania
Chapter 4 — The Processor — 23
Warunki forwardowania

EX hazard



if (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
ForwardA = 10
if (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
ForwardB = 10
MEM hazard


if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0)
and (MEM/WB.RegisterRd = ID/EX.RegisterRs))
ForwardA = 01
if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0)
and (MEM/WB.RegisterRd = ID/EX.RegisterRt))
ForwardB = 01
Chapter 4 — The Processor — 24
Podwójny hazard danych

Rozważmy sekwencję rozkazów:
add $1,$1,$2
add $1,$1,$3
add $1,$1,$4

Trzeci rozkaz wykryje dwa hazardy


Forwardujemy tylko z drugiego razkazu
Poprawiamy warunek hazardu typu MEM

Forwarduj tylko, gdy hazard typu EX nie został
wykryty
Chapter 4 — The Processor — 25
Poprawiony warunek forward.

MEM hazard

if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0)
and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
and (MEM/WB.RegisterRd = ID/EX.RegisterRs))
ForwardA = 01

if (MEM/WB.RegWrite and (MEM/WB.RegisterRd ≠ 0)
and not (EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
and (MEM/WB.RegisterRd = ID/EX.RegisterRt))
ForwardB = 01
Chapter 4 — The Processor — 26
Procesor z forwardingiem
Chapter 4 — The Processor — 27
Hazard danych z lw
Potrzebne
wstrzymanie
na 1 cykl
Chapter 4 — The Processor — 28
Wykrywanie hazardu z lw


Wykrywane w fazie ID kolejnego rozkazu
Rejestry źródłowe dla ALU w fazie ID są w


Hazard ,,po lw'', gdy


IF/ID.RegisterRs, IF/ID.RegisterRt
ID/EX.MemRead and
((ID/EX.RegisterRt = IF/ID.RegisterRs) or
(ID/EX.RegisterRt = IF/ID.RegisterRt))
Po wykryciu wstrzymanie potoku na 1 cykl
Chapter 4 — The Processor — 29
Jak wstrzymać potok

Ustaw sygnały sterujące w rejestrze
ID/EX na 0


EX, MEM and WB nic wtedy nie zrobią!
Zabloku zapis do PC oraz rejestru IF/ID



Aktualna instrukcja zostanie ponownie
zdekodowana
Kolejna zostanie ponownie pobrana
Opóźnienie o 1 cykl pozwala odczytać dane
przez lw
Które zostaną przeforwardowane do EX
Chapter 4 — The Processor — 30
Opóźnienie w potoku
Opóźnienie
wstawione
tutaj
Chapter 4 — The Processor — 31
Opóźnienie w potoku
Dokładniej...
Chapter 4 — The Processor — 32
Wykrywanie hazardów
Chapter 4 — The Processor — 33

Podobne dokumenty