---
title: "Problem set 8: processors, caches and physical design"
heading: "Problem set 8: the RISC-V core, pipelining, caches, clocks, resets and physical design"
eyebrow: S3 · Problem set 8
type: problems
---

::: hook
These problems cover lessons 41 to 47: instruction encoding and core timing, pipeline CPI and hazards, cache organization and miss penalties, clock trees, PLLs, jitter and resets, IR drop and on-chip variation.
:::

::: pool
pick: 12

::: check
kind: parts
given: rs2 = 3 | 11; rs1 = 7 | 15; imm = 36 | 300 | 1500

## The store `sw x{rs2}, {imm}(x{rs1})`.

::: part
answer: floor(imm/32)*2^25 + rs2*2^20 + rs1*2^15 + 2*2^12 + (imm - 32*floor(imm/32))*2^7 + 35
base: 16
width: 8

### Its encoding, as eight hex digits?

::: misses
- [any] imm[11:5], rs2, rs1, 010, imm[4:0], 0100011.
:::
:::

::: part
answer: floor(imm/32)
tolerance: 0

### The value in bits 31:25?

::: misses
- [any] imm[11:5].
:::
:::
:::

::: check
kind: parts
given: c = 45 | 55; i = 220 | 280; r = 130 | 170; a = 180 | 240; d = 220 | 320; m = 25; s = 20

## A single-cycle core: clock-to-Q {c}, instruction memory {i}, register read {r}, ALU {a}, data memory {d}, mux {m}, setup {s} ps.

::: part
answer: c + i + r + a + d + m + s
unit: ps
tolerance: 0.5%

### Clock period?

::: misses
- [any] The load's path.
:::
:::

::: part
answer: c + i + r + a + m + s
unit: ps
tolerance: 0.5%

### How long does an R-type instruction actually need?

::: misses
- [any] No data memory.
:::
:::
:::

::: check
kind: parts
given: l = 0.22 | 0.3; s = 0.08 | 0.14; b = 0.12 | 0.18; T = 280 | 350

## A multicycle core (load 5, store 4, ALU 4, branch 3 cycles) with a {T} ps clock runs {l} loads, {s} stores, {b} branches and the rest ALU.

::: part
answer: 5*l + 4*s + 3*b + 4*(1 - l - s - b)
tolerance: 0.5%

### CPI?

::: misses
- [any] Weighted average.
:::
:::

::: part
answer: (5*l + 4*s + 3*b + 4*(1 - l - s - b))*T
unit: ps
tolerance: 0.5%

### Average time per instruction?

::: misses
- [any] CPI times period.
:::
:::
:::

::: check
kind: parts
given: L = 0.2 | 0.3; u = 0.3 | 0.6; B = 0.12 | 0.2; m = 0.08 | 0.25; P = 2 | 3; S = 900 | 1100; T = 260 | 320

## A pipelined core with forwarding: {L} loads ({u} used at once), {B} branches mispredicted {m} of the time at a {P}-cycle penalty, a {T} ps clock; the single-cycle version takes {S} ps.

::: part
answer: 1 + L*u + B*m*P
tolerance: 0.5%

### CPI?

::: misses
- [any] $1 + f_Lu + f_BmP$.
:::
:::

::: part
answer: S/((1 + L*u + B*m*P)*T)
tolerance: 0.5%

### Speedup over single cycle?

::: misses
- [any] $T_s/(\text{CPI}\,T_p)$.
:::
:::
:::

::: check
kind: parts
given: N = 12 | 40; n = 1 | 4; b = 2 | 3; s = 3 | 4

## A five-stage pipeline resolves branches in stage {s} and runs {N} instructions with {n} load-use stalls and {b} mispredicted branches.

::: part
answer: s - 1
tolerance: 0

### Misprediction penalty?

::: misses
- [any] Stages fetched past.
:::
:::

::: part
answer: 5 + N - 1 + n + (s - 1)*b
tolerance: 0

### Total cycles?

::: misses
- [any] Fill, one per instruction, plus stalls.
:::
:::
:::

::: check
kind: parts
given: S = 16 | 64 | 256; B = 32 | 64; W = 2 | 4 | 8; A = 32 | 40

## A {S} KB, {W}-way cache with {B}-byte lines and {A}-bit addresses.

::: part
answer: log(S*1024/(B*W))/log(2)
tolerance: 0.4

### Index bits?

::: misses
- [any] $\log_2(S/BW)$.
:::
:::

::: part
answer: A - log(S*1024/W)/log(2)
tolerance: 0.4

### Tag bits?

::: misses
- [any] A minus index minus offset.
:::
:::

::: part
answer: S*1024/B*(8*B + A - log(S*1024/W)/log(2) + 2)
tolerance: 0.5%

### Total SRAM bits, with valid and dirty bits?

::: misses
- [any] Lines × (data + tag + 2).
:::
:::
:::

::: check
kind: parts
given: h = 1 | 2; m = 0.02 | 0.06; L = 60 | 150; B = 64 | 128; w = 16 | 32

## A cache hits in {h} cycles with a {m} miss rate; a miss waits {L} cycles, then moves a {B}-byte line over a {w}-byte bus.

::: part
answer: L + B/w
tolerance: 0.5%

### Miss penalty?

::: misses
- [any] Latency plus transfer.
:::
:::

::: part
answer: h + m*(L + B/w)
tolerance: 0.5%

### AMAT?

::: misses
- [any] Hit plus miss rate times penalty.
:::
:::
:::

::: check
kind: parts
given: f = 20 | 50; N = 48 | 120; M = 1 | 2; P = 2 | 4; s = 1 | 2.5

## A PLL with a {f} MHz reference and dividers N = {N}, M = {M}, P = {P}, whose output has {s} ps rms jitter.

::: part
answer: f*N/(M*P)
unit: MHz
tolerance: 0.5%

### Output frequency?

::: misses
- [any] $fN/(MP)$.
:::
:::

::: part
answer: 2*7.03*s
unit: ps
tolerance: 0.5%

### Peak-to-peak jitter at $10^{-12}$ (Q = 7.03)?

::: misses
- [any] $2Q\sigma$.
:::
:::
:::

::: check
kind: parts
given: N = 20000 | 800000; f = 6 | 10; D = 0.46 | 0.53; F = 500 | 1000

## A clock tree of fanout-{f} buffers reaches {N} flip-flops; the {F} MHz clock has a {D} duty cycle.

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

### Levels?

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

::: part
answer: D*1e6/F
unit: ps
tolerance: 0.5%

### Time from rising to falling edge?

::: misses
- [any] $DT$.
:::
:::
:::

::: check
kind: parts
given: I = 40 | 150; R = 4 | 12; P = 3 | 20; V = 0.75 | 0.9; J = 2 | 4

## A {R} Ω rail carrying {I} mA drawn evenly; and a block of {P} W at {V} V on metal rated {J} mA per µm.

::: part
answer: I*R/8
unit: mV
tolerance: 0.5%

### Worst drop on the rail fed from both ends?

::: misses
- [any] $IR/8$.
:::
:::

::: part
answer: P/V*1000/J
unit: µm
tolerance: 0.5%

### Total wire width for the block's current?

::: misses
- [any] Current over the rating.
:::
:::
:::

::: check
kind: parts
given: T = 900 | 1300; L = 320 | 460; D = 450 | 750; C = 300 | 440; s = 30; l = 1.07 | 1.1; e = 0.9 | 0.93; c = 200 | 280

## A {T} ps clock: launch clock {L} ps, data {D} ps, capture clock {C} ps, setup {s} ps, derates {l} and {e}; the clock paths share {c} ps.

::: part
answer: T + e*C - l*(L + D) - s
unit: ps
tolerance: 0.5%

### OCV setup slack before CRPR?

::: misses
- [any] Launch side late, capture early.
:::
:::

::: part
answer: T + e*C - l*(L + D) - s + c*(l - e)
unit: ps
tolerance: 0.5%

### After CRPR?

::: misses
- [any] Credit back $t_\text{common}(d_l - d_e)$.
:::
:::
:::

::: check
kind: parts
given: n = 2 | 3; f = 100 | 400; a = 15 | 60; b = 40 | 90; c = 70 | 110

## A {n}-flop reset synchronizer at {f} MHz, and a net with pins at x = {a}, {b} and {c} µm, all on one row.

::: part
answer: n*1000/f
unit: ns
tolerance: 0.5%

### Longest time from reset release to leaving reset, in whole cycles?

::: misses
- [any] n clock periods.
:::
:::

::: part
answer: (abs(a - b) + abs(b - c) + abs(a - c))/2
unit: µm
tolerance: 0.5%

### Half-perimeter wire length?

::: misses
- [any] Largest x minus smallest.
:::
:::
:::

::: check
kind: parts
given: i = 6 | 7 | 9; o = 5 | 6; W = 2 | 4 | 8; A = 32 | 48

## A cache uses {i} index bits and {o} offset bits with {W} ways, on {A}-bit addresses.

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

### How big is it?

::: misses
- [2^(i + o)/1024] Multiply by the ways.
- [any] $2^{i + o}W$ bytes.
:::
:::

::: part
answer: A - i - o
unit: bits
tolerance: 0

### How wide is each tag?

::: misses
- [any] Address less index and offset.
:::
:::
:::

::: check
kind: parts
given: m = 0.02 | 0.05 | 0.1; h = 8 | 14; q = 0.1 | 0.3; M = 80 | 200

## An L1 cache hits in 1 cycle and misses {m} of the time to an L2 that hits in {h} cycles and misses {q} of its accesses to memory at {M} cycles.

::: part
answer: 1 + m*(h + q*M)
unit: cycles
tolerance: 0.5%

### What is the average memory access time?

::: misses
- [1 + m*M] Most L1 misses hit in the L2.
- [any] $h_1 + m_1(h_2 + m_2t_\text{mem})$.
:::
:::
:::

::: check
kind: parts
given: n = 32 | 128; c = 1.5 | 2; i = 0.6 | 0.9; g = 4 | 8; V = 0.7 | 0.9; f = 1 | 2

## A bank of {n} flip-flops with {c} fF clock pins is idle {i} of the time; a clock-gating cell adds {g} fF that always toggles. The clock is {f} GHz at {V} V.

::: part
answer: n*c*V^2*f
unit: µW
tolerance: 0.5%

### What does the bank's clock load burn ungated?

::: misses
- [any] $nCV^2f$.
:::
:::

::: part
answer: (n*c*i - g)*V^2*f
unit: µW
tolerance: 0.5%

### How much does gating save?

::: misses
- [n*c*i*V^2*f] The gating cell's own clock pin toggles every cycle.
- [any] $(nCi - C_\text{gate})V^2f$.
:::
:::
:::
:::
