5.5.1 · D3Embedded Systems & Real-Time Software

Worked examples — Microcontroller architecture — ARM Cortex-M series (M0, M3, M4, M7)

2,695 words12 min readBack to topic

This page is one big practice arena for the ideas in the parent note. We will not learn any new theory here — instead we take the three formulas the parent built (pipeline cycles, superscalar IPC, interrupt latency) and push them into every corner case that a real embedded engineer meets: tiny inputs, huge inputs, the "trap" answer, the degenerate answer, the word problem, and the exam twist.

Before any example, let us re-state the three tools in plain words so nothing appears unearned.

Recall The three formulas we will reuse (from the parent)

1. Pipeline cycles. An -stage pipeline is an assembly line with work-stations. The first instruction must walk through all stations before it finishes; every instruction after it finishes just one clock later. So for instructions: The is the one-time "fill the pipe" tax.

2. Superscalar IPC. IPC = Instructions Per Cycle. A normal core finishes 1 per cycle (). A dual-issue core (like M7) can start 2 at once, but only when a pair of instructions is independent enough. If a fraction of pairs can go together, and the machine is -wide:

3. Interrupt latency. When an interrupt fires, the CPU must (a) notice it, (b) stack 8 registers, and (c) wait if something more urgent is already running:

Every symbol above (, , , , ) is now defined. Good — let us build the map of cases.


The scenario matrix

Think of every problem this topic throws as landing in one cell. If we solve one example per cell, the reader never meets an unseen scenario.

# Case class What makes it tricky Example that hits it
A Single pass, small Fill tax dominates Ex 1
B Many passes, large Fill tax becomes negligible Ex 2
C Degenerate: or Formula must still make sense Ex 3
D Limiting: Average cycles/instr Ex 3
E Superscalar, vs The two extremes of dual-issue Ex 4
F Superscalar realistic Fractional, real-world value Ex 4
G Interrupt latency, no blocking Best case () Ex 5
H Interrupt latency, nested/blocked Worst case, higher-prio running Ex 5
I Word problem (deadline) Convert cycles ↔ time via clock Ex 6
J Exam twist: the double trap Hidden software emulation Ex 7
K Exam twist: deep-pipe misprediction "More stages" backfires Ex 8

Each figure below carries the geometry of one derivation — look at the arrows, not just the numbers.


Worked examples

Ex 1 — Cell A: one pass, the fill tax bites

Ex 2 — Cell B: many passes, tax fades away

Ex 3 — Cells C & D: degenerate and limiting inputs

Ex 4 — Cells E & F: the two extremes and the middle of dual-issue

Ex 5 — Cells G & H: interrupt latency, best and worst

Ex 6 — Cell I: real-world deadline word problem

Ex 7 — Cell J: the double trap (exam twist)

Ex 8 — Cell K: deep pipeline misprediction (exam twist)


Recall

Do :::

Cells-covered
A (Ex1), B (Ex2), C+D (Ex3), E+F (Ex4), G+H (Ex5), I (Ex6), J (Ex7), K (Ex8)
One-pass cycles for on a 2-stage pipe
Why 1000 passes ≠ one pass
the fill tax is paid only once
Max IPC of a dual-issue core
(at )
Why double is slow on M4F
its FPU is single-precision only, so double falls back to software emulation
Why deep pipelines hurt branchy code
misprediction refill penalty is cycles — bigger , bigger waste