6.5.10 · D4Advanced & Emerging Architectures

Exercises — FPGA-based acceleration

3,320 words15 min readBack to topic

The three formulas we lean on all page long — restated so nothing is used before it is shown:

Here (the clock period) is the time for one tick of the clock; if the clock frequency is (ticks per second) then . A period of means , because ticks/s.


Level 1 — Recognition

Exercise 1.1

Match each block to the single job it exists for: LUT, Flip-Flop, BRAM, DSP slice, Interconnect.

Recall Solution
  • LUT (Look-Up Table): a tiny truth-table memory that becomes any boolean gate of its inputs — the atom of custom logic.
  • Flip-Flop: a 1-bit register that holds pipeline state between two clock edges.
  • BRAM: on-chip SRAM that keeps data near the compute so you avoid slow DRAM trips.
  • DSP slice: a hardwired multiply-accumulate unit; multipliers are expensive built from LUTs, so they are hardened.
  • Interconnect: programmable wires + switches that let you connect blocks into any topology.

See Configurable Logic Blocks (LUTs & Flip-Flops) for the LUT/FF pair in depth.

Exercise 1.2

A -input LUT stores how many output bits, and why exactly that many?

Recall Solution

A -input LUT stores bits — one output for every combination of its inputs. With : Six inputs have possible input patterns; the truth table needs one output entry per pattern. Write any boolean function's truth table into those cells and the LUT is that function.

Exercise 1.3

"Field-programmable" — what does field mean, and what physical object does the programming?

Recall Solution

Field = after manufacturing, out in the world (the "field"), not baked in at the factory. The programming is done by a bitstream: a configuration file that flips every LUT cell and interconnect switch into the pattern that realises your circuit. Contrast an ASIC, whose logic is fixed forever at fabrication.


Level 2 — Application

Exercise 2.1

A pipeline has stages and streams items at clock . Find the total time and the speedup over the serial version.

Recall Solution

Cycles: Time: Speedup: Just shy of the ideal : the fill cycles are tiny against items. This is Pipelining and Throughput in one line.

Exercise 2.2

Same pipeline but only items. What speedup now, and what lesson does it teach?

Recall Solution

Only , not . Lesson: the fill cost is fixed; it only becomes negligible when . Short streams pay the fill penalty heavily. Latency (first result after cycles) dominates when is small.

Exercise 2.3

An FPGA runs at and completes operations every cycle. A CPU runs at and completes operations every cycle. Which has higher throughput, and by how much?

Recall Solution

Throughput (ops/cycle) (cycles/second): Ratio: The FPGA is faster despite its far lower clock — parallelism pipelining beats raw clock speed.


Level 3 — Analysis

Exercise 3.1

A kernel has arithmetic intensity and runs on hardware with bandwidth and peak compute . Is it compute-bound or memory-bound, and what is the best achievable ?

Recall Solution

Roofline: . Compare to . Since , the memory roof is lower: You are leaving of compute idle.

The figure below plots this. Its horizontal axis is ==arithmetic intensity in ops/byte (how much compute each fetched byte feeds); its vertical axis is performance == in GOP/s (billions of operations per second). The sloped orange line is the memory roof , the flat violet line is , the navy line is the actual attainable roof (the lower of the two), and the magenta dot marks this kernel at sitting on the sloped (memory) part — read straight off the vertical axis. See Roofline Model & Arithmetic Intensity.

Figure — FPGA-based acceleration
Figure s01 — Roofline. X-axis: arithmetic intensity (ops/byte). Y-axis: performance (GOP/s). The magenta dot () sits on the sloped memory roof: memory-bound at . Push intensity right past the ridge () and the violet dot () hits the flat compute ceiling at .

Exercise 3.2

For Exercise 3.1, you buffer data in BRAM to reuse each byte , raising intensity to . Recompute . What is now the limiting factor?

Recall Solution

New memory roof: Now — the compute roof wins. The design is now compute-bound. On the roofline plot (figure s01) the operating point has moved right past the "ridge" where the sloped memory line meets the flat compute ceiling. Raising further no longer helps; only more compute units would.

Exercise 3.3

A design uses of the FPGA's LUTs but sustains only of peak throughput. Its intensity sits left of the roofline ridge. Someone proposes adding more compute units. Good idea?

Recall Solution

No. Left of the ridge means the workload is memory-bound — bandwidth , not compute, is the ceiling. More compute units add area and power but sit idle waiting for data. The correct fix is to raise arithmetic intensity : cache/reuse data in BRAM, tile the loops, stream so each fetched byte feeds many operations. Fix the bottleneck, not the abundant resource.


Level 4 — Synthesis

Exercise 4.1

Design a streaming accelerator for a -tap FIR filter . List the hardware blocks, say why each exists, and give the steady-state throughput.

Recall Solution

Blocks and their jobs:

  1. 16 DSP slices — one multiply per tap , all in the same cycle → 16-way spatial parallelism. (Hardened multipliers, not LUT-built.)
  2. Adder tree, levels, each level registered — sums the 16 products. Pipelining the tree keeps the slowest stage small so the clock stays fast. This is dataflow.
  3. Shift register of length 16 for — each cycle one new sample shifts in; every stored sample feeds a different tap over time. This gives data reuse: no byte is re-fetched from DRAM, so intensity stays high.

Throughput: after the pipeline fills, one per clock cycle. A CPU does multiply-adds serially per output, so the speedup , bounded by input bandwidth. See High-Level Synthesis (HLS) for expressing this in C.

Exercise 4.2

For the Exercise 4.1 design at , streaming samples, the pipeline depth (fill) is stages (1 multiply + 4 adder levels). Compute total time and the speedup over a serial CPU doing ops per sample at .

Recall Solution

FPGA time: CPU time: Speedup: Only even though we placed 16 multipliers — because the FPGA clock period () is the CPU op time (). The parallelism-16 win is partly cancelled by the slower clock: . This is exactly the trade-off between low clock and high parallelism.


Level 5 — Mastery

Exercise 5.1 (degenerate case)

What is the pipeline speedup when ? Interpret physically.

Recall Solution

Speedup for every . A "one-stage pipeline" has nothing to overlap — there is a single combinational block, no registers splitting the work, so pipelining buys nothing. Pipelining only pays when , and its ceiling grows with .

Exercise 5.2 (limiting behaviour, both directions)

Fix . Evaluate the speedup at , , , and . Describe the curve's shape.

Recall Solution

The curve rises from (one item = pure latency, no overlap) and saturates toward the horizontal asymptote . It is concave: fast gains early, diminishing returns as grows.

The figure below draws exactly this curve. Its horizontal axis is the ==number of streamed items == (drawn on a log scale so both small and large are visible); its vertical axis is the speedup (dimensionless, "how many times faster than serial"). The three sample points and the dashed asymptote at are marked.

Figure — FPGA-based acceleration
Figure s02 — Speedup for . X-axis: number of streamed items (log scale). Y-axis: speedup (×, dimensionless). Rises from at , passes at and at , and flattens toward the dashed line .

Exercise 5.3 (two-roof crossover — the ridge point)

On a roofline with and , find the arithmetic intensity where the memory roof meets the compute roof (the "ridge"). What does an operating point at exactly mean, and which way should you move a point that lands left of it?

Recall Solution

The ridge is where the two roofs are equal: At the design is perfectly balanced: it saturates memory bandwidth and peak compute simultaneously. Left of ⇒ memory-bound; right of ⇒ compute-bound. A point that lands left of should be pushed rightward — raise its intensity (buffer and reuse data in BRAM so each fetched byte feeds more operations) until it reaches the ridge; past there is nothing more to gain from intensity, and only extra compute units would help.

Exercise 5.4 (synthesis of both models — when is the FPGA worth it?)

A workload streams items, needs pipeline stages, clock . It is memory-bound: intensity , bandwidth , each item is bytes and needs ops. Compute (a) the ideal pipelined compute time, (b) the roofline memory-bound time, (c) which one actually governs — and explain why we must use total-ops, not raw bytes.

Recall Solution

(a) Pipelined compute time (assuming data is always available — the compute roof only):

(b) Roofline memory-bound time. Why not just bytes? Raw transfer time tells you only how long the wires are busy — it ignores how much useful compute each byte must feed. The roofline measures performance in ops/s, so the honest memory-bound time is total operations divided by the memory-limited op-rate : The two numbers differ ( vs ) precisely because each byte carries op here, but each item is bytes yet demands ops — so the compute-per-byte the memory roof allows () is the real throttle, not the raw byte count. Using bytes would wrongly claim the job finishes in .

(c) Which governs? A design cannot finish faster than the slower of its two ceilings. Here compute time and memory-bound time are nearly equal, so this design sits right at the ridge — neither roof is badly slack. The memory roof governs by a hair ( means memory is the tighter of the two only marginally; in practice they co-limit). To go faster you must lift both: raise (more DRAM channels) and raise (BRAM reuse). Improving only one just makes the other roof the new wall.