im trying to implement the FuallAdder usind two H.A.
when adding the C bit using a H.A. , i conclude that the carry_out
is not important so i want to leave it unwired
but the Hardware simulator is crying that its the carry output
shoul be connected
how can i cause it be unconnected?
You do need to do something with the carry outputs from both half adders to make a correct full adder. Consider adding a=0, b=1 and c=1.
The first half adder produces sum1=1, carry1=0.
The second half adder adds sum1 and c producing sum2=0, carry2=1.
sum2 is the sum output from the full adder. carry1 and carry2 need to be combined in some fashion to produce the full adder's carry output.
It is OK to leave out the connection to an unused output in a part line. For instance the full adder for bit 15 in your Add16 won't have its carry connected so you can write:
FullAdder(a=a, b=b, c=c14, sum=out);
The second half adder adds carry<sub>1</sub> and c producing sum<sub>2</sub>=0, carry<sub>2</sub>=1.
<p> sum<sub>2</sub> is the sum output from the full adder. carry<sub>1</sub> and carry<sub>2</sub> need to be combined in some fashion to produce the full adder's carry output.
I think you made a typo.
Shouldn't you add sum1 and c to get the final sum?
when performing C = A + B + carry_in where A and B are two one-bit inputs and C is a two bit output (C_carry, C_sum) you are just adding three bits together, right.
So consider the possibilities. You use a half-adder to add any two of the bits (let's say A and B).
This produces a two-bit partial result consisting of a sum and a carry. How many possible results are there? Only three! You can't add two bits together and get 11. So we don't have to consider this case at all.
Now you want to add another bit to this result using another half adder.
How would you do it by hand and what are the possibilities?
Thanks for your fast reply. I have to admit that I don't fully understand your explanation, especially this sentence:
In no case what there a Carry from either of these operations but in which we wanted the Cout to be anything other than zero.
Can you reformulate that?
Sure. We need to come up with logic that not only gives us a 1 when we need a 1, but also that does NOT give us a 1 when we need a 0.
If there were times that one of the half-adders produced a carries but that we needed the full-adder to produce a 0, then we couldn't use the Or of the carries from the two half-adders as our carry from the full adder.
So the Cout bit is a 1 whenever there is a Carry from EITHER of the two half-add operations.
If this is the conclusion, shouldn't it be a Xor gate instead of Or?
In this case it doesn't matter.
It comes down to what we need to happen when BOTH half-adders produce a carry. It's a non-issue because it can't ever happen. So we don't care what our full-adder's carry would be in that situation and we can choose either an Or or an Xor. Since the Or is the smaller, faster logic (something that doesn't matter for this course), we would opt for it.