6.5.11 · D3Advanced & Emerging Architectures

Worked examples — RISC-V custom extensions for accelerators

3,219 words15 min readBack to topic

The scenario matrix

Every problem this topic can throw belongs to one of these case classes. The worked examples below are each tagged with the cell they cover, and together they fill the whole grid.

# Case class What makes it tricky Covered by
A Encoding budget — normal count ops from field widths Ex 1
B Encoding — degenerate / zero one slot, zero free bits, "how many left" Ex 2
C Bit-assembling a real instruction pack funct7/rs2/rs1/funct3/rd/opcode into 32 bits Ex 3
D Speedup — normal (Amdahl) fraction accelerated < 1 Ex 4
E Speedup — limiting case fraction → 1, or infinite hardware speed Ex 5
F Coupling choice — small data tight vs loose decision Ex 6
G Coupling choice — large streaming data RoCC / DMA regime Ex 6
H Real-world word problem crypto/AI kernel, profile first Ex 7
I Exam twist / trap "unimplemented op" behaviour, sign of a saturating result Ex 8
J Boundary of the opcode space all 4 slots used, running out Ex 9

Notice the grid spans counting, bit-packing, performance, architecture choice, and traps. We now cover each cell.


Case A — Encoding budget, the normal count


Case B — Degenerate / zero free bits


Case C — Bit-assembling a real instruction


Case D — Speedup, the normal Amdahl regime


Case E — Limiting cases of speedup


Case F & G — Choosing the coupling


Case H — Real-world word problem (profile first)


Case I — Exam trap: unimplemented op & saturating sign


Case J — Boundary of the opcode space


Active recall

Recall Which cells did we cover, and can you reproduce one from each family?
  • Counting (A/B/J): per slot, total, subtract used, escape via immediate.
  • Bit-packing (C): funct7|rs2|rs1|funct3|rd|opcode → hex.
  • Performance (D/E/H): , ceiling .
  • Architecture (F/G): data volume vs latency → tight or RoCC.
  • Traps (I): unimplemented ⇒ trap; saturate clamps, not wraps.
Recall Quick self-tests

Encoding budget of one custom slot? ::: ops. Overall speedup if , ? ::: . Absolute ceiling when ? ::: . Saturating signed-8 of ? ::: clamp, not . A standard core meets your custom op? ::: illegal-instruction trap, never silent wrong result.


Connections

How many custom R-type ops fit in one opcode slot?
.
Hex encoding of mac x5,x6,x7 (custom-0, funct3=000, funct7=0)?
0x0073028B.