5.5.1 · D3 · HinglishEmbedded Systems & Real-Time Software

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

2,856 words13 min read↑ Read in English

5.5.1 · D3 · Coding › Embedded Systems & Real-Time Software › Microcontroller architecture — ARM Cortex-M series (M0, M3,

Yeh page parent note ke ideas ke liye ek bada practice arena hai. Yahan hum koi naya theory nahi seekhenge — balki parent ne jo teen formulas banaye hain (pipeline cycles, superscalar IPC, interrupt latency), unhe har us corner case mein push karenge jo ek real embedded engineer ko milti hai: chhoti inputs, badi inputs, "trap" answer, degenerate answer, word problem, aur exam twist.

Kisi bhi example se pehle, teen tools ko plain words mein re-state karte hain taaki kuch bhi unexplained na lage.

Recall Teen formulas jo hum baar baar use karenge (parent se)

1. Pipeline cycles. Ek -stage pipeline ek assembly line hai jisme work-stations hain. Pehla instruction saare stations se guzarne ke baad hi finish hota hai; uske baad har instruction ek clock baad finish hoti hai. To instructions ke liye: ek baar ka "pipe fill karo" tax hai.

2. Superscalar IPC. IPC = Instructions Per Cycle. Ek normal core har cycle mein 1 finish karta hai (). Ek dual-issue core (jaise M7) ek saath 2 start kar sakta hai, lekin sirf tab jab instructions ka ek pair itna independent ho. Agar fraction pairs saath chal sakti hain, aur machine -wide hai:

3. Interrupt latency. Jab interrupt fire hota hai, CPU ko (a) use notice karna hota hai, (b) 8 registers stack karne hote hain, aur (c) wait karna hota hai agar koi zyada urgent cheez already chal rahi ho:

Upar har symbol (, , , , ) ab define ho gaya hai. Acha — ab cases ka map banate hain.


The scenario matrix

Is topic ke har problem ko ek cell mein girta hua socho. Agar hum ek cell mein ek example solve karein, toh reader ko koi unseen scenario nahi milega.

# Case class Kya tricky banata hai Example jo hit karta hai
A Single pass, chhota Fill tax dominate karta hai Ex 1
B Bahut saare passes, bada Fill tax negligible ho jaata hai Ex 2
C Degenerate: ya Formula phir bhi sense banana chahiye Ex 3
D Limiting: Average cycles/instr Ex 3
E Superscalar, vs Dual-issue ke do extremes 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 chal raha hai Ex 5
I Word problem (deadline) Cycles ↔ time convert karo clock ke zariye Ex 6
J Exam twist: double trap Hidden software emulation Ex 7
K Exam twist: deep-pipe misprediction "Zyada stages" ulta pad jaata hai Ex 8

Neeche har figure ek derivation ki geometry carry karta hai — sirf numbers nahi, arrows bhi dekho.


Worked examples

Ex 1 — Cell A: ek pass, fill tax kaata hai

Ex 2 — Cell B: bahut saare passes, tax fade ho jaata hai

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

Ex 4 — Cells E & F: dual-issue ke do extremes aur middle

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

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

Ex 7 — Cell J: 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)
2-stage pipe par ke liye one-pass cycles
1000 passes one pass kyun nahi hota
fill tax sirf ek baar pay hota hai
Dual-issue core ki max IPC
(at )
double M4F par slow kyun hai
uska FPU single-precision only hai, toh double software emulation par fall back karta hai
Deep pipelines branchy code ko kyun hurt karte hain
misprediction refill penalty cycles hai — bada , bada waste