Skip to content

Register File

A register file is a set of registers organized as an addressed array.

In CPUs, register files typically provide:

  • multiple read ports (e.g., read two source operands in the same cycle)
  • at least one write port (write back results on a clock edge)
  • address selection for choosing which register to read/write

In this section you will build a simplified multi-port register file: 4 registers × 8 bits, with two read ports and one write port, and observe its read/write behavior.

  • Understand the structure: register array + write decoding + read selection.
  • Understand the difference between ports:
    • the write port is clocked (synchronous write)
    • the read ports are address-selected (combinational read)

Registers: R0R3R0\ldots R3, each 8 bits.

Write port:

  • WA[1:0]WA[1:0]: write address
  • WD[7:0]WD[7:0]: write data
  • WEWE: write enable
  • CLKCLK: clock

Two read ports:

  • RA1[1:0]RD1[7:0]RA1[1:0] \rightarrow RD1[7:0]
  • RA2[1:0]RD2[7:0]RA2[1:0] \rightarrow RD2[7:0]
  • Synchronous write: when WE=1WE=1, on the rising clock edge write WDWD into Reg[WA]Reg[WA].
  • Combinational read: RD1=Reg[RA1]RD1 = Reg[RA1], RD2=Reg[RA2]RD2 = Reg[RA2].
  • Register array: 4 parallel 8-bit registers (R0R3R0\ldots R3)
  • Write selection: decode WAWA with a 2-to-4 decoder; AND with WEWE to form each register’s load/WE
  • Read selection: two 4-to-1 MUXes, one for RD1RD1, one for RD2RD2
  • Simulator: Logisim Evolution

Task 1: Build the 4×8 register array and write port

Section titled “Task 1: Build the 4×8 register array and write port”
  1. Place pins: WAWA, WDWD, WEWE, CLKCLK.
  2. Place 4 Register components (name them R0R3R0\ldots R3).
  3. Set bit widths: WAWA is 2 bits; WDWD and each register are 8 bits.
  4. Wire WDWD to all register inputs; wire CLKCLK to all register clock inputs.
  5. Decode write address:
    • place a 2-to-4 decoder for WAWA
    • AND each decoder output with WEWE and feed to the corresponding register’s enable/write input
  1. Place pins: RA1RA1, RA2RA2, RD1RD1, RD2RD2.
  2. Set bit widths: RA1RA1 and RA2RA2 are 2 bits; RD1RD1 and RD2RD2 are 8-bit outputs.
  3. Place two 4-to-1 MUXes (select bits = 2).
  4. Connect R0R3R0\ldots R3 outputs to the data inputs of both MUXes.
  5. Wire RA1RA1 to MUX1 select and MUX1 output to RD1RD1.
  6. Wire RA2RA2 to MUX2 select and MUX2 output to RD2RD2.

Register file circuit

Figure 3.7: 4×8 multi-port register file circuit.

Use probes to observe RD1RD1 and RD2RD2.

  • Case 1: Write and hold

    • Set WA=10WA=10 (write R2R2), WD=0xA5WD=0xA5, WE=1WE=1.
    • Trigger one rising edge on CLKCLK, then set WE=0WE=0.
    • Change WDWD to 0xFF and trigger multiple clocks: R2R2 should remain 0xA5.
    • Set RA1=10RA1=10, RA2=10RA2=10 and confirm both reads output 0xA5.
  • Case 2: Two read ports in parallel

    • Write 0x3C to R1R1 and 0xF0 to R3R3 (each write requires WE=1WE=1 and a clock edge).
    • Set RA1=01RA1=01, RA2=11RA2=11 and confirm RD1=0x3CRD1=0x3C, RD2=0xF0RD2=0xF0.
    • Without clocking, change RA2RA2 (e.g. to 00) and observe RD2RD2 changes immediately.
  • Case 3: Read/write overlap

    • Keep RA1=10RA1=10 to continuously read R2R2.
    • Write 0x55 to R1R1 (set WA=01WA=01, WD=0x55WD=0x55, WE=1WE=1, trigger clock edge).
    • Confirm reading R2R2 remains unchanged; then set RA2=01RA2=01 and confirm RD2=0x55RD2=0x55.
  • Circuit screenshot (including any extra probes/displays used).
  • Verification notes:
    • why writing requires a clock edge
    • why changing RA1/RA2RA1/RA2 changes RD1/RD2RD1/RD2 immediately
    • why values do not change when WE=0WE=0 even if the clock toggles
  1. If you extend from 4 registers to 8, which key structures must change?
  2. If RA1=WARA1=WA and a write happens in the same cycle, do you observe RD1RD1 as the old value or new value? Explain based on your structure (read is combinational; write happens at the edge).
  • Make R0R0 hard-wired to 0 (always reads 0 regardless of writes).
  • Add a global Reset to clear all registers.
  • Scale up to 8×328\times 32.