You are on page 1of 10

Lecture 14: pipeline (1) Lecturer: Noor Kadhum

GENERAL CONCEPTS

Pipelining refers to the technique in which a given task is


divided into a number of subtasks that need to be performed in
sequence. Each subtask is performed by a given functional unit.
The units are connected in a serial fashion and all of them
operate simultaneously(‫)ﻓﻲ ﻧﻔﺲ اﻟﻮﻗﺖ‬.

The use of pipelining improves the performance compared to


the traditional sequential execution of tasks.

Pipeline Classification
There are two areas of computer design where the
pipeline organization is applicable.
1- Instruction pipeline which is explained in the previous
lecture and the beginning of this lecture.
2- Arithmetic pipeline which divides an arithmetic operation
into sub-operations for execution in the pipeline segments

Pipeline and sequential instructions

Important Laws
1- No. of clock cycle time= n+m-1
where :
n: No. of tasks.
m: No. of segments.

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

2- Total time with pipeline = No. of clock cycle time × tp


= (n+m-1) × tp
where tp : time of the segment.

3- Total time without pipeline ≈ n × m × tp

Total time without pipeline


4- Speed up = ‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Total time with pipeline

where speed up is a performance measure that quantify (‫)ﯾﻘ ﯿﺲ‬


the performance when using the pipeline.
Examples :
1- Compute the total time required to execute (4)
instruction with and without pipeline (suppose the pipe
have 4 segments). the time of each segments is (25 ns).
Solution:
n= 4
m=4
tp =25 ns

1- Total time with pipeline = No. of clock cycle time × tp


= (n+m-1) × tp
= (4+4-1) × 25
= 7 × 25
= 175 ns
where tp : time of the segment.

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

2- Total time without pipeline ≈ n × m × tp


= 4 × 4 × 25
= 400 ns

2- Compute the total time required to execute (5)


instruction with and without pipeline (suppose the pipe
have 5 segments). the time of each segments is (20 ns)
then compute the speed up.

Solution:
n= 5
m=5
tp =20 ns

1- Total time with pipeline = No. of clock cycle time × tp


= (n+m-1) × tp
= (5+5-1) × 20
= 9 × 20
= 180 ns
where tp : time of the segment.

2- Total time without pipeline ≈ n × m × tp


= 5 × 5 × 20
= 500 ns

Total time without pipeline


3- speed up = ‫ــــــــــــــــــــــــــــــــــــــــــــــــــــــ‬
Total time with pipeline

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

= 500 / 180
= 2.777

Gantt’s chart
In order to formulate some performance measures for the
goodness of a pipeline in processing a series of tasks, a space
time chart –table- (called the Gantt’s chart) is used. The chart
shows the succession (‫ )ﺗﻌﺎﻗ ﺐ‬of the subtasks (segments) in the
pipe with respect to time. The following examples will show you
how to use Gantt’s chart for displaying the execution of the
instruction using pipeline:
EXAMPLE1:-
There are (4) instructions ,Use Gantt’s chart to show how
are they executed in the pipeline .Suppose that the pipe have
(4) segment (FI: fetch instruction, DI: decode instruction ,FO:
fetch operands , EX: execution).

SOLUTION:

1 2 3 4 5 6 7
I1 FI DI FO EX
I2 FI DI FO EX
I3 FI DI FO EX
I4 FI DI FO EX

The chart shows that the four instructions need (7) clock cycles .

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

EXAMPLE2:-
There are (5) instructions ,Use Gantt’s chart to show how are
they executed in the pipeline .Suppose that the pipe have (5)
segment (FI: fetch instruction, DI: decode instruction ,FO: fetch
operands , EX: execution , SR: save result).
SOLUTION:-
1 2 3 4 5 6 7 8 9
I1 FI DI FO EX SR
I2 FI DI FO EX SR
I3 FI DI FO EX SR
I4 FI DI FO EX SR
I5 FI DI FO EX SR
The chart shows that the five instructions need (9) clock cycles.

Home work:

There are (6) instructions , Suppose that the pipe have (4)
segment (FI: fetch instruction, DI: decode instruction , EX:
execution , WR: write results to the memory) where each
segment take 15ns :-

1- Use Gantt’s chart to show how are they executed in the


pipeline.

2- Compute the total time with pipeline.

2- Compute the total time without pipeline.

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

3- Compute the speed up ratio.

Pipeline and branch instructions


The pipeline deals with the branch instructions in
different way, As soon as branch instruction is decoded in the
segment of (decoding instruction – DA) , the transfer from
(Fetching instruction –FI) to DI of the other instructions is
halted(‫ )ﺗﺘﻮﻗﻒ‬until the branch instruction is executed .
If the branch is taken , a new instruction is fetched. If the
branch is taken , instruction fetched in the next step can be
used. The pipeline then continues normally until a new branch
instruction is encountered.
Now let's see – in examples what happened if the pipe
encounters (‫ )ﯾﺼﺎدﻓﮫ‬unconditional and conditional instruction :

Unconditional branches
There is on unconditional branch instruction, in some
programming language this instruction is (jmp), in other
language may this type of instruction be (go or goto).
When the pipe encounters such instructions , the pipe empty
itself until the unconditional branch is executed , then start a
new cycle to exexcute the rest of instruction normally.

Example :
Use Gantt chart to show the behaviour of pipeline when (6)
instructions is executed and the third one is unconditional

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

branch instruction. Suppose the each instruction has 4


segments .

SOLUTION
1 2 3 4 5 6 7 8 9 10 11 12
I1 Fi DI FO EX
I2 FI DI FO EX
I3 - - FI DI FO EX
(BRANCH)
I4 - - - - - - FI DI FO EX
I5 - - - FI DI FO EX
I6 FI DI FO DI

Important Laws :

1- No. of clock cycle = (n+m-1)+(No .of branch instruction ×(m -1))


2- Total time with pipe = No. of clock cycle × tp

For example , for the previous chart :


1- No. of clock cycle = (n+m-1)+(No.of branch instruction×(m -1))

= (6+4-1)+(1× (4-1))
= 9+ 3
= 12
2- Total time with pipe = No. of clock cycle × tp
= 12 × tp

Question for you:


Use gantt chart to show the behavior of pipeline when (9)
instructions is executed where the fourth and sixth instruction

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

are unconditional branch instruction. Suppose the each


instruction has 4 segments , each segment takes 15 ns to
execute .
Conditional branches
The conditional branch has two cases :
- The condition is achieved .
- The condition is not achieved .

note that In the first case the instruction behave as if it was an


(unconditional) branch instruction. Anyway, you must draw 2k
charts ,where k is the N0. Of conditional branch instructions,
i.e. :
- If we have two conditional branch instructions

We draw 22 =4 charts. Why ?


Because we have 4 possibilities as shown in the following
table :
The first The second
condition branch condition branch
Not Happened Not Happened
Not Happened Happened
Happened Not Happened
Happened Happened

- If we have three conditional branch instructions


We draw 23 =8 charts, shown in the following table :

The first The second The third


condition branch condition branch condition branch

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

Not Happened Not Happened Not Happened


Not Happened Not Happened Happened
Not Happened Happened Not Happened
Not Happened Happened Happened
Happened Not Happened Not Happened
Happened Not Happened Happened
Happened Happened Not Happened
Happened Happened Happened

Example :
Use Gantt chart to show the behaviour of pipeline when (6)
instructions is executed and the third one is conditional branch
instruction. Suppose the each instruction has 4 segments .
Sol :
There was only one conditional instruction ,
so we draw 21 = 2 charts
The first chart when the branch condition is achieved :
1 2 3 4 5 6 7 8 9 10 11 12
1 Fi DI FO EX
2 FI DI FO EX
3 - - FI DI FO EX
(BRANCH)
4 - - - - - - FI DI FO EX
5 - - - FI DI FO EX
6 FI DI FO DI

Babylon university - Sciences College For Women - Architecture – Third class


Lecture 14: pipeline (1) Lecturer: Noor Kadhum

The second chart if the condition is not met :


1 2 3 4 5 6 7 8 9
1 Fi DI FO EX
2 FI DI FO EX
3 - - FI DI FO EX

4 - - - FI DI FO EX
5 - - - - FI DI FO EX
6 - - - - - FI DI FO EX

Questions for discussion :


1- Formulate a Law to get the No. of clock cycle without pipe if
there are branch instructions .
2- Formulate a Law to get the speed up ratio.

Babylon university - Sciences College For Women - Architecture – Third class