Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIPS 32-bit architecture: how can a register in a register file be read from and written to in the same clock cycle?

My computer architecture books explains that

"Since writes to the register file are edge-triggered, our design can legally read and write the same register within a clock cycle: the read will get the value written in an earlier clock cycle, while the value written will be available to read in a subsequent clock cycle."

This makes some sense, and I somewhat understand what's going on with the register file. However, I don't understand when each event happens. Say we're reading from one of the 32 register files and writing to it in the same cycle. When would the register be read from? When would it be written to? I don't totally understand how events are triggered by the clock-edges, so it'd help to have that explained too. Thank you!

like image 226
Maharlikans Avatar asked Nov 04 '12 20:11

Maharlikans


People also ask

What is register file in MIPS 32 architecture?

The register file contains the 32 MIPS general-purpose (integer/address) registers. One can view the register file as an array of registers. An R-type instruction uses two register values as input and one register as output. Thus, there are two register read data ports and one register write data port.

Why do we do a register write in first half of a clock cycle and read in the second half?

The register file can be read and written in the same cycle. The write takes place during the first half of the cycle and the read takes place during the second half of the cycle, so a register can be written and read back in the same cycle without introducing a hazard.

What is designed to enable two registers to be read at the same time?

This register file makes possible to simultaneously read from two registers and write into one register as it is appropriate for MIPS processor.

How does a register file work?

Register files have one word line per entry per port, one bit line per bit of width per read port, and two bit lines per bit of width per write port. Each bit cell also has a Vdd and Vss. Therefore, the wire pitch area increases as the square of the number of ports, and the transistor area increases linearly.


2 Answers

Reading the value of a register is asynchronous, whereas in the architecture you are working in your class, the registers are written sychronously (i.e. the writes are edge-triggered).

This means that you can read the current value of a register, apply some operation on it (e.g. add some immediate) and write the result at the next raising clock edge.

Suppose you want to issue an addiu $1, $1, 123, that is take the current value of $1, add 123 and store the result back in $1.

At the start of the clock cycle the control unit would instruct the register file to put the contents of $1 in one of the data buses that gets into the ALU. the control unit would also instruct to put the immediate 123 in the other data bus that also gets into the ALU. The addition which is just a combinatorial circuit implemented inside the ALU would compute the said addition and put the result in the data bus that connects the register file for storage. All of this is done before the raising edge of the clock happens and the result of the addition gets presented until the next raising edge. At some point the raising edge occurs and the result of the addition is now written back into register $1.

like image 57
gusbro Avatar answered Nov 18 '22 17:11

gusbro


The register file is built from flip-flops. Each flip-flop has a store, an input, an output and a trigger. The output is always presenting the stored value, so can be read all the time. With a rising edge on the trigger, the input value moves into the store.

like image 45
Conor OG Avatar answered Nov 18 '22 17:11

Conor OG