2

I know that the Arithmetic Logic Unit (ALU of a processor performs arithmetic (and bitwise) operations and the result is stored as the ALU's output - but what component, device or software is actually accessing/using the output of an ALU? And is it valid to say that the ALU returns the result of an operations or would that be wrong?

Robert Harvey
  • 200,592

1 Answers1

3

It depends heavily on the processor design; however, broadly I'd say that, the ALU output from a requested operation is temporarily available, and depending on the instruction being executed:

  • the ALU output is captured to the accumulator, or
  • to a particular register, or
  • even sent to the data bus (e.g. for a memory write operation), or
  • sent back to the ALU as input for another operation, or,
  • simply ignored!

Regarding the last, not all instructions make a request of the ALU — consider a branch instruction, perhaps, that has its own way of computing the new pc value not involving the ALU. However, even when not in use, the ALU is still there and still has output lines, just that the capture/forwarding mechanism is configured to do nothing with the output.


Yes, so let's talk about a machine instruction that does ADD r3,r1,r2 where r1 & r2 are sources from the register file and r3 is a target in the register file.

Register r3 will (at the one proper cycle when the ALU result is know to be read) be switched into a capture mode and the ALU output will be made available to the register file data lines. By the next clock, the ALU output will have been captured into r3.

If the instruction had been "LOAD r3, ..." then the same capture enable would happen but the data bus value would be made available to the register file data lines instead of the ALU.

Later if a STORE r3,... is executed, the value in r3 will be placed onto the data bus for the memory write.


The register file is "ported". It can have multiple read and/or write ports. Each port allows access to the register file in the same cycle. So, two read ports and one write port would mean that two different registers can be read in the same cycle and that one can be written in that same cycle.

Erik Eidt
  • 34,819