Computer Organization & Architecture · Problem type

CPI with stalls

Use this for “Loads are 25% of instructions and 40% of them stall 1 cycle; branches are 20%, 10% mispredicted at 3 cycles. Find the CPI.”

Diagram

12345678lw x1, 0(x2)IFIDEXMEMWBadd x3, x1, x4IFIDEXMEMWBsub x5, x3, x6IFIDEXMEMWB○ = a stall (bubble) · arrow = forwarded result8 cycles
k + n − 1 + stalls = 5 + 3 − 1 + 1 = 8 cycles.
This is an example. Type your own values to start a new problem.
CPI
=
1
+
fL (%)
×
u (%)
×
sL
+
fB (%)
×
m (%)
×
P
fL and fB are the shares of all instructions that are loads and branches; the diagram draws one load-use stall, sL bubbles before add’s EX.

Formulas

CPI
=
1
+
(fL
×
u
×
sL
+
fB
×
m
×
P
)
÷
10,000
1.16
=
1
+
25 × 40 × 1 + 20 × 10 × 3
10,000

Assumptions

•
Without hazards the pipeline finishes one instruction every cycle, so the ideal CPI is 1.
•
A load-use stall comes when the next instruction needs the loaded value; with forwarding it costs one bubble.
•
A mispredicted branch flushes the instructions fetched after it, costing P cycles.
•
Rates are percents: u is a share of the loads and m a share of the branches.

Step-by-step

WE KNOW
fL = 25%, u = 40%, sL = 1, fB = 20%, m = 10%, P = 3
FIND
cycles per instruction (CPI)
Step 1 · Find cycles per instruction (CPI)
Use CPI = 1 + (fL × u × sL + fB × m × P) ÷ 10,000
Each kind of stall adds its share of instructions times the cycles it costs to the ideal 1; ÷ 10,000 turns two percents into a fraction.
CPI
=
1
+
25 × 40 × 1 + 20 × 10 × 3
10,000
CPI
=
1
+
1,000 + 200 × 3
10,000
CPI
=
1
+
1,000 + 600
10,000
CPI
=
1
+
1,600
10,000
CPI = 1 + 0.16
CPI = 1.16
Check
Put the numbers back in. Both sides should match.
1.16
=
1
+
25 × 40 × 1 + 20 × 10 × 3
10,000
✓
Topic check
See what you know: 5 questions on this topic
New questions each time. Pass to mark it complete.

Related lessons

© 2026 SME. All rights reserved.