5.1.4 · D4Instruction Set Architecture (ISA)

Exercises — Register file organization

2,454 words11 min readBack to topic

Before we start, here is the entire symbol kit on one card so nothing appears "out of nowhere."

Figure — Register file organization

The figure above shows the one picture behind everything: a grid of rows (one per register), each row cells wide, with read wires and write wires threading through every cell. Keep this image in your head — most exercises are just "what happens to this grid if I change one number?"


Level 1 — Recognition

Recall Solution

WHAT: we want the smallest with . WHY: each address bit doubles how many registers you can name; you need enough patterns to give every register a unique name. Check: exactly, so 4 bits name all 16 registers with none left over.

Recall Solution
  • Read = a ==-to-1 multiplexer== (MUX): many inputs, choose one onto the output wire. One MUX per read port.
  • Write = a ==-to- decoder== whose outputs are ANDed with a global WriteEnable: it lights up exactly one register's capture line. WHY these two and not others? "Pick one of many onto a wire" is the definition of a MUX; "send one wire to one of many" is the definition of a decoder. They are mirror images of each other. See Multiplexers and Decoders.

Level 2 — Application

Recall Solution

WHAT: total state . WHY: ports affect wiring/area, not stored data. The amount you can store is simply (number of slots) × (width of each slot).

Recall Solution

WHAT: each register field is bits, and there are 3 fields. WHY it matters: those 15 bits are gone before you even spend a single bit on the opcode. This is exactly why enlarging is not free — it widens every instruction. See Instruction Set Architecture (ISA).

Recall Solution

WHAT: area , and are unchanged so they cancel. WHAT IT LOOKS LIKE: in the grid figure, doubling the ports both thickens the wire bundle through each cell (more wires) and stretches each cell taller and wider — height × width both grow, so the product grows as the square. Four times bigger, not twice.


Level 3 — Analysis

Recall Solution

WHAT the instruction demands: add rd, rs1, rs2 must read rs1 and rs2 in the same cycle (that is 2 simultaneous reads) and later store one result into rd (1 write). WHY that maps to ports: the ALU has two operand inputs and one result output (see Datapath and ALU). Two operands read at once ⇒ ; one result ⇒ . Fewer read ports and the ALU would starve waiting for its second operand. What would change it: issuing more instructions per cycle (superscalar), or an instruction with 3 source operands (e.g. fused multiply-add reads 3), pushes up; committing two results per cycle pushes up. Each bump costs the square.

Recall Solution

WHAT happens depends on the timing policy:

  • Read-first: the read port sees the old R5 value (the write lands on the clock edge, after the read has already sampled).
  • Write-first / internal forwarding: the new value is steered onto the read bus, so the reader gets the new R5. WHY it matters: if a later dependent instruction needs the just-computed value and the file is read-first with no help, it reads stale data — a data hazard. Real designs add a forwarding/bypass MUX that compares the read address to the write address and, on a match, feeds the fresh value straight through. See Pipeline Hazards.

Level 4 — Synthesis

Recall Solution

WHAT: every issued op needs 2 reads and 1 write, and 3 issue in parallel. Area factor: WHY this shapes real chips: a 3-wide file is the area of a single-issue one. That's why wide machines often bank or cluster the register file — split it into smaller copies so each copy has fewer ports, dodging the square law. This is a core reason superscalar design is hard.

Recall Solution

WHAT the trick buys you:

  • mov rd, rs add rd, rs, r0 because .
  • nop add r0, r0, r0 — it computes and the write to R0 is discarded, so nothing changes. WHY it saves opcodes: you reuse the ALU's add you already built; no dedicated mov/nop opcode needed, freeing encoding space (see RISC vs CISC). Hardware cost: essentially nothing — you don't build flip-flops for R0; its read-MUX input line is tied low (constant 0), and its decoder line is disconnected so writes vanish.

Level 5 — Mastery

Recall Solution

(a) Address width. bits. Why: names all registers, R0 included (it still has a name, it just always reads 0). (b) Usable stored bits. All 32 slots have a name but R0 has no flip-flops, so 31 real registers store data: (The naive counts a slot that stores nothing.) (c) Register-name bits per add. Three fields, each : bits. (d) Widening factor. — four times the area.

Recall Solution

Design A area (drop the common ): Design B area (two banks, add them): Ratio: . Design B is 4× smaller in this simplified model. WHY it reflects reality: banking dodges the square law by keeping each bank's port count low. The catch (not in the area formula): an operand living in the "wrong" bank forces a cross-bank read, so real designs must schedule operands into the right bank — a genuine engineering trade-off. See Datapath and ALU.


Active Recall

Recall Quick self-quiz (answers hidden)
  1. ⇒ how many address bits? → .
  2. , R0 hardwired ⇒ usable stored bits? → .
  3. Going multiplies area by? → .
  4. 3-issue, 2R+1W each ⇒ and area factor? → ; .
  5. Why bank a register file? → keeps ports-per-bank low, beating the square law.

Connections


For registers, how many address bits per register field?
.
Going from to , how many times larger is the register file?
.
Why bank/cluster a superscalar register file?
To keep each bank's port count low and dodge the area square law.