---
title: "Problem set 2: datapaths and memories"
heading: "Problem set 2: adders, multipliers, number formats and memories"
eyebrow: S3 · Problem set 2
type: problems
---

::: hook
These problems cover lessons 8 to 13: adder architectures and overflow, multiplier reduction and division, fixed- and floating-point formats, floating-point units, memories and FIFOs, and SRAM arrays. Dadda heights: 2, 3, 4, 6, 9, 13, 19, 28, 42, 63.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 16 | 32 | 64; t = 25 | 40

## An {N}-bit adder with {t} ps per level.

::: part
answer: N*t
unit: ps
tolerance: 0.5%

### Ripple-carry delay?

::: misses
- [any] Nt.
:::
:::

::: part
answer: (log(N)/log(2) + 2)*t
unit: ps
tolerance: 1%

### Kogge–Stone delay (prefix levels plus 2)?

::: misses
- [any] $(\log_2N + 2)t$.
:::
:::

::: part
answer: N*log(N)/log(2) - N + 1
tolerance: 0.4

### Kogge–Stone prefix cells?

::: misses
- [any] $N\log_2N - N + 1$.
:::
:::
:::

::: check
kind: parts
given: N = 32 | 64; k = 4 | 8

## A carry-select adder of {N} bits in {k} equal blocks, against Brent–Kung.

::: part
answer: N/k + k
tolerance: 0.4

### Carry-select delay, in carry delays?

::: misses
- [any] $N/k + k$.
:::
:::

::: part
answer: 2*log(N)/log(2) - 1
tolerance: 0.4

### Brent–Kung prefix levels?

::: misses
- [any] $2\log_2N - 1$.
:::
:::

::: part
answer: 2*N - 2 - log(N)/log(2)
tolerance: 0.4

### Brent–Kung prefix cells?

::: misses
- [any] $2N - 2 - \log_2N$.
:::
:::
:::

::: check
kind: parts
given: M = 16 | 24; N = 16 | 32

## An {M} × {N} multiplier.

::: part
answer: M*N
tolerance: 0

### Partial-product bits?

::: misses
- [any] MN.
:::
:::

::: part
answer: M + N
tolerance: 0

### Product width?

::: misses
- [any] M + N.
:::
:::

::: part
answer: step(N/2 - 2.5) + step(N/2 - 3.5) + step(N/2 - 4.5) + step(N/2 - 6.5) + step(N/2 - 9.5) + step(N/2 - 13.5) + step(N/2 - 19.5) + step(N/2 - 28.5)
tolerance: 0

### Dadda stages after radix-4 Booth recoding of the {N}-bit multiplier?

::: misses
- [any] N/2 rows; count Dadda heights below that.
:::
:::
:::

::: check
kind: parts
given: s = 4 | 7; b = 24 | 53; f = 200 | 500; N = 32 | 64

## Division: Newton–Raphson from a {s}-bit seed to {b} bits, or a restoring divider for {N} bits at {f} MHz.

::: part
answer: ceil(log(b/s)/log(2) + 0.0001)
tolerance: 0

### Newton–Raphson iterations?

::: misses
- [any] Doublings needed.
:::
:::

::: part
answer: N/(f*1e6)*1e9
unit: ns
tolerance: 0.5%

### Restoring divider time?

::: misses
- [any] N cycles.
:::
:::
:::

::: check
kind: parts
given: a = 1 | 3; b = 11 | 15; c = 1 | 2; d = 15 | 17; K = 16 | 100

## A Q{a}.{b} sample times a Q{c}.{d} coefficient, summed over {K} taps.

::: part
answer: a + b + c + d
tolerance: 0

### Exact product width?

::: misses
- [any] Integer and fractional bits add.
:::
:::

::: part
answer: a + b + c + d + ceil(log(K - 0.5)/log(2))
tolerance: 0

### Accumulator width with guard bits?

::: misses
- [any] Product width plus $\lceil\log_2K\rceil$.
:::
:::
:::

::: check
kind: parts
given: m = 1 | 2; n = 9 | 13; e = 124 | 133; f = 0.125 | 0.5

## Formats: signed Q{m}.{n}, and an IEEE single with exponent field {e} and fraction {f}.

::: part
answer: 2^(-n)
tolerance: 0.0001%

### Q{m}.{n} resolution?

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

::: part
answer: (1 + f)*2^(e - 127)
tolerance: 0.0001%

### The single's value?

::: misses
- [any] $(1 + f)2^{e - 127}$.
:::
:::

::: part
answer: 2^(e - 150)
tolerance: 0.0001%

### Its ULP?

::: misses
- [any] $2^{e - 127 - 23}$.
:::
:::
:::

::: check
kind: parts
given: N = 8 | 16; a = 70 | 100; b = 40 | 60

## An {N}-bit two's complement adder with saturation adds {a} and {b}.

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

### Largest representable value?

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

::: part
answer: (a + b + 2^(N - 1) - 1 - abs(a + b - 2^(N - 1) + 1))/2
tolerance: 0.4

### The sum with saturation?

::: misses
- [any] Clamp at the largest value.
:::
:::
:::

::: check
kind: parts
given: B = 128 | 1000; w = 100 | 250; r = 40 | 90

## A burst of {B} words at {w} MHz into a FIFO read at {r} MHz.

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

### Depth needed?

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

::: part
answer: B*(1 - r/w)/(r*1e6)*1e9
unit: ns
tolerance: 0.5%

### Time to drain afterward?

::: misses
- [any] Backlog over the read rate.
:::
:::
:::

::: check
kind: parts
given: D = 1024 | 16384; W = 16 | 64

## A {D} × {W} memory.

::: part
answer: log(D)/log(2)
tolerance: 0.4

### Address bits?

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

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

### 32 Kb block RAMs needed?

::: misses
- [any] Bits over 32,768, rounded up.
:::
:::

::: part
answer: log(D)/log(2) + 1
tolerance: 0.4

### Pointer bits if used as a FIFO?

::: misses
- [any] Address bits plus one.
:::
:::
:::

::: check
kind: boolean
vars: A, B, S
answer: A & B & ~S | ~A & ~B & S
ops: and, or, not

## Write the two's complement overflow flag from the sign bits A, B of the addends and S of the sum.

::: right
Right.
:::

::: misses
- [any] Not yet. Same-sign operands, different-sign sum.
:::
:::

::: check
kind: parts
given: K = 8 | 64; m = 1 | 2; n = 15 | 23

## A filter accumulates {K} products, each Q{m}.{n} × Q{m}.{n}.

::: part
answer: 2*(m + n) + log(K)/log(2)
tolerance: 0.4

### Accumulator bits to never overflow?

::: misses
- [any] Product bits plus $\log_2K$.
:::
:::

::: part
answer: 6.02*(m + n) + 1.76
unit: dB
tolerance: 0.5%

### SQNR if the output is rounded back to Q{m}.{n}?

::: misses
- [any] $6.02(m + n) + 1.76$.
:::
:::
:::

::: check
kind: parts
given: N = 9 | 13 | 19 | 28

## {N} rows of partial products.

::: part
answer: step(N - 2.5) + step(N - 3.5) + step(N - 4.5) + step(N - 6.5) + step(N - 9.5) + step(N - 13.5) + step(N - 19.5) + step(N - 28.5)
tolerance: 0

### Dadda stages?

::: misses
- [any] Count heights below N.
:::
:::

::: part
answer: N - 2
tolerance: 0

### Stages for a linear array?

::: misses
- [any] N − 2.
:::
:::
:::

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

## A binary floating-point format has {e} exponent bits and {f} fraction bits.

::: part
answer: 2^(e - 1) - 1
tolerance: 0

### What is its exponent bias?

::: misses
- [any] $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 - 1)
tolerance: 0.5%

### What is its unit roundoff?

::: misses
- [2^(-f)] That's the spacing at 1; rounding to nearest halves it.
- [any] $2^{-(f + 1)}$.
:::
:::
:::

::: check
kind: parts
given: p = 11 | 24 | 53

## A floating-point adder aligns {p}-bit significands, keeping guard, round and sticky bits.

::: part
answer: p + 3
unit: bits
tolerance: 0

### How wide is the aligned significand?

::: misses
- [any] p plus three.
:::
:::

::: part
answer: ceil(log(p + 3)/log(2) - 1e-9)
tolerance: 0

### How many levels does a barrel shifter for shifts up to p + 2 need?

::: misses
- [any] $\lceil\log_2(p + 3)\rceil$.
:::
:::
:::

::: check
kind: parts
given: n = 128 | 256 | 512; c = 0.15 | 0.25; I = 10 | 25

## An SRAM bitline serves {n} cells of {c} fF plus 40 fF of wire, with {I} µA of cell current; the sense amplifier needs 80 mV.

::: part
answer: (n*c + 40)*1e-15*0.08/(I*1e-6)*1e9
unit: ns
tolerance: 0.5%

### How long does a read take to develop?

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

::: part
answer: (n*c + 40)*1e-15*0.08*1*1e12*64
unit: pJ
tolerance: 0.5%

### How much energy do 64 such bitlines take per read at 1 V?

::: misses
- [any] $mC\Delta V\,V_{DD}$.
:::
:::
:::
:::
