I am a little confused about the role of XNOR operation when we have more that two inputs. After simulation, I realized that when we use multiple two inputs XNOR gates, the resulted output is 1 if there is an even number of 0 at the inputs. I searched on the internet to confirm this but I did not find anything. So my question is: Is my interpretation of XNOR operation true or false?
-
Draw the truth table for 2 XNORs. – StainlessSteelRat Jan 01 '21 at 11:23
-
1Note that the function of XOR/XNOR gates with more than 2 inputs is not well defined. See https://electronics.stackexchange.com/questions/93713/how-is-an-xor-with-more-than-2-inputs-supposed-to-work?rq=1 – Elliot Alderson Jan 01 '21 at 14:41
2 Answers
I’ve never heard of XOR or XNOR being applied to anything but two inputs. Most logically you might think that the output should be true (or false) when exactly one input is true. It’s difficult to think of an example of when you might want to test for having an even number of true inputs.

- 6,686
- 1
- 8
- 12
-
There are many examples for algorithms using multiple inputs to a XOR/XNOR gate. Simplest one is parity generation. – Justme Jan 01 '21 at 11:39
-
1@Justme Frog is right about this. XOR/XNOR as a **binary** operator is well defined. For more than two operands it is not. See https://electronics.stackexchange.com/questions/93713/how-is-an-xor-with-more-than-2-inputs-supposed-to-work?rq=1 – Elliot Alderson Jan 01 '21 at 14:41
The NOT part of an XNOR gate can be moved from the output to either of the inputs without changing the function of the gate.
XOR (Not Q) - a.k.a XNOR
| A | B |!Q |
+---+---+---+
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
XOR (Not A) - a.k.a XNOR
|!A | B | Q |
+---+---+---+
| 1 | 0 | 0 |
| 1 | 1 | 1 |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
XOR (Not B) - a.k.a XNOR
| A |!B | Q |
+---+---+---+
| 0 | 1 | 0 |
| 0 | 0 | 1 |
| 1 | 1 | 1 |
| 1 | 0 | 0 |
If you start moving them further and further down the chain, you should see that they start to cancel out with each other. The first two gates cancel to become a pair of XOR gates chained together, as do the second pair. So essentially you've built a 5-input XOR gate.
More generally, for it to be considered an N-input XNOR gate, or even number of 1's detector, you need to construct it from one XNOR gate, and N-2 XOR gates. Essentially you need to result in an odd number of NOTs in the circuit.
If you want to make an even number of 0's detector, you will need to invert all the inputs. You can of course propagate those NOT gates through, at which point you will find that for a even number of bits in your input, the circuit is the same as for an even number of 1's detector. For an odd number of input bits, you want the final gate to be an XOR not an XNOR.

- 63,168
- 3
- 139
- 196