---
title: Problem set 7
heading: "Problem set 7: interfaces, arbitration, codes and the processor"
eyebrow: S3 · Problem set 7
type: problems
---

::: hook
These problems use lessons 36 to 43: valid/ready interfaces and bursts, arbiters, test and reliability, CRCs and error-correcting codes, the RISC-V core, its pipeline and its caches.
:::

::: pool
pick: 12

::: check
kind: parts
given: a = 2 | 4; b = 1 | 2; c = 1 | 3; d = 1 | 2; B = 1.6 | 6.4

## Four requesters share a {B} GB/s port by weighted round-robin with weights {a}, {b}, {c} and {d}. The third requester goes idle.

::: part
answer: a/(a + b + c + d)*B
unit: GB/s
tolerance: 0.5%

### What bandwidth does the first get when all four are busy?

::: misses
- [any] $w_1/\sum w$ of the port.
:::
:::

::: part
answer: a/(a + b + d)*B
unit: GB/s
tolerance: 0.5%

### And with the third idle?

::: misses
- [a/(a + b + c + d)*B] Idle requesters' turns go to the others.
- [any] Share among the active weights only.
:::
:::
:::

::: check
kind: parts
given: p = 0.2 | 0.4; q = 0.3 | 0.5; r = 0.1 | 0.3

## Under fixed priority, three higher requesters ask independently in fractions {p}, {q} and {r} of cycles.

::: part
answer: (1 - p)*(1 - q)*(1 - r)*100
unit: %
tolerance: 0.5%

### At most what share of cycles can the fourth requester win?

::: misses
- [(1 - p - q - r)*100] Independent requests overlap; multiply the idle probabilities.
- [any] $(1 - p)(1 - q)(1 - r)$.
:::
:::
:::

::: check
kind: parts
given: N = 4 | 8 | 16; B = 4 | 16; o = 1 | 3; f = 250 | 500

## {N} masters share a bus by round-robin; each grant moves a {B}-beat burst plus {o} cycles of overhead, at {f} MHz.

::: part
answer: (N - 1)*(B + o)
unit: cycles
tolerance: 0

### What is a master's worst-case wait?

::: misses
- [(N - 1)*B] Count each grant's overhead too.
- [any] $(N - 1)(B + o)$.
:::
:::

::: part
answer: (N - 1)*(B + o)*1000/f
unit: ns
tolerance: 0.5%

### How long is that?

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

::: check
kind: parts
given: m = 32 | 64 | 128; p = 1e-6 | 1e-4

## Memory words hold {m} data bits with SECDED, and bits flip independently with probability {p} between scrubs.

::: part
answer: m + ceil(log(m + 1 + ceil(log(m + 1)/log(2)))/log(2)) + 1
unit: bits
tolerance: 0

### How many bits does each stored word have?

::: misses
- [any] Data + Hamming checks + one parity bit.
:::
:::

::: part
answer: 1 - (1 - p)^(m + ceil(log(m + 1 + ceil(log(m + 1)/log(2)))/log(2)) + 1) - (m + ceil(log(m + 1 + ceil(log(m + 1)/log(2)))/log(2)) + 1)*p*(1 - p)^(m + ceil(log(m + 1 + ceil(log(m + 1)/log(2)))/log(2)))
tolerance: 1%

### What is the chance a word has an uncorrectable (two or more bit) error?

::: misses
- [any] $1 - (1 - p)^n - np(1 - p)^{n-1}$.
:::
:::
:::

::: check
kind: parts
given: R = 10 | 25 | 100; f = 200 | 400; n = 16 | 32

## A link runs at {R} Gb/s and checks frames with an {n}-bit CRC, computed by a parallel engine at {f} MHz.

::: part
answer: R*1000/f
unit: bits
tolerance: 0.5%

### How many bits per clock must the engine take?

::: misses
- [any] Rate over clock.
:::
:::

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

### What fraction of randomly corrupted frames escapes detection?

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

::: check
kind: parts
given: v = 1 | 10 | 100 | 1000; o = 8 | 64 | 256

## Encode RISC-V immediates: `addi` with immediate −{v}, and a `beq` whose target is {o} bytes back.

::: part
answer: 4096 - v
tolerance: 0

### What value does the 12-bit I-type immediate field hold?

::: misses
- [v] Negative values are stored in two's complement.
- [any] $4096 - v$.
:::
:::

::: part
answer: 4096 - o/2
tolerance: 0

### What value do the 12 bits imm[12:1] of the branch hold?

::: misses
- [4096 - o] Branch offsets are stored in units of 2 bytes.
- [any] The offset over 2, as a 12-bit two's complement field.
:::
:::
:::

::: check
kind: parts
given: u = 0.3 | 0.5; m = 0.1 | 0.3; r = 0.02 | 0.05; P = 20 | 50

## A pipelined core runs a program with 25% loads ({u} used at once), 10% stores and 15% branches ({m} mispredicted, 2 cycles each). Loads and stores miss the data cache {r} of the time, stalling {P} cycles.

::: part
answer: 1 + 0.25*u + 0.15*m*2 + 0.35*r*P
tolerance: 0.5%

### What is its CPI?

::: misses
- [1 + 0.25*u + 0.15*m*2] Add the cache-miss stalls.
- [any] Sum each hazard's frequency × cost.
:::
:::

::: part
answer: 0.35*r*P/(1 + 0.25*u + 0.15*m*2 + 0.35*r*P)*100
unit: %
tolerance: 0.5%

### What fraction of the time goes to cache misses?

::: misses
- [any] Miss cycles over total CPI.
:::
:::
:::

::: check
kind: parts
given: t = 18 | 20; i = 6 | 7 | 8; o = 5 | 6; W = 2 | 4 | 8

## A cache's addresses split into a {t}-bit tag, a {i}-bit index and a {o}-bit offset; it has {W} ways.

::: part
answer: 2^(i + o)*W/1024
unit: KB
tolerance: 0.5%

### How big is the cache?

::: misses
- [2^(i + o)/1024] Each set holds W lines.
- [any] Sets × ways × line size.
:::
:::

::: part
answer: t + i + o
unit: bits
tolerance: 0

### How wide are the addresses?

::: misses
- [any] Tag + index + offset.
:::
:::
:::

::: check
kind: parts
given: f = 1 | 2; s = 0.1 | 0.15; r = 0.02 | 0.05; y = 0.3 | 0.5; L = 64 | 128

## A core at {f} GHz completes one instruction per cycle; {s} of instructions are 4-byte stores, and 35% are loads or stores. Its data cache misses {r} of accesses, and {y} of evicted lines are dirty.

::: part
answer: s*f*4
unit: GB/s
tolerance: 0.5%

### What write traffic does a write-through cache send onward?

::: misses
- [any] Every store goes onward.
:::
:::

::: part
answer: 0.35*r*y*L*f
unit: GB/s
tolerance: 0.5%

### What does a write-back cache send, writing back {L}-byte dirty lines on eviction?

::: misses
- [any] Accesses × miss rate × dirty fraction × line size.
:::
:::
:::

::: check
kind: parts
given: o = 2 | 4 | 8; E = 0.9 | 0.95

## Each bus transaction costs {o} overhead cycles; bursts carry one beat per cycle.

::: part
answer: o*E/(1 - E)
unit: beats
tolerance: 0.5%

### How long must bursts be for an efficiency of {E}?

::: misses
- [any] Solve $B/(B + o) = E$.
:::
:::
:::

::: check
kind: parts
given: L = 20 | 60 | 120; B = 4 | 8 | 16

## A memory returns a {B}-beat burst {L} cycles after the request; the bus carries one beat per cycle.

::: part
answer: ceil((L + B)/B)
tolerance: 0

### How many bursts must be outstanding to keep the bus busy?

::: misses
- [any] Cover the whole round trip: $\lceil(L + B)/B\rceil$.
:::
:::

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

### What bus utilization does one outstanding burst give?

::: misses
- [any] One burst per round trip.
:::
:::
:::

::: check
kind: parts
given: F = 100000 | 1000000; C = 16 | 32; X = 10 | 50; P = 5000 | 20000; f = 50 | 100

## A chip with {F} flip-flops has {C} scan pins; compression expands them into {X} times as many internal chains. {P} patterns shift at {f} MHz.

::: part
answer: ceil(F/(C*X))
tolerance: 0

### How long is each internal chain?

::: misses
- [ceil(F/C)] Compression multiplies the chain count.
- [any] $\lceil F/(CX)\rceil$.
:::
:::

::: part
answer: P*(ceil(F/(C*X)) + 1)/(f*1e6)*1000
unit: ms
tolerance: 0.5%

### How long does the test take?

::: misses
- [any] $P(L + 1)/f$.
:::
:::
:::

::: check
kind: parts
given: b = 2 | 3 | 5; k = 2 | 4 | 8; m = 64 | 128

## An SRAM row interleaves {k} SECDED words of {m} data bits; a strike flips {b} adjacent cells.

::: part
answer: ceil(b/k)
unit: errors
tolerance: 0

### How many errors does the worst-hit word get?

::: misses
- [any] $\lceil b/k\rceil$.
:::
:::

::: part
answer: k*(m + ceil(log(m + 1 + ceil(log(m + 1)/log(2)))/log(2)) + 1)
unit: bits
tolerance: 0

### How many cells does the row hold?

::: misses
- [k*m] Count the check bits too.
- [any] k × stored word width.
:::
:::
:::

::: check
kind: parts
given: r = 2 | 4; d = 3 | 6; f = 0.5 | 0.75

## A credit-based link has a {r}-cycle credit return and {d} cycles of data latency; the sender must sustain {f} of the link's rate.

::: part
answer: r + d
tolerance: 0

### How many credits give full rate?

::: misses
- [any] Cover the round trip.
:::
:::

::: part
answer: ceil(f*(r + d))
tolerance: 0

### How many does {f} of full rate need?

::: misses
- [any] $\lceil f(r + d)\rceil$.
:::
:::
:::

::: check
kind: parts
given: N = 4 | 8; T = 2 | 6; p = 0.01 | 0.02

## {N} masters share a resource by round-robin with {T}-cycle grants; each wants it in a fraction {p} of cycles.

::: part
answer: N*p*T
tolerance: 0.5%

### What fraction of the resource's capacity do they demand, if each request needs one {T}-cycle grant?

::: misses
- [N*p] Each request holds the resource for T cycles.
- [any] $NpT$.
:::
:::

::: part
answer: (N - 1)*T
unit: cycles
tolerance: 0

### What is the worst-case wait?

::: misses
- [any] $(N - 1)T$.
:::
:::
:::
:::
