5
\$\begingroup\$

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?

\$\endgroup\$
4
  • 2
    \$\begingroup\$ A "Mux" selects one of many input ports for each output port. Dual Channel Memory is an example that doubles bandwidth using 2 channels for 64bit RAM to make 128bit bus faster. But the ALU computes all your program jumps math in single, double or any precision. It is also used in some ECC circuits. \$\endgroup\$ – Tony Stewart EE75 Jul 13 '12 at 13:28
  • 2
    \$\begingroup\$ While everyone has given good answers, let me add something important: The symbols for a MUX and an ALU are almost identical and easily mixed up. The ALU symbol has a little triangle piece removed between the 2 inputs, while the mux symbol is a simple quadrilateral. While their functions are very different, I can see how you could mistake one for the other. \$\endgroup\$ – user3624 Jul 13 '12 at 14:01
  • 1
    \$\begingroup\$ @David - Yes, I was tempted to explain it as the "upside down trousers" and the "boat", but I think I'll keep that for my lecture for 1st graders :-) \$\endgroup\$ – stevenvh Jul 13 '12 at 14:08
  • \$\begingroup\$ @stevenvh Thank you I'm glad you mentioned the mnemonics "upside down trousers" and the "boat" it's very pedagocial. \$\endgroup\$ – Niklas R. Jul 29 '12 at 8:21
12
\$\begingroup\$

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.

enter image description here

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ @Nick - You're welcome, glad to be of help. Thanks for the accept. \$\endgroup\$ – stevenvh Jul 29 '12 at 7:54
8
\$\begingroup\$

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.

enter image description here

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.

\$\endgroup\$
3
  • \$\begingroup\$ +1 for clearly pointing out that a mux is usually a very small piece of a much larger ALU. I wish I could give you another +1 for pointing out that an ALU is performing all math operations in parallel, and the mux selects the operation that was requested by the instruction. \$\endgroup\$ – ajs410 Jul 13 '12 at 22:24
  • \$\begingroup\$ Very interesting. Thanks a lot for the information. I also found VHDL code for an ALU in my digital logic book which helped me unerstand that it is the ALU that makes the CPU understand machine code(?) \$\endgroup\$ – Niklas R. Jul 29 '12 at 19:40
  • \$\begingroup\$ @NickRosencrantz most of the machine code (i.e. instruction bits) are used to control elements of the data path in the various pipelined stages - the ALU ends up doing the primitive mathematical operations dictated by the instructions \$\endgroup\$ – vicatcu Jul 30 '12 at 1:52
6
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's an interesting question if there are any practical ALUs out there which cannot function as multiplexers. At first one wouldn't think so, but then there are some really unique architectures. \$\endgroup\$ – Chris Stratton Jul 13 '12 at 14:28
  • \$\begingroup\$ @ChrisStratton AFter doing some more research what is what here I'm beginning to think that an ALU can be disabled to work like a MUX so an ALU could be the baseclass for a MUX and not the other way round. Thank you for the comment (+1). \$\endgroup\$ – Niklas R. Jul 29 '12 at 19:44
4
\$\begingroup\$

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.

ALU

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the answer. I'm thinking the relationship could be thought of the other way round, that a MUX is like an ALU which has some of the functions disabled. \$\endgroup\$ – Niklas R. Jul 29 '12 at 19:41
1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the answer. The book I'm using is Digital Logic with VHDL Design and your answers help me understand the text. Now the other 2 things I must study more are Karnaugh maps and 4-LUT which I don't understand completely. Thanks again for the help. \$\endgroup\$ – Niklas R. Jul 29 '12 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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