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

Thread Starter

mikez

Joined Jan 21, 2013
47
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.
 

tshuck

Joined Oct 18, 2012
3,534
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...
 

Thread Starter

mikez

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

Rich (BB code):
Cin   A   B   Cout     S
0     0   0      0     0
0     0   1      0     1
0     1   0      0     1
0     1   1      1     0
1     0   0      0     1
1     0   1      1     0
1     1   0      1     0
1     1   1      1     1
here is my proposed schematic - sorry for it being crudely drawn.
Rich (BB code):
 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?
 

WBahn

Joined Mar 31, 2012
29,976
Your description is extremely confusing.

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?
 

Thread Starter

mikez

Joined Jan 21, 2013
47
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.
 

WBahn

Joined Mar 31, 2012
29,976
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.
 

WBahn

Joined Mar 31, 2012
29,976
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).
 

tshuck

Joined Oct 18, 2012
3,534
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?
 

Thread Starter

mikez

Joined Jan 21, 2013
47
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.
 

tshuck

Joined Oct 18, 2012
3,534
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.
What is the truth table for this schematic? Draw it out. If it matches your initial truth table, then you are done!
 

Thread Starter

mikez

Joined Jan 21, 2013
47
What is the truth table for this schematic? Draw it out. If it matches your initial truth table, then you are done!
Rich (BB code):
A    B    C   Cout     S
0     0   0      0     0
0     0   1      0     1
0     1   0      0     1
0     1   1      1     0
1     0   0      0     1
1     0   1      1     0
1     1   0      1     0
1     1   1      1     1
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.
 

tshuck

Joined Oct 18, 2012
3,534
Good!
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.
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....
 

WBahn

Joined Mar 31, 2012
29,976
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.
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.

Rich (BB code):
   | Ci=0 | Ci=1
AB | Co S | Co S
00 | 0  0 | 0  1
01 | 0  1 | 1  0
10 | 0  1 | 1  0
11 | 1  0 | 1  1
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.
 

Thread Starter

mikez

Joined Jan 21, 2013
47
Glad to help, provided you are willing to provide the right output
:D(I couldn't resist...)
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.
 

tshuck

Joined Oct 18, 2012
3,534
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.
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?
 

WBahn

Joined Mar 31, 2012
29,976
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.
 

Thread Starter

mikez

Joined Jan 21, 2013
47
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.
 
Top