-3

Does the ALU have its own memory or registers where it stores input operands etc. or does it only use CPU registers (that aren't only specifically used for ALU tasks)?

4
  • 1
    A Google Search for "Does the ALU have its own memory or registers" yielded this short lecture, which seems to suggest that the ALU uses the general registers and has none of its own. But CPU manufacturers architect their processors as they see fit, and it wouldn't surprise me if someone put a register or two in the ALU to speed things up at some point. Note that these lectures tend to use older architectural designs, because they are simpler to understand and explain. Commented Jan 27, 2021 at 21:04
  • Entirely depends on the hardware. Registers are not required. Nor are ALU’s. Commented Jan 27, 2021 at 23:36
  • The CPU registers are mainly connected to the ALU, so what difference does it make? The ALU is a box on a drawing; no matter whether you put the registers inside or outside that box the circuit is still the same. Commented Jul 26, 2021 at 14:27

3 Answers 3

1

An ALU is part of the CPU, so your question is worded a little confusingly. ALU registers are CPU registers by definition. That being said, there are registers that are named and visible to a programmer, and there are registers that don't really have a name and are only used internally, especially in a pipelined processor. They will have values like "what used to be in EAX 3 clock cycles ago." Anytime a value needs to be remembered for a while.

1

In hardware there are two ways of wiring circuits:

  • Combinational — combinational circuits compute current outputs from current inputs.  Computation flows from start to finish in a directed acyclic graph of gates.

  • Sequential — sequential circuits compute current outputs from both current inputs and past inputs.  Sequential circuits remember things from cycle to cycle.  They do this by having feedback loops in the circuitry.

The CPU registers are effectively sequential circuits, where they remember data values from cycle to cycle so as to act on those data values as per the instructions of the program being executed, i.e. program loops operate on different data each iteration despite executing the same instructions (the body of the loop) because the register are updated.

Generally speaking, an ALU does is a combinational circuit, providing computational results based on its inputs alone, without memory of previous operations.


The above is gross oversimplification for modern processors.

Multicycle processors spread execution of a single instruction over multiple cycles, as do pipelined processors; both require additional state for managing that, so use additional internal registers.

Register renaming and many other features of the processor (branch prediction, caching, etc..) also involve state that we would consider sequential circuitry, i.e. involving registers or other storage.

0

Modern processors make use of 2 flavors of registers.

  • architectural registers (exposed to the programmer)
  • hardware registers (the ones uses in side)

The X86/AArch64 have just a few architectural registers and this is a huge restriction on the performance because with just this limited number of registers, the instructions need to wait for an register to come available.

That is why processors make use of the Tomasulo algorithm for register renaming that at runtime assigns the architectural registers to physical registers. E.g. the arm AArch64 has just 31 archictural registers, but the M1 more than 600 physical registers. In combination with a huge window for out of order execution, super scalar resources and pipelining, with a relatively low frequency, you can still get a huge performance improvement compared to a simple sequential execution.

Not the answer you're looking for? Browse other questions tagged or ask your own question.