# Why is the inverter need in this ALU?

I'm studying computer architecture and I wonder why the inverter is needed in this ALU?

• How else would you get the inverted value of B? Feb 5 '18 at 5:51
• @IgnacioVazquez-Abrams Now I almost understand. But when is the inverted value of B needed? For what operations? Feb 5 '18 at 5:53
• Inversion, subtraction, etc. Feb 5 '18 at 5:53
• @IgnacioVazquez-Abrams I accept that as an answer. Thanks! Feb 5 '18 at 5:54
• @IgnacioVazquez-Abrams. Not to step on your turf, but you should post your comment as an answer since the OP accepted it. I could do so but it would be a copy-cat version.
– user105652
Feb 5 '18 at 6:22

Inversion of an input is used in some operations, including but not limited to subtraction, XNOR, and of course inversion. It can also simplify some operations when used as an input of an AND or OR gate.

Practically, in the ALU circuit you posted, with only defined function F[2:0] as 000 (A AND B operation), not only inverter is not needed, but also small mux device, adder, zero extender and big mux.

As it is a picture from the learning material, you may guess that this ALU circuit diagram may have some other functions, defined by the value of vector input F[2:0]. For example:

If F[2:0]==001 then ALU outputs A OR B;

If F[2:0]==010 then ALU outputs A+B with no carry bit;

If F[2:0]==100 then ALU outputs A AND (NOT B);

If F[2:0]==101 then ALU outputs A OR (NOT B);

If F[2:0]==110 then ALU outputs A + (NOT B).

Not all operations may have sense without understanding the context ALU is implemented in though. I also do not know the "zero extend" device and its purpose here. Seems device returns True (1) if resulting number is negative, and False (0) if positive, but it does not elaborate on overflow thus output makes no use for further binary arithmetic operations.