---
title: Problem set 5
heading: "Problem set 5: floating point, memory arrays, latch timing, formal checks and HLS"
eyebrow: S3 · Problem set 5
type: problems
---

::: hook
These problems use lessons 6, 10, 12, 16, 25, 32 and 33: parameterized structures, floating-point units and formats, SRAM arrays and register files, latch-based timing, formal verification, streaming image pipelines and high-level synthesis. They mix the new structures with the timing and cost reasoning of the earlier lessons.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 30 | 100 | 300; k = 4 | 6; W = 8 | 16

## A reduction tree combines N = {N} values of {W} bits with {k}-input adders, registered after each level.

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

### How many adders does it need?

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

::: part
answer: ceil(log(N)/log(k) - 1e-9)
unit: cycles
tolerance: 0

### What is its latency?

::: misses
- [any] One cycle per level: $\lceil\log_kN\rceil$.
:::
:::

::: part
answer: W + ceil(log(N)/log(2) - 1e-9)
unit: bits
tolerance: 0

### How wide must the final sum be?

::: misses
- [W + ceil(log(N)/log(k) - 1e-9)] Width grows with the number of values summed, $\log_2N$, not with the levels.
- [any] $W + \lceil\log_2N\rceil$.
:::
:::
:::

::: check
kind: parts
given: W = 8 | 12 | 16; V = 8 | 16; K = 16 | 100 | 1000

## A multiply-accumulate unit sums {K} products of a {W}-bit and a {V}-bit signed value.

::: part
answer: W + V
unit: bits
tolerance: 0

### How wide is each product?

::: misses
- [any] W + V.
:::
:::

::: part
answer: W + V + ceil(log(K)/log(2) - 1e-9)
unit: bits
tolerance: 0

### How wide must the accumulator be to never overflow?

::: misses
- [any] Add $\lceil\log_2K\rceil$ guard bits.
:::
:::
:::

::: check
kind: parts
given: e = 5 | 8; f = 7 | 10 | 23

## A binary floating-point format has {e} exponent bits (biased) and {f} fraction bits, with IEEE-style normal numbers.

::: part
answer: (2 - 2^(-f))*2^(2^(e - 1) - 1)
tolerance: 0.5%

### What is its largest finite value?

::: misses
- [any] $(2 - 2^{-f})\cdot2^{\text{bias}}$ with bias $2^{e-1} - 1$.
:::
:::

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

### What is its smallest normal value?

::: misses
- [any] $2^{1 - \text{bias}}$.
:::
:::

::: part
answer: 2^(-f)
tolerance: 0.5%

### What is the spacing between 1 and the next number?

::: misses
- [any] One ULP at 1: $2^{-f}$.
:::
:::
:::

::: check
kind: parts
given: s = 1.25 | 1.75; t = 1.5 | 1.875; p = 6 | 7; q = 0 | 1 | 2

## A floating-point adder subtracts {t} × 2^{q} from {s} × 2^{p}.

::: part
answer: p - q
tolerance: 0

### How far is the smaller operand shifted?

::: misses
- [any] The exponent difference.
:::
:::

::: part
answer: s - t/2^(p - q)
tolerance: 0.5%

### What significand does the subtraction give before normalization?

::: misses
- [any] Align, then subtract.
:::
:::

::: part
answer: (s - t/2^(p - q))*2^(p)
tolerance: 0.5%

### What value is the result?

::: misses
- [any] Significand × $2^{\text{exponent}}$.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 4096; c = 0.15 | 0.25; I = 15 | 30; t = 100 | 200

## An SRAM column of {N} cells ({c} fF each, 30 fF of wire, {I} µA of cell current, 100 mV to sense) can be split into banks; each level of bank multiplexing adds {t} ps.

::: part
answer: (N*c + 30)*1e-15*0.1/(I*1e-6)*1e9
unit: ns
tolerance: 0.5%

### How long does a read take unbanked?

::: misses
- [any] $C\Delta V/I$.
:::
:::

::: part
answer: (N/8*c + 30)*1e-15*0.1/(I*1e-6)*1e9 + 3*t/1000
unit: ns
tolerance: 0.5%

### And split into 8 banks?

::: misses
- [(N/8*c + 30)*1e-15*0.1/(I*1e-6)*1e9] Add three levels of bank multiplexing.
- [any] Shorter bitlines plus $\log_2 8$ multiplexer levels.
:::
:::
:::

::: check
kind: parts
given: S = 16 | 64; R = 256 | 512; C = 256 | 512; W = 32 | 64

## A {S} KB SRAM uses {R} × {C} subarrays, read in {W}-bit words.

::: part
answer: round(log(S*8192/(R*C))/log(2))
unit: bits
tolerance: 0

### How many address bits choose the subarray?

::: misses
- [any] $\log_2$ of the number of subarrays.
:::
:::

::: part
answer: round(log(R)/log(2))
unit: bits
tolerance: 0

### How many choose the row?

::: misses
- [any] $\log_2R$.
:::
:::

::: part
answer: round(log(C/W)/log(2))
unit: bits
tolerance: 0

### How many drive the column multiplexer?

::: misses
- [any] $\log_2(C/W)$.
:::
:::
:::

::: check
kind: parts
given: a = 3 | 5; b = 4 | 6; p = 3 | 4; q = 8 | 12

## A register-file cell is {a} by {b} tracks before ports, plus one track each way per port; it grows from {p} to {q} ports.

::: part
answer: (a + q)*(b + q)/((a + p)*(b + p))
tolerance: 0.5%

### By what factor does each cell's area grow?

::: misses
- [(q/p)^2] That's the large-port limit; include the base tracks.
- [any] $(a + q)(b + q)/((a + p)(b + p))$.
:::
:::
:::

::: check
kind: parts
given: a = 0.9 | 1.1; b = 0.3 | 0.5; d = 40 | 60; s = 30 | 50

## A two-phase latch pipeline alternates blocks of {a} ns and {b} ns; latches take {d} ps from D to Q and need {s} ps of setup.

::: part
answer: a + b + 2*d/1000
unit: ns
tolerance: 0.5%

### What is the shortest clock period?

::: misses
- [any] $t_1 + t_2 + 2t_{DQ}$.
:::
:::

::: part
answer: a + 0.1 + 0.03
unit: ns
tolerance: 0.5%

### What would a flip-flop pipeline with one stage per block need, with 100 ps clock-to-Q and 30 ps setup?

::: misses
- [any] The slower block plus flip-flop overhead.
:::
:::

::: part
answer: (a - b)/2
unit: ns
tolerance: 0.5%

### How much does the slow block borrow in the latch design at its shortest period?

::: misses
- [any] Its arrival minus the half period.
:::
:::
:::

::: check
kind: parts
given: h = 15 | 25; w = 50 | 100; c = 20 | 40; m = 30 | 120

## A pulsed-latch design has {w} ps pulses, {h} ps hold and {c} ps contamination clock-to-Q. Its shortest path is {m} ps.

::: part
answer: m - (h + w - c)
unit: ps
tolerance: 0.5%

### What is its hold slack?

::: misses
- [m - (h - c)] The receiving latch is open for the whole pulse.
- [any] $t_\text{min} - (t_\text{hold} + t_\text{pw} - t_{ccq})$.
:::
:::
:::

::: check
kind: parts
given: F = 500 | 4000; G = 20000 | 200000; k = 20 | 40 | 80

## Bounded model checking unrolls a block with {F} flip-flops and {G} gates to depth {k}.

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

### About how many variables does the solver see?

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

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

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

::: misses
- [3*G] Every unrolled cycle has its own gates.
- [any] $3kG$.
:::
:::
:::

::: check
kind: parts
given: m = 12 | 20 | 28; r = 1e6 | 1e9

## A bug needs one specific value on an {m}-bit field; random tests run at {r} per second.

::: part
answer: ln(0.01)/ln(1 - 2^(-m))
tolerance: 0.5%

### How many tests give 99% confidence of hitting it?

::: misses
- [any] $\ln(0.01)/\ln(1 - 2^{-m})$.
:::
:::

::: part
answer: ln(0.01)/ln(1 - 2^(-m))/r
unit: s
tolerance: 0.5%

### How long does that take?

::: misses
- [any] Tests over rate.
:::
:::
:::

::: check
kind: parts
given: N = 512 | 2048; D = 6 | 14; r = 4 | 6; p = 2; L = 3 | 5; d = 1 | 2

## An HLS loop of {N} iterations, {D} cycles deep, reads an array {r} times per iteration from a dual-port memory and has a loop-carried chain of {L} cycles at distance {d}.

::: part
answer: ceil(r/2) - (ceil(r/2) - ceil(L/d))*step(ceil(L/d) - ceil(r/2))
tolerance: 0

### What initiation interval can it reach?

::: misses
- [any] The larger of $\lceil r/p\rceil$ and $\lceil L/d\rceil$.
:::
:::

::: part
answer: (N - 1)*(ceil(r/2) - (ceil(r/2) - ceil(L/d))*step(ceil(L/d) - ceil(r/2))) + D
unit: cycles
tolerance: 0

### How many cycles does the loop take?

::: misses
- [any] $(N - 1)\text{II} + D$.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 8192; U = 4 | 16; D = 8 | 12; f = 200 | 400

## An HLS loop of {N} iterations, {D} cycles deep, is unrolled by {U} and pipelined at II = 1 on a {f} MHz clock, with the arrays partitioned to match.

::: part
answer: N/U - 1 + D
unit: cycles
tolerance: 0

### How many cycles does it take?

::: misses
- [any] $(N/U - 1) + D$.
:::
:::

::: part
answer: (N/U - 1 + D)/f
unit: µs
tolerance: 0.5%

### How long is that?

::: misses
- [any] Cycles over the clock rate.
:::
:::

::: part
answer: U
tolerance: 0

### How many array partitions must each array have for one element per copy per cycle, with single-port memories?

::: misses
- [any] One per unrolled copy.
:::
:::
:::

::: check
kind: parts
given: b = 10 | 16 | 24; f = 200 | 500

## A pipelined CORDIC must compute sines and cosines to {b} bits, one result per cycle at {f} MHz, with one iteration per stage (about one bit per iteration).

::: part
answer: b + 1
unit: stages
tolerance: 0

### How many stages does it need, if n iterations give an error under $2^{-(n-1)}$?

::: misses
- [any] Solve $2^{-(n - 1)} \le 2^{-b}$.
:::
:::

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

### What is its latency?

::: misses
- [any] Stages × period.
:::
:::
:::

::: check
kind: parts
given: p = 11 | 24 | 53; S = 1 | 2 | 4

## A floating-point multiplier for {p}-bit significands is built from 18 × 18-bit hard multipliers tiled over the partial products, and it must deliver {S} result(s) per cycle.

::: part
answer: ceil(p/18)^2
tolerance: 0

### How many hard multipliers does one significand product need?

::: misses
- [any] $\lceil p/18\rceil^2$ tiles.
:::
:::

::: part
answer: S*ceil(p/18)^2
tolerance: 0

### How many in all?

::: misses
- [any] Per product × products per cycle.
:::
:::
:::

::: check
kind: parts
given: k = 3 | 5 | 7; W = 1280 | 1920 | 3840; b = 8 | 10; f = 30 | 60; H = 720 | 1080 | 2160

## A {k} × {k} filter streams {W} × {H} video with {b}-bit pixels at {f} frames per second.

::: part
answer: (k - 1)*W*b/8/1024
unit: KB
tolerance: 0.5%

### How much line-buffer memory does it need?

::: misses
- [k*W*b/8/1024] Only $k - 1$ rows are stored.
- [any] Not yet. $(k - 1)Wb$ bits.
:::
:::

::: part
answer: W*H*f/1e6
unit: MHz
tolerance: 0.5%

### How many megapixels per second must it process, ignoring blanking?

::: misses
- [W*H/1e6] Multiply by the frame rate.
- [any] Not yet. $WHf$.
:::
:::

::: right
Right. Line buffers keep the memory to kilobytes while the pixel rate sets the clock.
:::
:::
:::
