0% found this document useful (0 votes)
23 views36 pages

DigitalLogic ComputerOrganization L18 PipelinedProcessorP2 Handout

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views36 pages

DigitalLogic ComputerOrganization L18 PipelinedProcessorP2 Handout

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

DIGITAL LOGIC AND

COMPUTER ORGANIZATION
Lecture 18: Pipelined Microprocessor (P2)
ELEC3010
ACKNOWLEGEMENT

I would like to express my special thanks to Professor Zhiru Zhang


School of Electrical and Computer Engineering, Cornell University
and Prof. Rudy Lauwereins, KU Leuven for sharing their teaching
materials.

2
COVERED IN THIS COURSE
❑ Binary numbers and logic gates
❑ Boolean algebra and combinational logic
❑ Sequential logic and state machines
❑ Binary arithmetic
Digital logic
❑ Memories

❑ Instruction set architecture


❑ Processor organization Computer
❑ Caches and virtual memory
❑ Input/output Organization
❑ Advanced topics
3
PIPELINED MICROPROCESSOR

4
REVIEW: DATA HAZARD PROBLEM

5
REVIEW: COMPILER INSERTS NOPS (SOLUTION 1)

6
EXAMPLE: DATA HAZARDS
❑ How many NOPs need to be inserted to avoid data
hazards in the following instruction sequence

SUB R4, R2, R3


SUB R4, R2, R3 NOP
ADD R1, R1, 1 NOP
ADDI R2, R4, 1 ADD R1, R1, 1
OR R5, R3, R4 ADDI R2, R4, 1
OR R5, R3, R4
7
REVIEW: HW STALLS THE PIPELINE (SOLUTION 2)

8
SOLUTION 3: HW FORWARDING (BYPASSING)

How to forward to the AND instruction?


9
SOLUTION 3: HW FORWARDING (BYPASSING)

10
PIPELINED MICROPROCESSOR W/O FORWARDING

11
PIPELINED PROCESSOR WITH FORWARDING

12
FORWARDING IN ACTION

13
FORWARDING IN ACTION

14
FORWARDING IN ACTION

15
HW FORWARDING

16
EXAMPLE: DATA HAZARDS W/O FORWARDING
❑ Identify all data hazards in the following instruction
sequences by circling each source register that is read
before the updated value is written back

ADD R1, R2, R3


OR R4, R1, R3
SUB R5, R2, R1
AND R6, R1, R2

17
EXAMPLE: DATA HAZARDS W/ FORWARDING
❑ Identify all data hazards in the following instruction
sequences by circling each source register that is read
before the updated value is written back

ADD R1, R2, R3


OR R4, R1, R3
SUB R5, R2, R1
AND R6, R1, R2

Data hazards resolved by R-type to R-type forwarding


18
ANOTHER EXAMPLE: DATA HAZARDS W/
FORWARDING
❑ Identify all data hazards in the following instruction
sequences by circling each source register that is read
before the updated value is written back

LW R1, 0(R2)
OR R4, R1, R3
SUB R5, R2, R1

19
DATA HAZARDS CAUSED BY LOAD

20
LOAD INSTRUCTIONS AND FORWARDING

21
SOLUTION 2: HW STALLS THE PIPELINE

22
SOLUTION 3: DELAY SLOTS

❑ A delay slot is a location in the program where the compiler


is required to insert an instruction between dependent
instructions
❑ The ISA defines the delay slots
❑ The compiler can fill delay slots with NOPs
❑ Even better: Move a non-dependent instruction from
elsewhere in the program into the delay slot
– Doing so must not change the function of the program

23
EXAMPLE 1: FILLING THE LOAD DELAY SLOT

24
EXAMPLE 2: FILLING THE LOAD DELAY SLOT ?

The ADDI instruction cannot be moved to the delay slot due to data dependence on AND
25
THE PROBLEM WITH BRANCHES

26
THE PROBLEM WITH BRANCHES

27
CONTROL HAZARD

28
REDUCING THE BRANCH DELAY

❑We already calculate the branch target in ID

❑Put dedicated hardware to also evaluate the condition


in ID

29
EVALUATING BRANCH CONDITION IN ID STAGE

30
BRANCH DELAY SLOT

❑ If the ISA defines a branch delay slot, the instruction


immediately following a branch is always executed after
the branch
❑ The compiler finds an instruction to put there, or puts in
a NOP
❑ The hardware must execute the instruction immediately
following the branch, regardless of whether the branch is
taken or not

31
FILLING THE BRANCH DELAY SLOT WITH A NOP

32
FILLING THE BRANCH DELAY SLOT

33
BRANCH TARGET ADDRESS (PC+2+OFF)

34
CAN YOU DO IT?

35
BEFORE NEXT CLASS

• Next time:
More Pipelined Microprocessor

36

You might also like