Electronic – Does an ALU always do add and sub, but only returns one of the results

8085alumultiplexer

Pretty simple question. Does an ALU internally always do multiple operations like add, sub, div, mul, … and you simply have to specify which result you want to return? I was told that it does that, but I wasn't able to find proof of that being correct. Though I found some graphics containing a multiplexer which from my understanding has basically one output and multiple inputs and by setting some special inputs you can pipe on input to the output. So that might be it, but I don't know enough about that to fully understand it.

I'm specifically wondering about the 8085 architecture's ALU in case it is special, but I'd also like to know about other ALUs if there are different ones.

Best Answer

Look up the age of the 8085. It dates from the era when every part of a circuit was hand optimised, and hand layout with tape and razor blade was still common (though likely Intel was using CAD systems). So it would have been designed to aggressively minimize the number of gates used. And as Tom says, you can add and subtract using the same circuit with a little care - so I think that gives you your answer.

From GBulmer's comment:

Can you see a way to produce multiple results (for example add and subtract) simultaneously, and select the correct answer with the fewer gates (or transistors) than logic producing only one result?

Personally, I can't. If you produce both answers, you need additional logic in the form of multiplexers to select the one you want.

Now I'm not going to run the experiment, but I suspect that if you write an ALU in VHDL, which follows this approach, a modern synthesis tool will spend a very long time (several seconds) and optimise it down to something close to the hand-optimised version.

To test this hypothesis, generate A+B, A-B, and a 2:1 multiplexer as separate modules, synthesise them separately and note resources. Then roll them up into a single design and re-run synthesis (you may need to enable optimisations, "optimise for area" and "flatten hierarchy"). The latter will be smaller : how close it is to a hand-minimised version I don't know : the challenge is set if anyone wants to add another answer!