Skip to content
BetterDL

Write port

Also called: register file write port, write address, write ports, input port

A register file's input path: write data, a write address and a write enable. At a clock edge with the enable on, the addressed register loads the data.

A write port puts a value into one register of a register file. It has three parts:

  • the write data, n bits, sent to every register,
  • the write address, log₂ k bits, which picks one register,
  • the write enable W, which says whether to write at all.

How it is built: every register is a load enable register. A decoder turns the write address into one-hot lines, and each line is ANDed with W to make that register's load enable. For 4 registers, register 2's load enable is L2 = .

The sequence of events for one write:

  1. The address, data and W = 1 are set up during the cycle.
  2. The decoder and AND gates raise exactly one load enable.
  3. At the rising edge, that register loads the data; all others hold.

Writing happens only at the edge, unlike reading, which is combinational. With W = 0 every load enable is 0, so nothing changes even if the address and data lines are busy.

The output path is the read port.

Worked examples

Example

Load enable for one register

In an 8-register file, the write address is A2 A1 A0 (A2 is the MSB) and W is the write enable. What load enable does register 3 get?

  1. 1.

    3 in binary is 011: A2 = 0, A1 = 1, A0 = 1.

  2. 2.

    The decoder line for 3 is .

  3. 3.

    AND it with W: L3 = .

Example

A write with W = 0

In a 4-register file, the write address is 11 and the data is 0101, but W = 0 at the edge.

  1. 1.

    Every load enable includes W, so all are 0.

  2. 2.

    Every register holds. Nothing is written, including register 3.

Common mistakes

  • Driving the load enables from the decoder alone. Without W, some register is written at every edge.

  • Expecting the register to change as soon as the address and data are set. It changes at the edge.

Practice Write port

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Write port is taught in Registers and Basic CPU / Computer Architecture.