Help from smart electrical/computer engineer people.
Go to solution
Solved by Dash Lambda,
Looking at question #1:
- -B: This depends on your representation. You're most likely using two's complement, for which this operation consists of performing a bitwise NOT on B then adding 1.
- A-B: You negate B then add it to A.
- A+B: This consists of just adders.
- A XOR B: This one also just consists of adders. A 1-bit adder is really just an XOR gate with carry bits, so you just disconnect the carries.
Now, there are two ways you could build this ALU: Build a dedicated circuit for each operation then MUX all the outputs together, or condense it all into one block of adders and MUX the inputs. The first way makes me angry, so let's see how you can rearrange things in the second one...
- Saying -B is the same as saying 0-B, and XOR is adding without the carries, so you can rewrite your operations as {0-B, A-B, A+B, A+B (without carry)}. All four can be done with a single block of adders! You just need to change the inputs for the first three and disable carry for the last one.
- The "A" input is 0 for the first one and A for the other three. So all you need to do is MUX A and a 0 signal together. The MUX chooses 0 for 00 and A for 01, 10, 11, so you can use an OR gate for the select bit.
- The "B" input is -B for 00, 01 and B for 10, 11. So you can MUX together a B and negated B, select bit is the high-order control bit, and when it's negated B you add a carry-in on the top adder (which'll be A+(NOT B)+1 = A-B).
- At this point, we've got -B, A-B, and A+B. We just need XOR, which is, as I said, just A+B with the carry disabled. Both 10 and 11 are A+B at the moment, so all you have to do is stick an AND gate between the two adders and a NAND gate on the control input, then you've got XOR!
- The Result and Carry_out outputs are straightforward, and for the Zero output just NOR the result bits together.
Here's what that looks like in Logisim. I used 2-bit wide inputs, MUX's, and a 2-bit output for Result to clean it up:

As for #2 (I'll be less explicit here):
- A+B: Same as before.
- A-B: Same as before.
- B-A: This'll just add some MUXing.
- A AND B: The carry out on an adder without a carry in is the AND of its inputs.
Implementation:
- You're MUXing on the output now, too, since you have one output coming from the adder sums and one coming from the carry outs.
- You're connecting/disconnecting both carry ins now.
- For the three operations where the first carry in is connected, the carry bit is the NOR of the control bits.
- Both A and B each have a MUX to NOT them, and the select bit for each one should be the AND of one control bit and the signal that connects the carries.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now