# Truth Table to check if 4-Bit binary numbers are in the set?

I know truth tables are pretty easy but I am just confused with this one. I have this question which says: Question: indicate if a 4-bit unsigned binary number is in the set {1,2,3,5,9,11,13,14} (decimal) or not?

I know there are going to be 4 inputs A,B,C,D and then the output. My question is how am I going to check if the output is going to be true or false for the above question. What should I check in the set {1,2,3,5,9,11,13,14} before writing the output as '1' or '0'?

I hope I made the question clear, I have an exam early morning. Any help would be highly appreciated

• Each of the four bits in the numbers correspond to A,B,C,D. Create a karnaugh map where the output is 1 when the number is in the set and 0 otherwise. Solve to get the logic. As this is homework and possibly exam work, that's all you're getting from me. – Tom Carpenter Dec 16 '15 at 23:48
• Well that flew way over my head to be honest. I have 5 parts of this question, starting from making truth table, SOP expression, Karnaugh map and then circuit for that expression. I know each and every part of this question the only thing that is still unclear to me is how to get the output of the 4 input truth table :/ obviously rest of the parts depends on the output of the truth table, can you please explain a bit in detail? – Muhammad Qureshi Dec 16 '15 at 23:54
• A is the first bit of the numbers, B is the second bit, C is the third bit, D is the fourth bit. List all possible combinations at the input, then convert those from binary to decimal, and see which match your set. – Tom Carpenter Dec 17 '15 at 0:04
• This entirely depends on your implementation technology - if your are plunking down gates (especially in SOP form) use a karnaughgh map. But if you are targeting an FPGA, the ultimate physical implementation of combinatorial logic may already fundamentally be a 4-input LUT, and anything else you do will be converted to those. – Chris Stratton Dec 17 '15 at 1:53

If I understand you correctly then you just need a 5 column table indicating if a number is or isn't in a set? Assuming an output of 1 is true.

Set: {1, 2, 3, 5, 9, 11, 13, 14}
A/8 B/4 C/2 D/1 |   N   In Set
0   0   0   0   |   0   0/false
0   0   0   1   |   1   1/true
0   0   1   0   |   2   1/true
0   0   1   1   |   3   1/true
0   1   0   0   |   4   0/false
0   1   0   1   |   5   1/true
0   1   1   0   |   6   0/false
0   1   1   1   |   7   0/false
1   0   0   0   |   8   0/false
1   0   0   1   |   9   1/true
1   0   1   0   |   10  0/false
1   0   1   1   |   11  1/true
1   1   0   0   |   12  0/false
1   1   0   1   |   13  1/true
1   1   1   0   |   14  1/true
1   1   1   1   |   15  0/false


I'm not as experienced at sleuthing out the logic that drives the last column, but hopefully this will help. Drawing the output as squares of different dimensions can help with visualization of patterns. My thought process usually involves finding an expression that makes some part of the table work without any false negatives (no incorrect trues) and then OR'ing all the parts together.

0 1 1 1 :  0- 3
0 1 0 0 :  4- 7
0 1 0 1 :  8-11
0 1 1 0 : 12-15


The first and second columns stand out here; which correspond to b0001,b0101,b1001,b1101 being true, the first and second bits being irrelevant and third and fourth being constant points you toward those (bXX01)

!C & D
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0


Fixing the first row could be done with C | D; but to capture limit it to only the first row requires negating A and B

!A & !B & ( C | D )
0 1 1 1
0 0 0 0
0 0 0 0
0 0 0 0
OR together the parts.
(!C & D) | (!A & !B & ( C | D ))
0 1 1 1
0 1 0 0
0 1 0 0
0 1 0 0


Close, but 11 and 14 (b1011 and b1110) are the two that are left

- - - -
- - - -
- - 0 1
- - 1 0


Which looks just like an XOR function. B XOR D (when A and C are true).

A & C & (B xor D)
0 0 0 0
0 0 0 0
0 0 0 1
0 0 1 0
OR together the parts
(!C & D) | (!A & !B & ( C | D )) | (A & C & (B xor D))
0 1 1 1
0 1 0 0
0 1 0 1
0 1 1 0