# Is this an xor gate?

1. Dec 16, 2013

### PsychonautQQ

http://en.wikipedia.org/wiki/XOR_gate
scroll down a little bit on this article and there is a picture labeled "xor gate made out of nands"

Can somebody verify that this wikipedia article is incorrect for me? The truth table I came up with is the exact opposite of an xor. When a and b are both 0 then the output is 1 and when a and b are both 1 the output is 1, but when a is 1 and b is 0 the output is 0.

2. Dec 16, 2013

### K^2

It's a XOR. Easy enough to analyze. Take the last NAND gate with the inversions on inputs from previous NAND gates. So the last NAND becomes an OR gate (by De Morgan's), and the two NANDs before it become ANDs. So now if A AND B, then the input to the two AND gates is zero, and the whole thing is zero. Otherwise, A AND gate is high if A, and B AND is high if B. So the OR gate gets A OR B. So the whole thing reads (A OR B) AND (A NAND B). That's obviously a XOR.

3. Dec 16, 2013

### PsychonautQQ

so as an xor gate, if b is 1 and A is zero the output should be one,.... right?

4. Dec 16, 2013

### K^2

Of course. The states of the four NANDS are going to be: Leftmost, 0 NAND 1 = 1. Top, 0 NAND 1 = 1. Bottom, 1 NAND 1 = 0. Rightmost, 0 NAND 1 = 1. And that's your output.

5. Dec 16, 2013

### cpscdave

Yup

Code (Text):

A B  |  XOR Result
0  0 |  0
0  1 |  1
1  0 |  1
1  1 |  0

6. Dec 16, 2013