I'm studying digital electronics where the components ALU and multiplexer appear. To me the ALU seems like a multiplexer but it's not specifically mentioned that this is the case. Is it so, or why not?
No, it's not a multiplexer. A multiplexer would select one of both inputs, in an ALU both inputs may be used simultaneously, depending on the pending operation.
ALU stands for Arithmetic and Logic Unit, and those are the types of operations it performs.
If the operation calls for a left shift of register R1, then the second input is ignored, but you might as well have "add the content from RAM address 0x1208 to register R1", then both inputs are used. Before the add can be performed the RAM data must be fetched and placed on one of the inputs, and the content of R1 on the other.
All in all an ALU can perform several logical operations, like adding, shifting, clearing, etc. It's a rather complex piece of logic which works on the operands on the inputs and the operation code.
Operations like "clear A" are simple, but "multiply A and B" requires lots of gates.
As others have noted, an ALU's function is to perform (typically either binary or unary) arithmetic and logical operations on input busses. You can break an ALU down into three primary stages along with some control logic that configures those stages.
- Argument Selection: this stage really really is just a Multiplexer for each input that allows for the selection of various inputs for either argument (i.e. RegisterA, RegisterB, MemoryLoad, Pipeline Byassed Value, etc).
- Arithmetic/Logic Computation: this is where all the math gets done in parallel on the selected / routed inputs
- Output selection: this can be thought of as a logically as another multiplexer, but for reasons of fan-in/fan-out is often implemented as a tri-state bus with the various output enables driven by a decoder based on the instruction op-code.
Here's a really high level drawing I whipped up to illustrate this partitioning.
There may be debate about whether the first stage and control logic is really part of the ALU, or if it is rather simply part of the Execution stage of the CPU Pipeline.
To me the ALU seems like a multiplexer ...
An ALU performs many tasks.
A multiplexer essentially performs one task.
An ALU could be given a multiplexer function as one of it's features if desired.
ie a multiplexer's capabilities may be a small subset of an ALU's capabilities.
In a typical implementation, both have two inputs and one output.
But the multiplexer carries out only an either/or selection between the two inputs.
The ALU could do this plus addition, OR, AND, XOR, Add, Subtract, ...
Given a single control input C and an n bit A port (with bits A0, A1, A2 ... An) and an n bit B port a multiplexer can be thought of as implementing.
Mout_x = A_x.C + B_x./C for all x = 0 ...n
"." = logical AND
"+" = logical OR.
No it's not a multiplexer. An ALU is an Arithmetic Logic Unit.
It does what the name suggests, perform various arithmetic and logical operations like add, subtract, multiply, shift, AND, OR, etc.
An ALU performs multiple arithmetic/logic operations depending on the "function" selected.
It's only a mux in the sense that the selected "function" will select the appropriate result to send to the output.
As an example, ADD two numbers, AND two numbers together. Then, the "function" multiplexes either the ADD or AND results to the output.
Incidentally, this is how some ALU inside microprocessors are designed.