---
title: "Problem set 4: pipelines, clock domains, verification and FPGAs"
heading: "Problem set 4: pipelining, clock domain crossing, verification and FPGA mapping"
eyebrow: S3 · Problem set 4
type: problems
---

::: hook
These problems cover lessons 23 to 27: pipeline throughput, latency and the iteration bound, synchronizer MTBF and handshakes, coverage and corner-case odds, formal checks, and mapping logic, memory and arithmetic onto an FPGA.
:::

::: pool
pick: 12

::: check
kind: parts
given: T = 3 | 6; k = 3 | 5 | 8; r = 0.06 | 0.15

## A {T} ns block is split into {k} balanced stages, each with {r} ns of register overhead.

::: part
answer: T/k + r
unit: ns
tolerance: 0.5%

### Clock period?

::: misses
- [any] $T/k + r$.
:::
:::

::: part
answer: T + k*r
unit: ns
tolerance: 0.5%

### Latency?

::: misses
- [any] $T + kr$.
:::
:::

::: part
answer: (T + r)/(T/k + r)
tolerance: 0.5%

### Throughput gain over the unpipelined block?

::: misses
- [any] Ratio of periods.
:::
:::
:::

::: check
kind: parts
given: a = 0.8 | 1.4; b = 1.1 | 1.2; c = 0.6 | 0.9; r = 0.08

## Three pipeline stages of {a}, {b} and {c} ns with {r} ns of register overhead.

::: part
answer: 1/(((a + b + abs(a - b))/2 + c + abs((a + b + abs(a - b))/2 - c))/2 + r)*1000
unit: MHz
tolerance: 0.5%

### Maximum clock as built?

::: misses
- [any] The slowest stage sets it.
:::
:::

::: part
answer: 1/((a + b + c)/3 + r)*1000
unit: MHz
tolerance: 0.5%

### Maximum clock after retiming balances them perfectly?

::: misses
- [any] Equal stages of a third of the total.
:::
:::
:::

::: check
kind: parts
given: L = 3 | 4.5; R = 2 | 3; f = 300 | 500

## A loop with {L} ns of logic and {R} registers, in a design that wants {f} MHz.

::: part
answer: L/R
unit: ns
tolerance: 0.5%

### Iteration bound?

::: misses
- [any] L/R.
:::
:::

::: part
answer: 1000/(L/R)
unit: MHz
tolerance: 0.5%

### Fastest clock the loop allows?

::: misses
- [any] One over the bound.
:::
:::
:::

::: check
kind: parts
given: t = 400 | 900; u = 18 | 25; f = 600 | 1500; d = 40 | 150

## A synchronizer flip-flop: τ = {u} ps, $T_0$ = 20 ps, {f} MHz clock, data at {d} MHz, and {t} ps of settling.

::: part
answer: exp(t/u)/(20e-12*f*1e6*d*1e6)
unit: s
tolerance: 1%

### MTBF?

::: misses
- [any] $e^{t/\tau}/T_0f_cf_d$.
:::
:::

::: part
answer: exp(1e6/f/u)
tolerance: 1%

### Improvement from a second flip-flop?

::: misses
- [any] $e^{T/\tau}$.
:::
:::
:::

::: check
kind: parts
given: Y = 100 | 10000; u = 15 | 30; f = 400 | 1200; d = 20 | 200

## A crossing must reach an MTBF of {Y} years, with τ = {u} ps, $T_0$ = 20 ps, a {f} MHz clock and {d} MHz data.

::: part
answer: u*ln(Y*3.156e7*20e-12*f*1e6*d*1e6)
unit: ps
tolerance: 0.5%

### Settling time needed?

::: misses
- [any] Solve for $t_r$ with the natural log.
:::
:::

::: part
answer: 1e6/f
unit: ps
tolerance: 0.5%

### Settling time one extra flip-flop adds?

::: misses
- [any] One clock period.
:::
:::
:::

::: check
kind: parts
given: s = 2 | 3; f = 100 | 400; d = 2 | 3; g = 50 | 250; w = 8 | 32

## A req/ack handshake: request through {s} flops at {f} MHz plus one cycle; acknowledge through {d} flops at {g} MHz plus one cycle. Each transfer carries {w} bits.

::: part
answer: (s + 1)*1000/f + (d + 1)*1000/g
unit: ns
tolerance: 0.5%

### Time per transfer?

::: misses
- [any] $(s + 1)T_\text{dest} + (d + 1)T_\text{src}$.
:::
:::

::: part
answer: w/((s + 1)*1000/f + (d + 1)*1000/g)*1000
unit: Mbit/s
tolerance: 0.5%

### Throughput?

::: misses
- [any] Bits per transfer over the transfer time.
:::
:::
:::

::: check
kind: parts
given: N = 5 | 6 | 7

## An {N}-bit counter's pointer crosses clock domains.

::: part
answer: 2^(N + 1) - 2
tolerance: 0

### Total bit changes over a full binary cycle?

::: misses
- [any] Bit k toggles $2^{N-k}$ times.
:::
:::

::: part
answer: 2^N
tolerance: 0

### Over a full Gray cycle?

::: misses
- [any] One per increment.
:::
:::
:::

::: check
kind: parts
given: N = 40 | 200; n = 100 | 500

## A coverpoint with {N} equally likely bins.

::: part
answer: 100*(1 - (1 - 1/N)^n)
unit: %
tolerance: 0.5%

### Coverage after {n} random tests?

::: misses
- [any] $1 - (1 - 1/N)^n$.
:::
:::

::: part
answer: N*(ln(N) + 0.5772)
tolerance: 1%

### Expected tests to fill it (use $N(\ln N + 0.577)$)?

::: misses
- [any] Coupon collector.
:::
:::
:::

::: check
kind: parts
given: p = 0.0005 | 0.00002; c = 0.9 | 0.999; w = 10 | 14; R = 2 | 50

## A corner case of probability {p} per test, and a {w}-bit adder tested at {R} million tests per second.

::: part
answer: ln(1 - c)/ln(1 - p)
tolerance: 0.5%

### Tests for confidence {c}?

::: misses
- [any] $\ln(1 - c)/\ln(1 - p)$.
:::
:::

::: part
answer: 2^(2*w)/(R*1e6)
unit: s
tolerance: 0.5%

### Exhaustive test time for the adder?

::: misses
- [any] $2^{2w}$ pairs.
:::
:::
:::

::: check
kind: parts
given: n = 18 | 40 | 70; k = 4 | 6

## An {n}-input XOR on {k}-input LUTs.

::: part
answer: ceil((n - 1)/(k - 1) - 0.001)
tolerance: 0

### LUTs?

::: misses
- [any] $\lceil (n - 1)/(k - 1) \rceil$.
:::
:::

::: part
answer: ceil(log(n)/log(k) - 0.0001)
tolerance: 0

### Levels?

::: misses
- [any] $\lceil \log_kn \rceil$.
:::
:::
:::

::: check
kind: parts
given: D = 900 | 3100 | 5000; W = 30 | 50; m = 1 | 2 | 4; let d = 1024*m; let w = 36/m; M = 32 | 54

## A {D} × {W} memory in {d} × {w} block RAMs, and an {M} × {M} multiply on 27 × 18 DSP slices.

::: part
answer: ceil(D/d - 0.0001)*ceil(W/w - 0.0001)
tolerance: 0

### Block RAMs?

::: misses
- [any] Round each direction up.
:::
:::

::: part
answer: ceil(M/27 - 0.0001)*ceil(M/18 - 0.0001)
tolerance: 0

### DSP slices?

::: misses
- [any] Pieces of each operand, multiplied pairwise.
:::
:::
:::

::: check
kind: parts
given: L = 3 | 5; t = 0.1 | 0.15; r = 0.35 | 0.55; c = 0.25; s = 0.05; k = 2 | 3

## An FPGA path: {L} LUT levels at {t} ns plus {r} ns routing each, {c} ns clock-to-Q, {s} ns setup.

::: part
answer: 1/(L*(t + r) + c + s)*1000
unit: MHz
tolerance: 0.5%

### Maximum clock?

::: misses
- [any] Levels times (LUT + routing), plus register overhead.
:::
:::

::: part
answer: 1/(ceil(L/k - 0.001)*(t + r) + c + s)*1000
unit: MHz
tolerance: 0.5%

### Maximum clock after pipelining into {k} stages (whole LUT levels per stage, the largest stage setting the clock)?

::: misses
- [any] The deepest stage has $\lceil L/k \rceil$ levels.
:::
:::
:::

::: check
kind: parts
given: F = 2000 | 8000; G = 50000 | 300000; k = 15 | 60

## A block with {F} flip-flops and {G} gates is unrolled {k} cycles for bounded model checking.

::: part
answer: k*(F + G)
tolerance: 0.5%

### About how many variables?

::: misses
- [any] $k(F + G)$.
:::
:::

::: part
answer: 3*k*G
tolerance: 0.5%

### About how many clauses at three per gate?

::: misses
- [any] $3kG$.
:::
:::
:::

::: check
kind: parts
given: n = 40 | 48 | 64; r = 1e7 | 1e9

## A block with {n} input bits could be simulated exhaustively at {r} vectors a second.

::: part
answer: 2^n/r/3.156e7
unit: years
tolerance: 0.5%

### How long would that take?

::: misses
- [any] $2^n$ over the rate.
:::
:::
:::

::: check
kind: parts
given: S = 6 | 10 | 16

## A one-hot state machine has {S} states.

::: part
answer: 2^S - S
tolerance: 0

### How many of its flip-flop codes are illegal?

::: misses
- [any] $2^S - S$.
:::
:::

::: part
answer: S/2^S
tolerance: 0.5%

### What fraction of its codes are reachable?

::: misses
- [any] $S/2^S$.
:::
:::
:::
:::
