Exercises — FPGA-based acceleration
6.5.10 · D4· Hardware › Advanced & Emerging Architectures › FPGA-based acceleration
Teen formulas jin par hum poore page bhar rely karte hain — restate kiye gaye taaki kuch bhi use hone se pehle dikhaya ja sake:
Yahan (clock period) clock ke ek tick ka time hai; agar clock frequency hai (ticks per second) toh . ka period matlab , kyunki ticks/s.
Level 1 — Recognition
Exercise 1.1
Har block ko woh single kaam match karo jiske liye woh exist karta hai: LUT, Flip-Flop, BRAM, DSP slice, Interconnect.
Recall Solution
- LUT (Look-Up Table): ek tiny truth-table memory jo apne inputs ka koi bhi boolean gate ban jaata hai — custom logic ka atom.
- Flip-Flop: ek 1-bit register jo do clock edges ke beech pipeline state hold karta hai.
- BRAM: on-chip SRAM jo data ko compute ke paas rakhta hai taaki slow DRAM trips se bacha jaa sake.
- DSP slice: ek hardwired multiply-accumulate unit; multipliers LUTs se banaye jaayein toh expensive hote hain, isliye inhe harden kiya jaata hai.
- Interconnect: programmable wires + switches jo tumhe blocks ko kisi bhi topology mein connect karne dete hain.
LUT/FF pair in depth ke liye Configurable Logic Blocks (LUTs & Flip-Flops) dekho.
Exercise 1.2
Ek -input LUT kitne output bits store karta hai, aur exactly kyun utne?
Recall Solution
Ek -input LUT bits store karta hai — apne inputs ke har combination ke liye ek output. ke saath: Chhe inputs ke possible input patterns hain; truth table ko har pattern ke liye ek output entry chahiye. Kisi bhi boolean function ka truth table un cells mein likho aur LUT woh function ban jaata hai.
Exercise 1.3
"Field-programmable" — field ka matlab kya hai, aur programming kaunsa physical object karta hai?
Recall Solution
Field = manufacturing ke baad, duniya mein ("field" mein), factory mein bake-in nahi. Programming bitstream se hoti hai: ek configuration file jo har LUT cell aur interconnect switch ko us pattern mein flip karti hai jo tumhara circuit realize karta hai. Compare karo ek ASIC se, jiska logic fabrication par hamesha ke liye fix ho jaata hai.
Level 2 — Application
Exercise 2.1
Ek pipeline mein stages hain aur items clock par stream karta hai. Total time aur serial version par speedup nikalo.
Recall Solution
Cycles: Time: Speedup: Ideal se thoda kam: fill cycles items ke against tiny hain. Yeh Pipelining and Throughput ek line mein hai.
Exercise 2.2
Same pipeline lekin sirf items. Ab speedup kya hai, aur yeh kya lesson deta hai?
Recall Solution
Sirf , nahi. Lesson: fill cost fixed hai; yeh sirf tab negligible hoti hai jab . Short streams fill penalty bahut zyada pay karti hain. Latency (pehla result cycles baad) dominate karta hai jab chhota ho.
Exercise 2.3
Ek FPGA par run karta hai aur har cycle operations complete karta hai. Ek CPU par run karta hai aur har cycle operations complete karta hai. Kiska throughput zyada hai, aur kitna zyada?
Recall Solution
Throughput (ops/cycle) (cycles/second): Ratio: FPGA faster hai baawajood apne bahut kam clock ke — parallelism pipelining raw clock speed ko beat karta hai.
Level 3 — Analysis
Exercise 3.1
Ek kernel ka arithmetic intensity hai aur woh hardware par run karta hai jiska bandwidth aur peak compute hai. Kya yeh compute-bound hai ya memory-bound, aur best achievable kya hai?
Recall Solution
Roofline: . Compare karo se. Kyunki , memory roof lower hai: Tum compute idle chhod rahe ho.
Neeche di gayi figure yeh plot karta hai. Iska horizontal axis ==arithmetic intensity hai ops/byte mein (kitna compute har fetched byte feed karta hai); iska vertical axis performance == hai GOP/s mein (billions of operations per second). Sloped orange line memory roof hai, flat violet line hai, navy line actual attainable roof hai (dono mein se lower), aur magenta dot is kernel ko par sloped (memory) part par mark karta hai — vertical axis se seedha padho. Dekho Roofline Model & Arithmetic Intensity.

Exercise 3.2
Exercise 3.1 ke liye, tum data ko BRAM mein buffer karte ho taaki har byte reuse ho sake, intensity tak raise ho jaaye. recompute karo. Ab limiting factor kya hai?
Recall Solution
Naya memory roof: Ab — compute roof jeetta hai. Design ab compute-bound hai. Roofline plot par (figure s01) operating point "ridge" ke paar right move ho gaya hai jahan sloped memory line flat compute ceiling se milti hai. aur badhane se koi faida nahi; sirf zyada compute units help karenge.
Exercise 3.3
Ek design FPGA ke LUTs use karta hai lekin sirf peak throughput sustain karta hai. Uski intensity roofline ridge ke left hai. Koi propose karta hai ki aur compute units add karo. Kya yeh accha idea hai?
Recall Solution
Nahi. Ridge ke left matlab workload memory-bound hai — bandwidth , compute nahi, ceiling hai. Zyada compute units area aur power add karte hain lekin data ka wait karte hue idle baithte hain. Sahi fix yeh hai ki arithmetic intensity raise karo: BRAM mein data cache/reuse karo, loops tile karo, stream karo taaki har fetched byte kaafi operations feed kare. Bottleneck fix karo, abundant resource nahi.
Level 4 — Synthesis
Exercise 4.1
Ek -tap FIR filter ke liye ek streaming accelerator design karo. Hardware blocks list karo, batao kyun har ek exist karta hai, aur steady-state throughput do.
Recall Solution
Blocks aur unke kaam:
- 16 DSP slices — ek multiply per tap , sab ek hi cycle mein → 16-way spatial parallelism. (Hardened multipliers, LUT-built nahi.)
- Adder tree, levels, har level registered — 16 products ko sum karta hai. Tree ko pipeline karna slowest stage ko chhota rakhta hai taaki clock fast rahe. Yeh dataflow hai.
- ke liye length 16 ka shift register — har cycle ek naya sample shift in hota hai; har stored sample time ke saath ek alag tap feed karta hai. Yeh data reuse deta hai: koi byte DRAM se re-fetch nahi hota, toh intensity high rehti hai.
Throughput: pipeline fill hone ke baad, har clock cycle mein ek . Ek CPU multiply-adds serially per output karta hai, toh speedup , input bandwidth se bounded. Is expression ko C mein express karne ke liye High-Level Synthesis (HLS) dekho.
Exercise 4.2
Exercise 4.1 design ke liye par, samples stream karte hue, pipeline depth (fill) stages hai (1 multiply + 4 adder levels). Total time aur ek serial CPU par speedup compute karo jo ops per sample par karta hai.
Recall Solution
FPGA time: CPU time: Speedup: Sirf baawajood 16 multipliers place karne ke — kyunki FPGA clock period () CPU op time () se hai. Parallelism-16 win partly slower clock se cancel ho jaata hai: . Yeh exactly trade-off hai low clock aur high parallelism ke beech.
Level 5 — Mastery
Exercise 5.1 (degenerate case)
Pipeline speedup kya hai jab ho? Physically interpret karo.
Recall Solution
Speedup har ke liye. Ek "one-stage pipeline" mein overlap karne ke liye kuch nahi hai — sirf ek combinational block hai, koi registers kaam ko split nahi karte, toh pipelining kuch buy nahi karta. Pipelining sirf tab pay karta hai jab ho, aur uska ceiling ke saath badhta hai.
Exercise 5.2 (limiting behaviour, both directions)
fix karo. , , , aur par speedup evaluate karo. Curve ki shape describe karo.
Recall Solution
Curve se rise karta hai (ek item = pure latency, koi overlap nahi) aur horizontal asymptote ki taraf saturate ho jaata hai. Yeh concave hai: pehle fast gains, phir jaise badhta hai diminishing returns.
Neeche di gayi figure exactly yeh curve draw karti hai. Iska horizontal axis ==streamed items ki count== hai (log scale par draw kiya gaya taaki chhota aur bada dono visible ho); iska vertical axis speedup hai (dimensionless, "serial se kitna zyada fast"). Teen sample points aur par dashed asymptote marked hain.

Exercise 5.3 (two-roof crossover — the ridge point)
Ek roofline par jahan aur hai, arithmetic intensity nikalo jahan memory roof compute roof se milti hai ("ridge"). Exactly par ek operating point ka kya matlab hai, aur jo point uske left land kare use kis direction mein move karna chahiye?
Recall Solution
Ridge wahan hai jahan dono roofs equal hain: par design perfectly balanced hai: yeh memory bandwidth aur peak compute dono simultaneously saturate karta hai. ke left ⇒ memory-bound; ke right ⇒ compute-bound. Jo point left of land kare use rightward push karna chahiye — uski intensity raise karo (BRAM mein data buffer aur reuse karo taaki har fetched byte zyada operations feed kare) jab tak ridge tak na pahunche; ke past intensity se aur kuch gain nahi, aur sirf extra compute units help karenge.
Exercise 5.4 (synthesis of both models — when is the FPGA worth it?)
Ek workload items stream karta hai, pipeline stages chahiye, clock . Yeh memory-bound hai: intensity , bandwidth , har item bytes hai aur ops chahiye. Compute karo (a) ideal pipelined compute time, (b) roofline memory-bound time, (c) kaunsa actually govern karta hai — aur explain karo kyun hum total-ops use karte hain, raw bytes nahi.
Recall Solution
(a) Pipelined compute time (assuming data hamesha available hai — sirf compute roof):
(b) Roofline memory-bound time. Kyun sirf bytes nahi? Raw transfer time sirf batata hai wires kitni der busy hain — yeh ignore karta hai ki har byte ko kitna useful compute feed karna hai. Roofline performance ops/s mein measure karta hai, toh honest memory-bound time hai total operations divided by memory-limited op-rate : Dono numbers differ karte hain ( vs ) exactly isliye kyunki yahan har byte op carry karta hai, lekin har item bytes hai phir bhi ops demand karta hai — toh compute-per-byte jo memory roof allow karta hai () real throttle hai, raw byte count nahi. bytes use karna galat claim karta ki kaam mein khatam ho jaayega.
(c) Kaunsa govern karta hai? Ek design apne dono ceilings mein se slower se faster khatam nahi kar sakta. Yahan compute time aur memory-bound time almost equal hain, toh yeh design ridge par bilkul baitha hai — koi bhi roof badly slack nahi hai. Memory roof marginally govern karta hai ( matlab memory dono mein se tighter hai sirf marginally; practice mein wo co-limit karte hain). Faster jaane ke liye tumhe dono uthane honge: raise karo (zyada DRAM channels) aur raise karo (BRAM reuse). Sirf ek improve karna doosre roof ko naya wall bana deta hai.