# Computer architecture why is MemRead used?

Why is a control signal MemRead needed for the Data Memory element if whenever the output Read Data is not desired it will be multiplexed out via MemtoReg?

Wouldn't having MemRead always enabled just cause Read Data to always output whatever is currently stored at targeted address, making it readily available to be used if required, or ignored if not required via the multiplexer?

Does Data Memory, being sequential, only execute on a clock edge and cannot complete two tasks at once like this? Isn't it true that combinational elements such as the ALU always output f(input1, input2) regardless of clock edge?

Wouldn't having MemRead always enabled just cause Read Data to always output whatever is currently stored at targeted address

Yes, it would output whatever is stored at the targeted address, but the targeted address might be from the last write operation.

or ignored if not required via the multiplexer

If the multiplexer is set to 0, the address will be output. If you want to hold the read value constant while write operations are happening, you would need to set MemRead low, and the mux selector, MemtoReg high.

Yes, if it's static RAM, it could just send whatever is addressed to the multiplexer always.

However, if it's DRAM, then it needs periodic refresh cycles. If the refresh is generated internally in the "memory" black box, then giving it both a read and a write signal allows it to know when it can safely take time off to do a refresh step.

Another explanation would be that it has to do with timing. Perhaps the memory needs several cycles to work, and the data path can be used for something productive meanwhile (assuming that the memory latches the address internally)?

• Additionally, some memory-mapped registers have side effects when you read them. Apr 28 '18 at 23:04

Not all processors have a MemRead signal.

It's generally useful for memory-mapped registers. Sometimes, specific memory addresses are connected to special hardware (instead of memory) and reading them might cause something to happen. For example, you might have a FIFO buffer, which returns a different value each time you read it. Having a MemRead signal ensures that if the address happens to be equal to the FIFO buffer's address, but the memory is bypassed (MemtoReg is 0), it won't accidentally count as a read.