---
title: Problem set 10
heading: "Problem set 10: verification, clock crossings and FIFOs"
eyebrow: S3 · Problem set 10
type: problems
---

::: hook
These problems use lessons 12, 23 to 25, 28 and 49: FIFOs and their pointers, clock domain crossing, testbenches, coverage and formal checks, and the asynchronous FIFO project. Take a year as $3.156 \times 10^7$ s.
:::

::: pool
pick: 12

::: check
kind: parts
given: B = 64 | 256; w = 200 | 400; r = 100 | 150; k = 3 | 4

## Bursts of {B} words written at {w} MHz cross into a {r} MHz domain through an asynchronous FIFO; pointer synchronization hides {k} entries from the writer.

::: part
answer: B*(1 - r/w)
tolerance: 0.5%

### What backlog does a burst leave?

::: misses
- [any] $B(1 - f_r/f_w)$.
:::
:::

::: part
answer: 2^ceil(log(B*(1 - r/w) + k)/log(2) - 1e-9)
tolerance: 0

### What power-of-two depth covers it, synchronization included?

::: misses
- [any] Round $B(1 - f_r/f_w) + k$ up to a power of two.
:::
:::
:::

::: check
kind: parts
given: n = 4 | 8 | 12

## An {n}-bit pointer counts up and wraps.

::: part
answer: n
tolerance: 0

### How many bits change in binary when it wraps from all ones to zero?

::: misses
- [any] Every bit.
:::
:::

::: part
answer: 1
tolerance: 0

### How many change in Gray code?

::: misses
- [any] Gray codes change one bit per step, including the wrap.
:::
:::

::: part
answer: 2 - 2^(1 - n)
tolerance: 0.5%

### How many change per step on average in binary, over a full cycle?

::: misses
- [any] $2 - 2^{1-n}$.
:::
:::
:::

::: check
kind: parts
given: t = 800 | 1500; u = 20 | 30; f = 500 | 1000; d = 50 | 200; S = 10 | 100

## A chip has {S} identical synchronizers, each with τ = $T_0$ = {u} ps and {t} ps to resolve, on a {f} MHz clock sampling data that changes at {d} MHz.

::: part
answer: exp(t/u)/(u*1e-12*f*1e6*d*1e6)/3.156e7
unit: years
tolerance: 0.5%

### What is one synchronizer's MTBF?

::: misses
- [any] $e^{t_r/\tau}/(T_0f_\text{clk}f_\text{data})$.
:::
:::

::: part
answer: exp(t/u)/(u*1e-12*f*1e6*d*1e6)/3.156e7/S
unit: years
tolerance: 0.5%

### What is the chip's?

::: misses
- [any] Failure rates add: divide by S.
:::
:::
:::

::: check
kind: parts
given: Y = 10 | 1000; S = 10 | 100 | 1000; u = 20 | 30; f = 500 | 2000; d = 100 | 500

## A design with {S} synchronizers (τ = $T_0$ = {u} ps, {f} MHz clock, {d} MHz data) must reach a combined MTBF of {Y} years.

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

### How much resolution time does each synchronizer need?

::: misses
- [u*ln(Y*3.156e7*u*1e-12*f*1e6*d*1e6)] Each must reach S times the target.
- [any] $\tau\ln(\text{MTBF}\cdot S\cdot T_0f_\text{clk}f_\text{data})$.
:::
:::
:::

::: check
kind: parts
given: a = 8 | 16 | 32; b = 4 | 8

## A cross coverpoint combines {a} opcodes with {b} modes, all equally likely in random tests.

::: part
answer: ln(0.1)/ln(1 - 1/(a*b))
tolerance: 0.5%

### How many tests reach 90% expected coverage?

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

::: part
answer: a*b*(ln(a*b) + 0.577)
tolerance: 1%

### About how many fill every bin?

::: misses
- [any] $N(\ln N + 0.577)$.
:::
:::
:::

::: check
kind: parts
given: p = 1e-5 | 1e-4; q = 0.001 | 0.01; c = 0.95 | 0.99

## A corner case has probability {p} per unconstrained random test; weighting the constraints raises it to {q}.

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

### How many unconstrained tests reach {c} confidence of hitting it?

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

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

### By what factor does weighting cut that?

::: misses
- [any] Ratio of the two test counts.
:::
:::
:::

::: check
kind: parts
given: n = 8 | 12 | 16; k = 3 | 4

## A bug fires only when an {n}-bit counter reaches its maximum value; formal tools can shrink the counter to {k} bits without changing the property.

::: part
answer: 2^n - 1
unit: cycles
tolerance: 0

### How deep must bounded model checking go to find it as written?

::: misses
- [2^n] The counter starts at zero.
- [any] $2^n - 1$ steps.
:::
:::

::: part
answer: 2^k - 1
unit: cycles
tolerance: 0

### And with the counter shrunk?

::: misses
- [any] $2^k - 1$.
:::
:::
:::

::: check
kind: parts
given: n = 16 | 32 | 64

## Two {n}-bit adders (with carry out) are compared by equivalence checking through a miter.

::: part
answer: n + 1
tolerance: 0

### How many XOR gates does the miter need?

::: misses
- [n] Include the carry out.
:::
:::

::: part
answer: n
tolerance: 0

### How many 2-input ORs combine them?

::: misses
- [any] One fewer than the XORs.
:::
:::
:::

::: check
kind: parts
given: n = 24 | 32 | 40; s = 1000 | 10000; e = 1e6 | 1e7

## A block has {n} input bits. A simulator runs {s} vectors a second; an emulator runs {e}.

::: part
answer: 2^n/s/3600
unit: hours
tolerance: 0.5%

### How long does exhaustive simulation take?

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

::: part
answer: 2^n/e/3600
unit: hours
tolerance: 0.5%

### And on the emulator?

::: misses
- [any] Same count, faster rate.
:::
:::
:::

::: check
kind: parts
given: Y = 0.7 | 0.9; D = 100 | 500

## A product's yield is {Y}, and no more than {D} parts per million shipped may be bad.

::: part
answer: 1 - ln(1 - D*1e-6)/ln(Y)
tolerance: 0.5%

### What fault coverage does the test need?

::: misses
- [any] Solve $DL = 1 - Y^{1 - T}$ for T.
:::
:::
:::

::: check
kind: parts
given: n = 16 | 24 | 32; f = 100 | 500

## An {n}-bit maximal LFSR drives random stimulus at {f} MHz.

::: part
answer: 2^n - 1
tolerance: 0

### How many states does it visit before repeating?

::: misses
- [2^n] The all-zero state is never visited.
- [any] $2^n - 1$.
:::
:::

::: part
answer: (2^n - 1)/(f*1e6)
unit: s
tolerance: 0.5%

### How long until the stimulus repeats?

::: misses
- [any] Period over clock rate.
:::
:::
:::

::: check
kind: parts
given: l = 0.25 | 0.5 | 1; W = 20 | 100 | 300

## A design accepts {l} transactions per cycle on average, and each takes {W} cycles to produce its result.

::: part
answer: l*W
tolerance: 0.5%

### How many transactions are in flight on average, so how deep must the scoreboard's expected-result queue be?

::: misses
- [any] Little's law: $L = \lambda W$.
:::
:::
:::

::: check
kind: parts
given: f = 100 | 400; g = 50 | 200

## A toggle synchronizer passes events from a {g} MHz domain to a {f} MHz domain; each event needs 3 destination cycles to be seen before the source may toggle again.

::: part
answer: f/3
unit: MHz
tolerance: 0.5%

### What is the highest event rate it can pass?

::: misses
- [any] One event per three destination cycles.
:::
:::

::: part
answer: 3*g/f
unit: cycles
tolerance: 0.5%

### How many source cycles is that spacing?

::: misses
- [any] Convert 3 destination cycles to source cycles.
:::
:::
:::

::: check
kind: parts
given: D = 4 | 5 | 8

## An assertion requires `req |-> ##[1:3] gnt`. A bug makes the grant delay uniformly random from 1 to {D} cycles.

::: part
answer: (D - 3)/D
tolerance: 0.5%

### What fraction of requests violate the assertion?

::: misses
- [any] Delays above 3 out of D equally likely values.
:::
:::

::: part
answer: ln(0.01)/ln(3/D)
tolerance: 0.5%

### How many requests give 99% confidence of catching it?

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

::: check
kind: parts
given: S = 5 | 9 | 12 | 20

## A state machine has {S} states.

::: part
answer: 2^ceil(log(S)/log(2) - 1e-9) - S
tolerance: 0

### How many illegal codes does binary encoding leave for a formal tool to rule out?

::: misses
- [any] $2^{\lceil\log_2S\rceil} - S$.
:::
:::

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

### And one-hot encoding?

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