# Help with making Full Adder using 2 4-to-1 muxes

Discussion in 'Homework Help' started by mikez, Jan 21, 2013.

1. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Hi all,
I am currently working on an 8-bit sign changer for the Basys2 board. Essentially I will input an 8-bit number using the 8 switches on the board and using a push button will be able to select between the number and its 2's complement. I have my truth table set up currently for my Cin, A, B, Cout, and Sum bits.

For my FA I am only allowed to us 2 4-to-1 muxes, 1 inverter, and GND and VCC as necessary. What I have going so far is that I would have the two muxes within my symbol both having the same signal control bits, but one of the enables will be connected to my button switch. When BTN0 = 0, signal will be inverted to send output from the first mux, when BTN0 = 1, enable for Mux1 will be 0 and signal for Mux2 will = 1 so that it will send its output. I am just confused on how to start up the wiring and what not for my muxes to be able to accomplish this. Any advice would be greatly appreciated.

2. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
I think we are going to need to see your truth tables and proposed schematic in order to comment on your layout.

Also, you are, probably, going to need to debounce your button inputs...

3. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Sorry, I should have known to show my truth table.

Code ( (Unknown Language)):
1.
2. Cin   A   B   Cout     S
3. 0     0   0      0     0
4. 0     0   1      0     1
5. 0     1   0      0     1
6. 0     1   1      1     0
7. 1     0   0      0     1
8. 1     0   1      1     0
9. 1     1   0      1     0
10. 1     1   1      1     1
11.
here is my proposed schematic - sorry for it being crudely drawn.
Code ( (Unknown Language)):
1.  http://i.imgur.com/KJAGNyq.png
My enable would be tied into the button and would essentially be a 2-to-1 mux if you will that will select between which mux sends the output. From reading another thread on the forums here I saw that I would need to connect my Cin to port 00 and NOT Cin to port 01. Am I right in my readings?

4. ### WBahn Moderator

Mar 31, 2012
20,716
5,914

When you say a 4-to-1 mux, that means that you have four 1-bit signals and those are multiplexed to a single 1-bit output under the control of a 2-bit select (or control) input. Likewise, in inverter as a 1-bit input and a 1-bit output. Are these the components you have to work with? Or are your multiplexers multibit in width? If so, then you should describe them as 8-bit 4:1 MUXes. What about the inverter? Is it a simple inverter, or a multibit wide component, as well?

You say that you will have the same signal control bits going to both muxes. Okay, but then you never say where these signals are coming from. Your description only talks about a single input, namely the pushbutton, and you say that you are going to connect it only to one of the enables (which implies that your MUXes have an output enable input, which not all MUXes have and should have been included in the description of your available parts). You description then sounds like the signal for both output enables will come from push button, with one of them being inverted.

It would help if you could post a sketch of what you currently have in mind. Also, describe your thoughts on what you need to accomplish, even if you don't know quite how to accomplish it. Get as detailed as you can (i.e., as close to the bit/logic level as possible).

Is the ONLY thing that your circuit is supposed to do is produce either the input or its 2's complement?

5. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Sorry I will try to be as clear and concise as possible:

My first task is to create a "sign changer" that will take input from 8 switches - each switch will be used to construct an 8 bit number going from MSB to LSB. The will be designated as the sign. For if I put in 0000 0010 and button = 0, then my output will be 02 on the seven segment displays. If my input is 0000 0010, but the button = 1 - within the sign changer it will need to then convert it to 2's complement and output 1111 1110 or FE to the displays.

Right now I am working on the Full Adder portion of my circuit. Sign changer will be made up of 8 Full Adders. But when constructing my Full Adders I am only allowed to use the following items to construct the Full Adder: only use TWO 4-to-1 muxes with an enable, and ONE inverter.

Here is what I have in mind - http://i.imgur.com/KJAGNyq.png

But I am thinking that I am going to scrap that idea as I just read some more information that may be leading me to change my design.

6. ### WBahn Moderator

Mar 31, 2012
20,716
5,914
Okay, I have a better grasp of what you are trying to do (reading between the lines, a bit). Correct me if I am wrong: You can use multiple Full Adders, but EACH full adder must be made using nothing but two 4:1 MUXes (1-bit wide) and a simple inverter.

So start from your signal interface. Your FA has three inputs (A, B, Cin) and you have two outputs (S, Cout). Your available components offer you a lot of inputs, namely nine, but only three outputs. Since both outputs are always active, if you only enable one of the MUXes at any given time, then you have to physically tie those two outputs together to provide one of your two outputs and that means you have to use the output of the inverter as your other output. But wait! You are already planning to use the inverter to choose which MUX is enable, meaning that you don't have enough outputs to produce the two outputs that your FA needs. Hence, your approach has a fundamental flaw.

Take a step back and think about how you would use a 4:1 MUX to implement any desired 2-input truth table.

7. ### WBahn Moderator

Mar 31, 2012
20,716
5,914
Our posts are crossing, but that's fine. Just bare it in mind.

8. ### WBahn Moderator

Mar 31, 2012
20,716
5,914
Once you figure out how to use a 4:1 MUX (without an Output Enable input) to implement any 2-input logic function, you need to figure out how to use an inverter in order to use a 4:1 MUX to implement any 3-input logic function (again, without an Output Enable input).

Once you have that figured out, then you will see that implementing a FA is trivial (and you do not need the Output Enable inputs at all - you can just tie them so as to enable the outputs).

9. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
So, to point you in the right direction, what are each of the outputs dependent on? Are they dependent of each other? If so, how?

10. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Thanks for the input WBahn, I have come up with another schematic - yet again this one is crudely drawn. I have taken a different approach as I saw the error that you pointed out - as well as reading some other information in another thread. Mind taking a look at this schematic and seeing if I am on the right track or getting closer to my desired goal?

http://i.imgur.com/bFM5T4m.png

Thanks.

I should add in that I wasnt paying attention to the way I had my previous truth table ordered - in my latest schematic A is my MSB and C is my LSB.

11. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
What is the truth table for this schematic? Draw it out. If it matches your initial truth table, then you are done!

12. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Code ( (Unknown Language)):
1.
2. A    B    C   Cout     S
3. 0     0   0      0     0
4. 0     0   1      0     1
5. 0     1   0      0     1
6. 0     1   1      1     0
7. 1     0   0      0     1
8. 1     0   1      1     0
9. 1     1   0      1     0
10. 1     1   1      1     1
11.
That would be it. I just did not label it according to the exact variable names as my previous table. I know that is a very bad habit that I need to get out of.

13. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Good!
I think it's important to note that you could use any of the variables as the input to the muxes. This would require you to design the circuit differently, but it would have the same function.

This is another reason why signal names are so important. It may be clear in one implementation, but there are any number of other implementations that can obscure which signal is intended....

14. ### mikez Thread Starter Member

Jan 21, 2013
47
0
I see. Thank you Tshuck and WBahn for both of your guys inputs.

15. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Glad to help, provided you are willing to provide the right output
(I couldn't resist...)

16. ### WBahn Moderator

Mar 31, 2012
20,716
5,914
You got it!

Note that there is no MSB or LSB for the inputs to a full adder -- the inputs all have the same weight and, hence, significance. You can freely interchange them. In fact, that is one of the sanity checks you should look for. In this case, it means that each MUX's 01 and 10 inputs should be the same. You could also send Cin to one of the control inputs and one of the normal inputs to the data inputs, but that makes things needlessly confusing.

A good way to see, and document, a design like this is along the lines of the following truth table.

Code ( (Unknown Language)):
1.
2.    | Ci=0 | Ci=1
3. AB | Co S | Co S
4. 00 | 0  0 | 0  1
5. 01 | 0  1 | 1  0
6. 10 | 0  1 | 1  0
7. 11 | 1  0 | 1  1
8.
NOTE: I used Ci and Co just to keep the example table a bit cleaner from a spacing standpoint. Your actual table should use the exact signal names as your circuit diagram and whatever other work or documentation is associated with the problem.

17. ### mikez Thread Starter Member

Jan 21, 2013
47
0
Ohm you! (Sorry I couldn't resist either)

Now that I have been able to complete this Full Adder I am now left with the task of stringing them together to form the 8-bit full adder. Switch0 - Switch7 each toggle the corresponding bit with Switch0 being the LSB and Switch7 being the MSB. How would I handle connecting the switches to work with my 8-bit Full Adder I have just assembled?

I know how to handle the changing to 2's complement. I am just a bit shaky on which switches would be connected to the A, B, and Cin.

18. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
Let's take a look at this from the basics. Let's say you have two four-bit, binary numbers: 0010 and 0110.

$\stackrel{\ \ 0010_{2}}{\underline{+ 0110_{2}}}$

How do you add these numbers?

19. ### WBahn Moderator

Mar 31, 2012
20,716
5,914
First, draw a schematic in which you have the following signals: A (the 8-bit input), N (the signal that is HI if you want to negate the input, so it comes from your pushbutton) and Y (the 8-bit output). You have available an 8-bit adder and other 2-input logic gates (what are your constraints at this level?). Hint, you can do it with your FA and eight XOR gates.

Note that, because your top level circuit has no B input, you can actually implement the whole thing with just a slightly modified FA circuit (of course, it would no longer be an FA circuit, but that's fine). I wonder if that would be worth some extra credit for you.

20. ### mikez Thread Starter Member

Jan 21, 2013
47
0
I would look at each bit position and add them up and carry over if it is necessary. If I did this right the answer should be: 8.