---
title: Problem set 12
heading: "Problem set 12: digital logic across the course"
eyebrow: C7 · Problem set 12
type: problems
---

::: hook
These problems use the CRC project and mix in the whole course: number formats, gates, timing, counters, state machines and memories. Each one has your own numbers.
:::

::: pool
pick: 12

::: check
kind: parts
given: m = 51..100 int; n = 1..50 int

## Two 8-bit two's-complement numbers: −{m} and +{n}.

::: part
answer: 256 - m
tolerance: 0

### What unsigned value does the bit pattern for −{m} have?

::: misses
- [255 - m] Invert and then add 1.
- [any] $256 - m$.
:::
:::

::: part
answer: n - m
tolerance: 0

### What's their sum, as a signed value?

::: misses
- [any] Two's complement adds like ordinary numbers.
:::
:::

::: part
answer: n - m + 256
tolerance: 0

### What unsigned value does the sum's 8-bit pattern have?

::: misses
- [n - m] The sum is negative, so its pattern reads as 256 plus it.
- [any] A negative result's pattern is 256 plus its value.
:::
:::

::: right
Right. The adder doesn't care about signs; only the reading does.
:::
:::

::: check
kind: parts
given: tcq = 60 | 100; tg = 20 | 40; n = 5 | 10 | 20; ts = 30 | 50

## A path runs from one flip-flop through {n} gates of {tg} ps each to another flip-flop. The flip-flops have $t_{cq}$ = {tcq} ps and a setup time of {ts} ps.

::: part
answer: n*tg
unit: ps
tolerance: 0.5%

### What's the logic delay?

::: misses
- [any] Gates × delay.
:::
:::

::: part
answer: tcq + n*tg + ts
unit: ps
tolerance: 0.5%

### What's the shortest clock period?

::: misses
- [n*tg] Include $t_{cq}$ and setup.
- [any] $t_{cq} + t_\text{logic} + t_\text{setup}$.
:::
:::

::: part
answer: 1e6/(tcq + n*tg + ts)
unit: MHz
tolerance: 0.5%

### What's the highest clock frequency?

::: misses
- [any] One over the period.
:::
:::

::: right
Right. The critical path sets the clock.
:::
:::

::: check
kind: parts
given: f = 1 | 12 | 50; n = 4 | 8 | 10

## An {n}-bit binary counter runs from a {f} MHz clock.

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

### What's its largest count?

::: misses
- [2^n] It starts from 0.
- [any] $2^n - 1$.
:::
:::

::: part
answer: f*1e6/2^n
unit: Hz
tolerance: 0.5%

### At what frequency does its top bit toggle through a full cycle?

::: misses
- [f*1e6/2^(n - 1)] The top bit is bit n − 1: its frequency is $f/2^n$.
- [any] $f/2^n$.
:::
:::

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

### How long is one full cycle of the count, from 0 back to 0?

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

::: right
Right. A counter divides time into powers of two.
:::
:::

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

## A memory has {n} address bits 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/1024
unit: KiB
tolerance: 0.5%

### How many kibibytes (1 KiB = 1024 bytes)?

::: misses
- [2^n*w/1024] Divide by 8 for bytes first.
- [any] $2^n \times w / 8 / 1024$.
:::
:::

::: part
answer: w
tolerance: 0

### How many data wires does it need?

::: misses
- [n] Those are the address wires.
- [any] One per bit of a word.
:::
:::

::: right
Right. Address bits set how many words; word width sets the data bus.
:::
:::

::: check
kind: parts
given: n = 8 | 16 | 32; L = 64 | 1500

## A link protects {L}-byte frames with an {n}-bit CRC.

::: part
answer: n
tolerance: 0

### What is the longest error burst it's guaranteed to catch?

::: misses
- [any] As long as the CRC.
:::
:::

::: part
answer: n/(8*L + n)*100
unit: %
tolerance: 0.5%

### What fraction of each frame is the CRC?

::: misses
- [any] CRC bits over total bits.
:::
:::
:::

::: check
kind: parts
given: L = 10 | 256 | 4096; n = 8 | 16

## A byte-wide table-driven {n}-bit CRC processes {L} bytes.

::: part
answer: L
tolerance: 0

### How many table lookups does it make?

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

::: part
answer: 8*L
tolerance: 0

### How many shift steps would the bitwise version take?

::: misses
- [any] Eight per byte.
:::
:::
:::

::: check
answer: 4
base: 2
width: 3

## What is the 3-bit CRC of the message 10011101 with generator 1001?

::: misses
- [any] Append 000 and divide by 1001 with XOR.
:::
:::

::: check
kind: parts
given: x = -3 | -77 | -128; y = 5 | 100

## Two's complement in 8 bits.

::: part
answer: x + 256
tolerance: 0

### What unsigned value has the same bits as {x}?

::: misses
- [any] Add 256.
:::
:::

::: part
answer: y + x - 256*step(y + x - 127.5) + 256*step(-128.5 - y - x)
tolerance: 0

### What does {y} + ({x}) give in 8 bits, as a signed value?

::: misses
- [any] Add, then wrap into −128 to 127 if needed.
:::
:::
:::

::: check
kind: parts
given: N = 7 | 24 | 100; f = 12 | 48

## A {f} MHz clock drives a modulo-{N} counter and a one-hot state machine with {N} states.

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

### How many flip-flops does the counter need?

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

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

### How many more does the one-hot machine use?

::: misses
- [any] N minus the binary count.
:::
:::
:::

::: check
kind: parts
given: tpcq = 30 | 60; ts = 20 | 50; f = 1 | 2

## A design must run at {f} GHz with flip-flops of $t_{pcq}$ = {tpcq} ps and $t_\text{setup}$ = {ts} ps.

::: part
answer: 1e3/f - tpcq - ts
unit: ps
tolerance: 0.5%

### How much logic delay is allowed between registers?

::: misses
- [any] The period less the overhead.
:::
:::

::: part
answer: (1e3/f - tpcq - ts)/25
tolerance: 0.5%

### How many 25 ps gates deep can the logic be?

::: misses
- [any] Divide by the gate delay.
:::
:::
:::

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

## A circuit outputs 1 when both A and B are 1 or both C and D are 1. Write it, and note it's an AOI22 followed by an inverter in CMOS.

::: misses
- [any] Two AND terms.
:::
:::

::: check
kind: parts
given: n = 10 | 20 | 30; w = 8 | 64

## A memory has {n} address lines and {w}-bit words, and an FPGA LUT implements its logic in 6-input blocks.

::: part
answer: 2^n*w
tolerance: 0.1%

### How many bits does the memory hold?

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

::: part
answer: 2^6
tolerance: 0

### How many configuration bits does one 6-input LUT hold?

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

::: check
kind: parts
given: H = 32 | 256 | 2048

## An inverter chain drives a load {H} times its input.

::: part
answer: log(H)/log(4)
tolerance: 0.5%

### About how many stages are best?

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

::: part
answer: H + 1
tolerance: 0.5%

### What's the delay of a single inverter driving it, in τ?

::: misses
- [any] $H + 1$.
:::
:::
:::

::: check
kind: parts
given: T = 1 | 3; s = 0.05 | 0.1; t = 20 | 60

## A synchronizer at a {T} ns period uses flops with τ = {t} ps and {s} ns setup.

::: part
answer: (T - s)*1000/t/ln(10)
tolerance: 0.5%

### How many decades of MTBF does each extra stage add?

::: misses
- [any] $\frac{T - t_\text{su}}{\tau\ln10}$.
:::
:::

::: part
answer: (T - s)*1000/t
tolerance: 0.5%

### What's the exponent of e?

::: misses
- [any] $\frac{T - t_\text{su}}{\tau}$.
:::
:::
:::

::: check
kind: parts
given: m = 8 | 32 | 256; r = 8 | 16 | 32

## A message of {m} bytes gets an {r}-bit CRC.

::: part
answer: r/(8*m)*100
unit: %
tolerance: 0.5%

### What's the overhead?

::: misses
- [any] CRC bits over message bits.
:::
:::

::: part
answer: r
tolerance: 0

### What's the longest burst of errors it's guaranteed to detect?

::: misses
- [any] An r-bit CRC catches every burst of r bits or fewer.
:::
:::
:::
:::
