For data inputs and selection bits , use a three-to-eight binary decoder. Its output is the minterm that is one exactly when the selection equals the three-bit binary representation of . For example,
Gate each data input with its decoded selection using an AND gate, then combine all eight results with an OR gate:
Exactly one is asserted, so for the selected , regardless of the other data inputs. A direct implementation uses three shared NOT gates, eight three-input AND gates for the binary decoder, eight two-input AND gates for the data, and one eight-input OR gate. Equivalently, combine each decoder term with its data input in one four-input AND gate. Larger logic gates may be built from two-input ones.
Use clocked processor registers, each storing an -bit word, two independent combinational read ports and one synchronous write port. Each address requires bits. The read addresses select two -to-one multiplexers, each bits wide. A write-address binary decoder combines its selected line with the global write enable to form the individual enables:
At the active clock edge, register captures the common write data if , otherwise retaining its word. Reads return the currently stored words selected by their respective addresses. For non-power-of-two , unused address codes need a specified harmless implementation. A simultaneous read and write of one address follows the chosen edge/read timing; an additional forwarding circuit would be needed if a different bypass convention were required.
Figure 1.
Two-read-port register file with a single synchronous write port
. The left panel uses a global write enable; the right shows the MIPS alternative with writes to index zero suppressed. Both read multiplexers select independently, and the alternative returns a hardwired zero for address zero. Details.