Electronic – Designing a simple ALU

adderalucalculatormultiplier

I need to design an ALU with two 8-bit inputs A and B and control inputs x, y, and z that supports the following operations:

x  y  z  |  operation

0  0  0  |  S = A-B
0  0  1  |  S = A+B
0  1  0  |  S = A*8
0  1  1  |  S = A/8
1  0  0  | S = A NAND B (bitwise)
1  0  1  | S = A XOR B (bitwise)
1  1  0  | s = reverse the bits of A
1  1  1  | S = NOT A (bitwise)

This is supposed to be done with an 8-bit adder and an arithmetic-logic extender. Reading through my textbook, I see that the purpose of an AL-extender is to alter the input bits so that an adder, rather than a lot of extra components, can be used to do everything (or at least that's what I understand from it). For example, the AL-extender could put the bits in two's complement so that the adder does a subtraction. Likewise, for the bitwise logical operations, the bits could be altered appropriately and one of the adder inputs could just be zero so that the result comes through properly.

But what exactly do I do about multiplication? My book is very vague, so I'm not sure if an AL-extender would require me to do something clever to make the adder do the work (just add 8 times in my case? …ha ha), or if I can just throw a multiplier in there. I'll have to read up on division, but I bet it's similar to multiplication.

Well, anyway, the bottom line is still, what is an AL-extender "allowed" to be/able to have in it? Is its only purpose to alter input so that it can be fed to an adder?

*EDIT: Well, it is multiplication/division by 8, so this can be easily performed with shifting left or right by 3. Would I still have a real/proper AL-extender if I added some shifters in there? (Maybe I'm overthinking this as a complete beginner…)

Best Answer

The simplest approach would be to decode the x y z inputs into eight lines. Then from these, you implement logic which drives chip select lines to enable the appropriate unit which handles the inputs, as well as any transformations that are needed so that the unit performs the correct operation.

I don't think you can use an adder for your logic operations because the adder carries (unless it has some input which disables the behavior of carry propagation). But you can have a single unit to do all the logic.

Maybe there is a reason why they call these ALU's, with a separate A and L. :)

Multiplication by 8 just means driving zeros on the lowest three input lines, ignoring the upper three lines, and mapping line 0 to line 3, 1 to 4, and so on. It's like a railway switch.