Visual walkthrough — FPGA-based acceleration
6.5.10 · D2· Hardware › Advanced & Emerging Architectures › FPGA-based acceleration
Yeh FPGA-based acceleration ka dhadakta hua dil hai: ek FPGA isliye fast nahi hota kyunki uski clock fast hai, balki isliye kyunki woh ek spatial pipeline bichha sakta hai aur use bhara rakh sakta hai. Aao hum yeh result zero se samjhein.
Step 1 — "Stage" kya hota hai? (assembly line ki picture)
KYA. Socho ek toy car bana rahe ho. Kaam teen jobs mein banta hai: (1) wheels lagao, (2) paint karo, (3) box karo. Har job apne station par hoti hai. Ek station par kaam karne wala worker sirf wahi ek kaam karta hai, hamesha.
KYUN. Ek CPU ek akela worker hai jo ek car par teenon kaam karta hai, puri tarah se, agle car ko haath laganey se pehle — ek aadmi, teen tools, bahut chalna-phirna. Ek pipeline teen workers hai, har ek apne station se chipka hua, car ko line mein aage pass karta hai. Yeh "ek station per job" ka idea exactly waahi hai jo ek FPGA silicon mein karta hai: ek physical circuit per operation. Hum kaam ko stages mein isliye todtey hain taaki har station ek alag car par usi waqt kaam kar sake.
PICTURE. Neeche, teen stations ek row mein baithe hain. Ek car left se enter karti hai, right se nikalti hai. Abhi sirf station 1 busy hai — pipe abhi bhi us ke peechey se khaali hai.

Step 2 — "Clock tick" kya hota hai? (drumbeat)
KYA. Har station apni car ko agley station ko usi ek pal mein pass karta hai — ek shared drumbeat par. Woh beat hi clock hai. Do beats ke beech ka waqt clock period hai, jise likhte hain.
KYUN. Sabhi stations ko saath mein hand off karna padta hai, warna ek adhi-bani car aglay wali se takraayegi. Toh drum utni hi tez beat kar sakta hai jitni tez sabse slow station apna kaam khatam kar sakta hai. Agar painting sabse zyada seconds leta hai, toh
- — beats ke beech seconds (clock period). Chhota = faster clock.
- — sabse slow stage ko kitna waqt chahiye. Yahi pace set karta hai; ek chain utni hi mazboot hoti hai jitna uska sabse kamzor link.
PICTURE. Teen stations, chhoti stopwatches ke saath. Painting (station 2) slow wali hai, toh uski stopwatch sab ke liye drumbeat define karti hai.

Step 3 — Naive tarika: pipeline nahi (ek baar mein ek car)
KYA. Pehle, waqt ko slow tarike se count karo — koi assembly line nahi. Ek car sabhi stations se guzarti hai, shuru se ant tak, aglay car ke enter karne se pehle.
KYUN. Humein compare karne ke liye ek baseline chahiye. CPU yahi karta hai: item 1 poora khatam karo, phir item 2, aur aisa hi aage. Items ki sankhya ko hum kehte hain.
Count, term by term. Ek item ko stages lagte hain, har ek ek beat ka kharcha karta hai, toh ek item = . Yahi items ke liye karo:
- — kitne data items (cars) hum daalte hain.
- — ek item ke liye stages (har item ko abhi bhi sab chahiye).
- — seconds per stage.
- Product = total stage-visits; times = total seconds.
PICTURE. Cars ka ek uncha stack wait kar raha hai. Car 2 tab tak start nahi ho sakti jab tak car 1 teeno stations nahi chod deti. Kisi bhi waqt teen mein se do stations idle bethe hain — waste workers.

Step 4 — Pipeline trick: cars ko overlap karo
KYA. Ab har station ko busy rakho. Jaise hi car 1 station 1 chhodti hai, car 2 station 1 mein enter karti hai — jabki car 1 station 2 par hai. Cars waqt mein overlap karti hain.
KYUN. Step 3 ke woh idle workers hi waste the. Overlapping ka matlab hai ki jab line bhar jaati hai toh saare stations alag cars par kaam kar rahe hote hain. Yahi poora idea hai: pipe bharo, phir kabhi station ko idle mat rehne do.
PICTURE — space-time chart. Yeh key diagram hai. Rows = stations, columns = clock ticks. Har colored block ek car hai jo ek station par ek tick ke liye hai. Diagonal stripes padho: har car diagonally neeche-daayein jaati hai, har tick par ek station. Pipe bhar jaane ke baad, har column poori tarah colored hai — har station har tick par busy.

Step 5 — Pipelined time count karo (bharo, phir har tick ek)
KYA. Step 4 ke diagram mein ticks count karo. Do phases: pipe bharna, phir har tick ek result nikalte rehna.
KYUN. Pehla result free nahi aata — car 1 ko abhi bhi sabhi stations se crawl karna hoga iske pehle koi car finish ho. Yahi fill cost hai. Lekin pehle ke baad har car exactly ek tick baad nikalti hai, kyunki sab overlap hain.
Count, banate hue.
Pipe bharna (pehla result nikalta hai): car 1 ko sabhi stations pass karne mein ticks lagte hain.
Baaki cars mein se har ek exactly ek tick baad apne aage wali car ke finish hoti hai (woh exactly ek beat se overlap hain):
Har tick seconds hai, toh:
- — ek-baar ki fill cost (pehla result aane se pehle ticks).
- — extra ticks, pehle ke baad har item ke liye ek.
- — seconds per tick, poori tick count ko seconds mein multiply karta hai.
PICTURE. Wahi chart, ab do phases shaded hain: left mein ek pale-yellow "fill" triangle length ka, phir ek chalk-blue "steady state" jahan results har column mein ek ek tapak rahe hain.

Step 6 — Speedup, aur yeh ki taraf kyun jaata hai
KYA. Naive time (Step 3) ko pipelined time (Step 5) se divide karo.
KYUN. Speedup "kitni baar faster" hai — purana time naye time se divide. Yeh akela ratio batata hai ki poori exercise worth it thi ya nahi.
Algebra, term by term.
cancel ho jaata hai (dono mein same clock) — pipelining faster clock ke baare mein nahi hai:
- Numerator — total kaam (item-stage visits).
- Denominator — actual ticks jo hum ne pay kiye.
- Unka ratio = useful-work-per-tick vs one-tick-of-clock.
Ab (batch size) ko infinity ki taraf push karo. Top aur bottom dono ko se divide karo:
- — fill cost items par spread out. Jaise badhta hai, yeh ho jaata hai.
- Jo bachta hai woh sirf hai: ek poora speedup.
PICTURE. Speedup vs ka ek curve: woh ke paas shuru hota hai (chhota batch, sab fill), badhta hai, aur par dashed ceiling line ko chhuute hue flat ho jaata hai.

Step 7 — Edge cases: woh corners jahaan intuition phisal jaati hai
KYA. Hum chhoti aur degenerate inputs check karte hain, warna reader formula par wahan trust karega jahan woh galat hoga.
KYUN. Jo formula aap tod nahi sakte, usse aap trust nahi kar sakte. Chaar corners:
(a) Ek item, . Plug in karo: . Bilkul koi speedup nahi! Ek akeli car ke saath, pipeline pure fill hai — aap poore ticks pay karte ho aur kuch gain nahi hota. Yeh latency vs throughput hai: ek item ki latency unchanged rehti hai.
(b) Ek stage, . . Overlap karne ko kuch nahi — ek station pehle se hi poora kaam hai. Pipelining ko help karne ke liye chahiye.
(c) Zero items, . Time — pipe andar se already rakhe leftovers drain karta hai, lekin naive time hai. Speedup undefined hai (); physically, "koi kaam nahi, koi fayda nahi." Khali batch se divide karne se bachao.
(d) Unbalanced stages. Agar ek stage kaafi slow hai, toh usi stage se upar khicha jaata hai aur har doosra station har tick ka kuch hissa idle rehta hai. Formula abhi bhi sahi hai, lekin clock buri hai. Real-world fix hai balancing — slow stage ko todna taaki koi station par dominant na ho.
PICTURE. Chaar mini-panels, har corner ke liye ek: single car (sab fill), single station (koi overlap nahi), khaali batch, aur ek aisi lopsided line jahan mota slow station drum ko rok deta hai.

Step 8 — Real numbers daalte hain (parent ka example, check kiya gaya)
KYA. stages, items, clock MHz use karo toh ns.
KYUN. Ek formula ko numbers ke saath survive karna chahiye.
Naive baseline ns per op, ops per item par:
Hum ceiling se thoda neeche utare — exactly wahi fill toll jo humne Step 6 mein predict ki thi. Picture aur algebra dono agree karte hain.
Recall Poori limit ek line mein bolo
kya hai aur kyun? ::: Yeh hai; ek-baar ki fill cost items par spread ho jaati hai aur gaayab ho jaati hai, puri stage count achievable speedup ke roop mein bachi rehti hai. ke saath, speedup kya hai? ::: Exactly — ek akela item pure fill hai, exploit karne ke liye koi overlap nahi.
Ek-picture summary
Yeh final chalkboard poori kahani compress karta hai: naive stack (workers idle) vs overlapped pipeline (sab workers busy), fill triangle of cost , steady state jo har tick ek result tapkaata hai, aur speedup curve jo apni ceiling tak chadhta hai.

Recall Feynman retelling — bina math ke ek dost ko explain karo
Socho toy cars bana rahe ho. Slow tarika: ek worker ek poori car banata hai — wheels, paint, box — phir aglay pe jaata hai. Teen cars = nau slow kaam ek ke baad ek.
Pipeline tarika: teen workers, har ek apne station se chipka hua. Jaise hi car 1 wheel station chhodti hai, car 2 andar aa jaati hai. Jald hi teeno workers ek saath teen alag cars par busy hote hain. Uske baad, har drumbeat par ek finished car nikalti hai.
Shuru mein ek pareshani hai: pehli car ko abhi bhi teeno stations se crawl karna hoga kuch bhi nikalne se pehle — yahi "fill" hai. Woh toll aap ek baar pay karte ho. Lekin hazaar cars par, ek baar pay karna kuch nahi. Toh ek teen-station line, lambe run mein, lone worker se lagbhag teen guna faster cars nikalti hai — aur barah-station line, lagbhag barah guna. Jaadu ki sankhya sirf aapke paas kitne stations hain hai, — drum kitni tez beat karta hai nahi. Isliye ek slow-clocked FPGA with a deep pipeline ek fast CPU ko flatten kar deta hai: woh har single tick par ek poori computation ke barabar kaam khatam karta hai.
Related build-up: Pipelining and Throughput · Configurable Logic Blocks (LUTs & Flip-Flops) · Dataflow architectures · Roofline Model & Arithmetic Intensity · GPU vs FPGA vs ASIC trade-offs