# Writing down logic of a circuit

I have this circuit :

I'm trying to write down the logic of every output (W,X,Y,Z), to get a truth table out of it :

W = NOT (A OR B)
X = NOT A AND B
Y = A AND NOT B
Z = A AND B


But when compares to the source, my truth table is wrong, so I know that my logics are all wrong.

I always start from the right to left everytime I want to understand a logic circuit, for example, in this case, output W is the output of an AND gate between two NOT parameters W = NOT X AND NOT Y, but where do "X" and "Y" in this case come from, obviously not A and B? Look at the logic circuit, I felt like I was lost in a maze! Any suggestions, or hints to help me to understand this kind of logic circuits easier is greatly appreciated!

If you trace through and label the inputs of each AND gate, it makes thing clearer:

W = (NOT B) AND (NOT A), same as NOT (B OR A) by De Morgan
X = (NOT B) AND A
Y = B AND (NOT A)
Z = B AND A

• Ah, So B is on top of A, I thought vice-versa this whole time? How do you know B is on top? Oct 15 '14 at 9:15
• You just have to trace back to the inputs on the left. I labeled the A lines red and the B lines green to make things more obvious. It turns out each of the AND gates has either B or NOT B on the top input, and A or NOT A on the bottom input. Your original table was actually correct except for getting A and B backwards. Oct 15 '14 at 9:24

the output of W is NOT A AND NOT B instead of NOT A OR NOT B

the output of X is NOT B AND A instead of NOT A AND B

the output of Y is NOT A AND B instead of NOT B AND A

maybe the difference of the output of W will solve your problem

• I'm right on A : Not (A or B) (De Morgan's law) Oct 15 '14 at 7:49
• For X : how can you determine that the first out put Not X is B instead of A ? Oct 15 '14 at 7:50
• I'm not that familiar with all the laws anymore. Where ther is a dot on the wires, means that there is a connection of atleast 3 wires.
– T J
Oct 15 '14 at 8:04

Since the gates are positive true ANDs, then for their outputs to go high, both gate inputs must be high.

The only way to satisfy that condition for W to be true, since it has inverters on both of its inputs, is to drive the inputs to the inverters low, and that can be done by driving both A and B low.

To drive X high, then, A must be high, and B must be low in order to drive the output of the inverter high.

For Y, A must be driven low and B must be driven high since the inverter is on A.

For Z, neither of the gate's inputs is inverted, so when A and B are both high, Z will go high.

Your truth table, then, looks like this:

     A   B    W   X   Y   Z
-----------------------
0   0    1   0   0   0
0   1    0   0   1   0
1   0    0   1   0   0
1   1    0   0   0   1


Just as an aside, note that since you have A and B, and since their complements are being generated by the pair of inverters driving the top AND, you have all of the possible input permutations and the circuit could be redrawn to eliminate the other inverters and still keep the same functionality, like this:

Output Z is $A.B$ as stated but output Y is stated incorrectly: -

Output Y is $\bar A.B$ and not $A.\bar B$

Output X is $A.\bar B$ and not $\bar A.B$

Output W is $\bar A.\bar B$

• For X : how can you determine that the first out put Not X is Not B instead of Not A ? Oct 15 '14 at 8:37
• @hoangnnm the X AND gate receives A and inverted B as inputs - I don't see what the difficulty is. Oct 15 '14 at 10:21