---
title: Problem set 9
heading: "Problem set 9: state machines and memory"
eyebrow: C7 · Problem set 9
type: problems
---

::: hook
These problems use lessons 37 to 45: finite state machines, designing them, memory technologies, and memory arrays with programmable logic.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 5 | 9 | 13 | 33

## A state machine has {N} states.

::: part
answer: ceil(log(N)/log(2))
tolerance: 0.5%

### How many flip-flops does a binary encoding need?

::: misses
- [any] $\lceil\log_2 N\rceil$.
:::
:::

::: part
answer: 2^ceil(log(N)/log(2)) - N
tolerance: 0

### How many unused codes does it leave?

::: misses
- [any] Codes minus states.
:::
:::
:::

::: check
kind: parts
given: n = 3 | 5 | 8

## A machine detects a particular {n}-bit input sequence, overlapping allowed.

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

### How many states does a Moore version need?

::: misses
- [any] One per matched prefix, including none.
:::
:::

::: part
answer: n
tolerance: 0

### How many does a Mealy version need?

::: misses
- [any] The output rides on the last transition.
:::
:::
:::

::: check
kind: boolean
vars: Q1, Q0, X
answer: Q0 & ~X | Q1 & ~Q0 & X
ops: and, or, not

## A Moore 101 detector codes its states S0 = 00, S1 ("1") = 01, S2 ("10") = 10, S3 ("101") = 11. Write $Q_1^+$.

::: misses
- [any] Transitions into S2 and S3.
:::
:::

::: check
kind: boolean
vars: Q1, Q0, X
answer: Q0 & ~X
dontcare: 6, 7
ops: and, or, not

## A Moore machine detects the pair 10. Its states are S0 = 00 (nothing yet), S1 = 01 (just saw 1) and S2 = 10 (just saw 10, output 1); a 1 always leads to S1, a 0 from S1 leads to S2, and a 0 from S0 or S2 leads to S0. The code 11 is never used. Write $Q_1^+$.

::: misses
- [any] Not yet. Only S1 with X = 0 leads to S2.
:::
:::

::: check
kind: parts
given: s = 0 | 1 | 2 | 3; n = 5 | 10; N = 4 | 6

## A ring of {N} states advances one state per clock, wrapping after the last.

::: part
answer: s + n - N*floor((s + n)/N)
tolerance: 0

### Starting in state {s}, where is it after {n} clocks?

::: misses
- [any] Add and wrap modulo {N}.
:::
:::

::: part
answer: N
tolerance: 0

### How many flip-flops does a one-hot encoding use?

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

::: check
kind: parts
given: n = 16 | 20 | 28; w = 8 | 16 | 32

## A memory has {n} address lines and {w}-bit words.

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

### How many words does it hold?

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

::: part
answer: 2^n*w/8/2^20
unit: MiB
tolerance: 0.5%

### How many mebibytes is that?

::: misses
- [any] Words × bits ÷ 8 ÷ $2^{20}$.
:::
:::
:::

::: check
kind: parts
given: Wt = 128 | 512; mt = 16 | 64; Wc = 32 | 64; mc = 8 | 16

## A {Wt}K × {mt} memory is built from {Wc}K × {mc} chips.

::: part
answer: Wt/Wc*mt/mc
tolerance: 0

### How many chips?

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

::: part
answer: log(Wt/Wc)/log(2)
tolerance: 0.1%

### How many address bits drive the chip-select decoder?

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

::: check
kind: parts
given: rows = 8192 | 16384 | 65536; T = 32 | 64

## A DRAM must refresh all {rows} rows every {T} ms.

::: part
answer: T/rows*1e6
unit: ns
tolerance: 0.5%

### How often must it refresh one row?

::: misses
- [any] Period over rows.
:::
:::

::: part
answer: rows/T*1000
tolerance: 0.5%

### How many row refreshes per second?

::: misses
- [any] Rows per period.
:::
:::
:::

::: check
kind: parts
given: tau = 40 | 150; V = 0.3 | 0.6

## A bit line's sense signal grows as $1 - e^{-t/\tau}$ with τ = {tau} ps.

::: part
answer: tau*ln(1/(1 - V))
unit: ps
tolerance: 0.5%

### How long until it reaches {V} of its final value?

::: misses
- [any] Solve $1 - e^{-t/\tau} = V$.
:::
:::

::: part
answer: tau*ln(1/(1 - 0.9))
unit: ps
tolerance: 0.5%

### And 90%?

::: misses
- [any] $\tau\ln 10$.
:::
:::
:::

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

## A ROM implements {m} functions of {n} inputs.

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

### How many bits does it store?

::: misses
- [any] $2^n \times m$.
:::
:::

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

### How many words?

::: misses
- [any] One per input combination.
:::
:::
:::

::: check
kind: parts
given: k = 4 | 6; n = 13 | 21 | 31

## An FPGA has {k}-input LUTs.

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

### How many configuration bits does each LUT hold?

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

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

### How many LUTs does an {n}-input AND take?

::: misses
- [any] The first takes k inputs, each later one k − 1 new ones.
:::
:::
:::

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

## A 2-input LUT is configured $K_0$ = 1, $K_1$ = 0, $K_2$ = 0, $K_3$ = 1 (selected by AB). What does it compute?

::: misses
- [any] The configuration bits are the truth table.
:::
:::

::: check
kind: parts
given: B = 50 | 300; fw = 120 | 240; fr = 40 | 90

## Bursts of {B} words at {fw} MHz feed a reader at {fr} MHz through a FIFO.

::: part
answer: B*(1 - fr/fw)
tolerance: 0.5%

### What depth does a burst need?

::: misses
- [any] $B\left(1 - \frac{f_r}{f_w}\right)$.
:::
:::

::: part
answer: B*(1 - fr/fw)/fr
unit: µs
tolerance: 0.5%

### How long does the reader take to drain that backlog?

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

::: check
kind: parts
given: V = 0.65 | 0.8; Vt = 0.25 | 0.35

## A design scales from 1.0 V to {V} V with $V_t$ = {Vt} V.

::: part
answer: V^2
tolerance: 0.5%

### What fraction of the energy per operation remains?

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

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

### What fraction of the speed?

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

::: check
kind: parts
given: s = 6 | 11 | 20

## A controller has {s} states.

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

### How many flip-flops with binary encoding?

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

::: part
answer: s
tolerance: 0

### With one-hot?

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