Maker Pro
Maker Pro

electronic schedule of a 4 bits adder

Rack

Dec 3, 2016
3
Joined
Dec 3, 2016
Messages
3
Hi,
I'd like to make a diagram of a 4 bits adder, i thought it would be best to begin by working out the truth table, i first calculated the highest number i can get with 4 bits, 1111 that is 15 as a decimal number, so should my truth table be 16 * 16 lines based? I mean, if the two numbers i add up can take the value 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, or F, should i write in the truth table the 256 cases, (0,0) (0,1) (0,2) ... (F,E) (F,F) ?
 

dorke

Jun 20, 2015
2,342
Joined
Jun 20, 2015
Messages
2,342
Welcome to EP.
You are writing under "Electronic projects", does it mean you need to implement the circuit in the smallest, cheapest, easiest way?
If so, you can use the 74XXX283 IC for that.

If however your purpose is learning:

1. You could use the "head in the wall" approach of a truth table with 8 bit inputs (9 with carry in).
2. The approach that most designer take is using a 2 bit full adder as a building block (the 74XXX283 as well).
3. Next you can think on the concept of "carry look ahead".
 
Last edited by a moderator:

AnalogKid

Jun 10, 2015
2,884
Joined
Jun 10, 2015
Messages
2,884
Addition is commutative: 2 + 5 is the same as 5 + 2, so only one of those two cases needs to be in the table. When you eliminate all of the other "duplicates" from the 256-length table, there are only 32 left.

Another way to figure this is that 16 + 16 = 32, so that is the maximum number of unique entries in the table.

ak
 

Rack

Dec 3, 2016
3
Joined
Dec 3, 2016
Messages
3
dorke,

"If however your purpose is learning", well that's the point, i don't want my project to be too easy to realize, i approach it by finding the different blocks i have to combine, then i focus on the components of each block, you said that a usual apporoach is to use a 2 bits full adder, it does ring a bell but i was actually told to use several 1 bit adders and combine it, as regards to the carry look ahead adders i'll look into it.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
i was actually told to use several 1 bit adders and combine i
That's probably a misunderstanding and both of you are talking about the same function: A 1 bit adder actually adds 2* 1 bit so you could call it a 2 bit adder.
Assume you have two numbers X and Y, represented as in the binary system as X3X2X1X0 and Y3Y2Y1Y0 wheer each Xi or Yi can be either 0 or 1 (e.g 1001, 0011 etc). You want to add these numbers to a result Z = Z4,Z3Z2Z1Z0 (note that Z has one more digit than X and Y as the sum is longer than the summands).
A very basic way of tackling the issue is by starting with the least significant bits: Z0+C0 = X0+Y0 where C0 is the overflow from the addition of X0 and Y0 (C for 'carry').
For the next digit you add X1+Y1 and you'll have to take into account the overflow from the lower digit which is C0.
The result is Z1+C1=X1+Y1+C0.
The functional element required is a 1 bit 'full adder', 4 of them to create a 4 bit full adder.
The 74xx283 (dorke's post #2) is an integreted version of a 4 bit full adder. You can easily build your own full adder from a handful of AND and EXOR gates. Read more here.

as regards to the carry look ahead adders i'll look into it.
The type of adder describes above is called 'carry ripple' adder as the carry ripples from the LSB to the MSB. This takes time and subsequently this type of adder is slow.
'Carry look ahead' adders compute the sum in the same way, but the carry signal is not rippled from LSB to MSB. Instead internal carry signals for each bit are computed in advance (look ahead) for all stages (bits) of the sum and used to compute the individual bits of the sum. Since the carries are all computed simultaneosly, there is no need to wait for computing results from previous stages and the carry look ahead adder is faste - at the cost of more gates and higher energy consumption.
 

Rack

Dec 3, 2016
3
Joined
Dec 3, 2016
Messages
3
AnalogKid,

i see what you mean, by the way i've been thinking about it recently, but i don't understand why you're saying that only 32 cases remain, overall, i found 256 ordered pairs, and 120 unordered pairs because the cardinality of a set that contains the unordered pairs of a 16 based set is about 16*15/2=120
 

dorke

Jun 20, 2015
2,342
Joined
Jun 20, 2015
Messages
2,342
Like @Harald Kapp noted we are talking about the same thing and I probably should have said "1 bit".

In the traditional learning of adders there is another step:
Creating a 1 bit Half adder.
From that you create a 1 bit full adder.
And then use it to create n -bits adders.
This link can be of help.

Another issue would be how to create a 4 bit subtractor.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Only partly different, as a-b = a+ (-b) so the challenge is in creating -b from b.
Which is the complement of B and a forced carry in to the low bit. (for two's complement arithmetic)

Bob
 
Top