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

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 9× 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, rsadd rd, rs, r0because .nopadd r0, r0, r0— it computes and the write to R0 is discarded, so nothing changes. WHY it saves opcodes: you reuse the ALU'saddyou already built; no dedicatedmov/nopopcode 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)
- ⇒ how many address bits? → .
- , R0 hardwired ⇒ usable stored bits? → .
- Going multiplies area by? → .
- 3-issue, 2R+1W each ⇒ and area factor? → ; .
- Why bank a register file? → keeps ports-per-bank low, beating the square law.
Connections
- Parent: Register File Organization — the concepts these exercises drill.
- Multiplexers and Decoders — the read (MUX) and write (decoder) hardware.
- Datapath and ALU — why 2 read + 1 write matches the ALU.
- Pipeline Hazards — read-during-write and forwarding.
- Instruction Set Architecture (ISA) — register fields inside instruction encoding.
- RISC vs CISC — R0 tricks and the many-register philosophy.
- Memory Hierarchy — where registers sit as the fastest tier.