Search code examples
booleansignal-processingdigital-logic

How do I use 2-input XOR and XNOR gates to create a circuit that detects whether an even number of inputs a, b, c, d is 1?


I am a bit confused as to how to solve this problem. I have put the problem into the following Boolean equation:

F = abc'd' + ab'cd' + ab'c'd + a'bcd' + a'bc'd + a'b'cd + abcd

I also know that in terms of two inputs, a and b, XOR and XNOR would be

XOR: a'b + ab'

XNOR: ab + a'b'

How do I turn this into a circuit using only 2-input XOR and XNOR gates? Any pointers in the right direction would be great. I'm completely stuck. Thanks!!


Solution

  • If zero is accepted as even number then it is simple.

    A XOR gate will be zero if there is an even number of ones, in this case 0 or 2. If there is one, it will be 1. Split the inputs into two groups and XOR respectively. Now you know if the groups have even or odd number of ones. XNOR the results and you will know the whole result.

    (A XOR B) XNOR (C XOR D)
    

    Proof:

    • If A and B have even number of ones, xor is 0. Same for C and D. XNOR for 0 and 0 is 1.
    • If A and B have odd number of ones, XOR is one. C and D also need odd number then. XNOR for 1 and 1 is 1.
    • If one has odd and the other even number of ones the result is 0 and 1 and their XNOR is 0.

    If zero is not even for some reason this won't work but it has always been for me in logic.