Sunday, June 19, 2011

Domino Calculator - The Half Adder

The half adder is a basic logic circuit that does addition between two binary values.  Before we go into the logic to do addition lets shortly go into binary addition.  Binary addition works exactly base 10 (regular) addition just that the base is 2 instead of 10.  That means instead of 0-9 as digits there is only 0 and 1.  One Hundred and One in base 10 can be expressed by a sum of the following 1*10^2 + 1*10 + 1.  Similarly seven can be represented by 1*2^2 + 1*2 + 1 = 7  or 111(base 2).
Addition in base 10 often has carries such as 9+2 = 11 or 1 with carry of 1*10 [10 is the base].  Binary addition does the same thing such as 1 + 1 = 10 (base 2) or 0 with a carry of 1*2 [2 is the base].

So to create binary addition lets make a truth table. For the truth table lets add bit A with bit B, S is the sum and C is the carry.  Bits A and B both have two possible values 0 and 1, so there is a total of 4 possible combinations to add A and B together.

ABSC
0000
0110
1010
1101


By looking at the truth table we can observer that the sum of two bits is the exclusive-or logical operation, and the carry is a logical  AND operation.  This brings us to the logical circuit of what is called a half adder:

Using dominoes I had to find a way to "set" two branches of falling dominoes, where each branch corresponds to a bit and then perform a parallel exclusive-or (XOR) operation and a logical AND.
This is a screenshot of the domino half adder build with around 100 dominoes.  A video is after the explanation.



The red domino is the bit indicator. If it is missing then that bit is a zero.  If present that bit is a 1, and the branch will fall.  The blue domino to the very left starts the chain reaction.  The black dominoes represent energy to be used in logic, its similar to a voltage line.  The yellow block is a bridge so that the B branch can cross over the S (A XOR B) branch.
The XOR operation is pretty simple if both A and B are triggered then they meet together.  If only one branch is triggered then the blocks will fall around and trigger one of the branches leading to the S output.

The AND operation is more complicated.  If A is set then a domino is knocked away from the branch at z.  since z will always be falling because it is from the main power line then the progression of branch at z will be stopped.  If bit A is not set then no domino is knocked away from branch z and it continues to fall.  This is a logical NOT operation.  Because z is always set it the action of stopping the branch or letting it continue will be the logical compliment to the logical value of A.

Looking at the truth table of A AND B will show what should be done next:

AB~A~BA AND B
00110
01100
10010
11001


As can be observed by looking at the truth table with ~A is 1 the value of A AND B does not depend on the value of B.  So by taking out the B branch when ~A=1 (A = 0), it is guaranteed that the logical value of the B branch is 0, which is the correct output of A AND B when A=0.  Also by looking at the truth table it can be seen that when the value of ~A is 0 the output of A AND B is dependent only on the logical value of B.  So when bit A is set ~A becomes a logical 0 and does not knock down anything allowing the output of A AND B becomes B when A=1.

So after all that, here is the video of a Blender simulation...

No comments:

Post a Comment