---
title: Problem set 11
heading: "Problem set 11: memories, power, Verilog and arithmetic"
eyebrow: C7 · Problem set 11
type: problems
---

::: hook
These problems use lessons 44 to 53: memories, memory arrays and FPGAs, low-power design, reading and writing Verilog, and the logic and arithmetic labs.
:::

::: pool
pick: 12

::: check
kind: parts
given: G = 2 | 8 | 32; w = 16 | 32 | 64

## A {G} GiB memory has {w}-bit words.

::: part
answer: 30 + log(G)/log(2) - log(w/8)/log(2)
tolerance: 0

### How many address lines?

::: misses
- [30 + log(G)/log(2)] That would address bytes.
- [any] $\log_2$ of the number of words.
:::
:::

::: part
answer: log(w/8)/log(2)
tolerance: 0

### How many low address bits does a byte address add?

::: misses
- [any] $\log_2$ of the bytes per word.
:::
:::
:::

::: check
kind: parts
given: R = 4096 | 8192 | 65536; t = 32 | 64

## A DRAM refreshes {R} rows every {t} ms.

::: part
answer: t/R*1000
unit: µs
tolerance: 0.5%

### How often must it refresh a row?

::: misses
- [any] $\frac{t}{R}$.
:::
:::

::: part
answer: R/(t/1000)
tolerance: 0.5%

### How many row refreshes per second?

::: misses
- [any] $\frac{R}{t}$.
:::
:::
:::

::: check
kind: parts
given: D = 128 | 512; W = 32 | 64; d = 32 | 64; w = 8 | 16

## A {D}K × {W} memory is built from {d}K × {w} chips.

::: part
answer: D/d*W/w
tolerance: 0

### How many chips?

::: misses
- [any] Depth ratio times width ratio.
:::
:::

::: part
answer: D/d
tolerance: 0

### How many chip-select outputs does the decoder need?

::: misses
- [any] One per row of chips.
:::
:::
:::

::: check
kind: parts
given: n = 4 | 6 | 8 | 10; m = 1 | 4 | 8

## An {n}-input, {m}-output function is stored in a ROM.

::: part
answer: 2^n*m
tolerance: 0

### How many bits?

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

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

### How many 4-input LUTs would an n-input AND alone need?

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

::: check
kind: parts
given: P = 1 | 4; s = 25 | 40; g = 60 | 85

## A {P} W block spends {s}% in its clocked registers, gated off {g}% of the time.

::: part
answer: P*s/100*g/100
unit: W
tolerance: 0.5%

### How much does clock gating save?

::: misses
- [any] Clocked share × fraction gated.
:::
:::

::: part
answer: P*(1 - s/100*g/100)
unit: W
tolerance: 0.5%

### What does it draw now?

::: misses
- [any] The rest.
:::
:::
:::

::: check
kind: parts
given: V = 0.6 | 0.75 | 0.9; Vt = 0.25 | 0.3

## Logic designed for 1.0 V is run at {V} V with $V_t$ = {Vt} V.

::: part
answer: ((V - Vt)^2/V)/((1 - Vt)^2)
tolerance: 0.5%

### What fraction of its speed remains?

::: misses
- [any] $\frac{(V - V_t)^2/V}{(1 - V_t)^2}$.
:::
:::

::: part
answer: V^2*((V - Vt)^2/V)/((1 - Vt)^2)
tolerance: 0.5%

### What fraction of its power, at that speed?

::: misses
- [V^2] That's the energy per operation; power also falls with frequency.
- [any] $V^2$ times the speed ratio.
:::
:::
:::

::: check
kind: parts
given: E = 2 | 10; L = 20 | 80; r = 1 | 3

## Waking a block costs {E} µJ; it leaks {L} mW awake and {r} mW asleep.

::: part
answer: E/(L - r)*1000
unit: µs
tolerance: 0.5%

### What's the break-even sleep time?

::: misses
- [any] $\frac{E}{L - r}$.
:::
:::

::: part
answer: (L - r)*1 - E
unit: µJ
tolerance: 0.5%

### How much energy does a 1 ms sleep save, net?

::: misses
- [any] Savings over 1 ms less the wake-up cost.
:::
:::
:::

::: check
kind: parts
given: N = 8 | 16 | 32; f = 25 | 100

## `always @(posedge clk) c <= c + 1;` with an N = {N}-bit c runs at {f} MHz.

::: part
answer: N
tolerance: 0

### How many flip-flops does it build?

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

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

### How long until c wraps around?

::: misses
- [any] $\frac{2^N}{f}$.
:::
:::
:::

::: check
kind: boolean
vars: sel, a, b
answer: sel & a | ~sel & b
ops: and, or, not

## Write the logic of `assign y = sel ? a : b;`.

::: right
Right: a 2:1 multiplexer, $\text{sel}\cdot a + \overline{\text{sel}}\,b$.
:::

::: misses
- [any] Not yet. sel picks a when 1 and b when 0.
:::
:::

::: check
kind: boolean
vars: en, d, q
answer: en & d | ~en & q
ops: and, or, not

## `always @(*) if (en) y = d;` has no else. Write y in terms of en, d and the latch's stored q.

::: right
Right: a latch, $en \cdot d + \overline{en}\,q$.
:::

::: misses
- [any] Not yet. When en is 0, y holds its old value.
:::
:::

::: check
kind: parts
given: k = 6 | 10 | 14

## A Quine–McCluskey minimizer starts from all the minterms of a {k}-variable function.

::: part
answer: 2^k
tolerance: 0

### At most how many minterms can there be?

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

::: part
answer: 3^k
tolerance: 0

### At most how many implicants (cubes, each variable 0, 1 or don't-care) exist?

::: misses
- [any] $3^k$.
:::
:::
:::

::: check
kind: parts
given: a = -7 | -3 | 5; b = 3 | 6

## Booth's algorithm multiplies {a} by {b} in 4 bits.

::: part
answer: a*b
tolerance: 0

### What's the product?

::: misses
- [any] The signed product.
:::
:::

::: part
answer: 2
tolerance: 0

### How many additions or subtractions does it perform? ({b} is a single run of 1s.)

::: misses
- [any] One at each end of the run.
:::
:::
:::

::: check
kind: parts
given: N = 100 | 143 | 200; D = 9 | 11 | 13

## Restoring division divides {N} by {D} with 8 bits.

::: part
answer: floor(N/D)
tolerance: 0

### What's the quotient?

::: misses
- [any] The whole part of N/D.
:::
:::

::: part
answer: N - D*floor(N/D)
tolerance: 0

### And the remainder?

::: misses
- [any] $N - DQ$.
:::
:::
:::

::: check
kind: parts
given: a = 46 | 58 | 79; b = 37 | 45 | 68

## BCD addition of {a} and {b}.

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

### What decimal sum do the BCD digits spell?

::: misses
- [any] The ordinary sum.
:::
:::

::: part
answer: step((a - 10*floor(a/10)) + (b - 10*floor(b/10)) - 10)
tolerance: 0

### Does the units digit need the +6 correction (1 for yes)?

::: misses
- [any] Only if the units digits sum to 10 or more.
:::
:::
:::

::: check
kind: parts
given: a = 90 | 110 | -100; b = 50 | -60 | -90; n = 8

## An {n}-bit signed saturating adder adds {a} and {b}.

::: part
answer: a + b - (a + b - 127)*step(a + b - 127) - (a + b + 128)*step(-128 - (a + b))
tolerance: 0

### What does it output?

::: misses
- [any] Clamp $a + b$ to −128 to 127.
:::
:::

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

### What's the exact sum it was trying to represent?

::: misses
- [any] The plain sum.
:::
:::
:::
:::
