Wednesday, January 28, 2015

Truth Table to Equation

Note:
This post will not only cover how to convert Truth Tables to Equations, but it will also cover what a truth table is, and how to use it.

So, what is a truth table.  If that is what you start with, and you do not understand what it means, then it is practically useless to you.  A Truth Table is a chart that lists all possible combinations of inputs, and the output of those combinations under a set of gates.  Here is an example of a Truth Table from the Majority vote project.


P
V
S
T
Decision
Row #
0
0
0
0
0
1
0
0
0
1
0
2
0
0
1
0
0
3
0
0
1
1
0
4
0
1
0
0
0
5
0
1
0
1
0
6
0
1
1
0
0
7
0
1
1
1
1
8
1
0
0
0
0
9
1
0
0
1
1
10
1
0
1
0
1
11
1
0
1
1
1
12
1
1
0
0
1
13
1
1
0
1
1
14
1
1
1
0
1
15
1
1
1
1
1
16


Note: the column labeled "row #" is simply there for reference and is not necessary in a Truth Table.
The columns labeled "P, V, S, and T are the inputs for this particular Truth Table.  They represent President, Vice President, Secretary and Treasurer.  each row in these columns is actually just counting up from zero to fifteen in binary.  To briefly go over how to set up the Truth Table we will start with the patterns of these four columns.   For any Truth Table, to figure out how many rows there are, we use the formula 2^(n)  where n= the number of inputs.  With four inputs, we know that there will be sixteen rows.  Then, with the right-most column, we start with zero and alternate every row.  The second column we alternate every two rows, the third, we alternate every four, and finally, the fourth column alternates every eight rows.  The result of this shows that each row of inputs counts from zero in binary.

The next step is to fill in the decision column, which for the sake of time we will not get into for this example.  Each problem has a different set of outcomes, and in this case, this column has already been filled in to specify the demands of the problem. 

Now we get to how to convert this to an equation.  The first step is to look at, and mark the minterms.  A minterm is any row that resulted in a one or an on.  The way to mark them is to write down the combinations of the inputs.  Take row 8 for example.  This is a minterm because it outputted a one.  So, we write under what circumstances this happened.  The president (P) was a zero.  So we write P' (which denotes "Not P").  All of the others are a one.  So we write all of this as products of each other P'VST.  This is how we annotate this minterm.  For another example, Row 10.  Row ten would look like this; PV'S'T because both V and S we zeros and both P and T were ones.  After you do this with each row that outputted a one, you throw them all together into a Sum-of-Products equation.  This is a sum of products because if any one of these combinations occur, the output will be a one.  So you would combine the products with addition signs that represent OR gates.  All of these letters are "multiplied" together because in equations, AND gates are represented by multiplication.  The final equation for the Truth Table above would be;


P'VST + PV'S'T + PV'ST'+ PV'ST+ PVS'T'+ PVS'T+ PVST'+ PVST
This of course could be simplified using k-mapping or blooean algebra, but this equation will do for now.  If you wanted to breadboard this, you would defiantly want to simplify this, for that saves a bit of money.  

No comments:

Post a Comment