yeolyi.comSeongyeol's CS

Register Files

A CPU contains several registers. How do we pick one of them to read, or to write a new value into?

The register file

A set of registers bundled so that we can pick one by its number (address) to read or write is called a register file. The picking is split between a MUX and a decoder.

Below is a register file made of four 1-bit registers (numbered 0~3 from the top). The write address WA1·WA0 goes into the decoder, and the read address RA1·RA0 goes into the MUX. With separate addresses, we can read one register while writing to another.

  1. WA and RA are both 00. Change IN and Write to 1, then change CLK to 1. Register 0 stores 1, and OUT becomes 1.
  2. Set Write and IN back to 0, then change RA0 to 1. OUT shows the 0 in register 1.
  3. Set RA0 back to 0 and OUT is 1. Register 0 is keeping its value.

Abstraction

From now on, we’ll draw this circuit as a single REGISTER FILE box. The inputs are the same: WA1·WA0, RA1·RA0, IN, Write (W), and CLK. OUT gives the value of the register that RA1·RA0 selects. Inside the box, we show the values of the four registers.

Wrapping up

After the circuit that adds, we’ve now built a register file that remembers the results. We now have two abilities: computing and remembering. But four registers can hold only four numbers. In the next post, let’s see how to hold a great many numbers.

Challenge

We want to build the read circuit of a register file with eight 8-bit registers using only 2-to-1 MUXes. It must output all 8 bits of the register the address selects. At least how many 2-to-1 MUXes are needed? Answer with a number.