Is it Possible 4 input XOR gate ? why ?

Discussion in 'General Electronics Chat' started by Ashik Ghona, Jan 28, 2012.

Thread Status:
Not open for further replies.
  1. Ashik Ghona

    Thread Starter New Member

    Jan 28, 2012
    2
    0
    Is it Possible 4 input XOR gate ? if not then why ?
     
  2. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    Although I've never seen one, if you follow the definition found on Wikipedia:

    "The XOR gate (sometimes EOR gate, or EXOR gate) is a digital logic gate that implements an exclusive or; that is, a true output (1) results if one, and only one, of the inputs to the gate is true (1)."

    then yes, it could have more than one input.

    For a "1" at the output you would then need to have only a single input at "High" level. All inputs at "0" or more than one input at "1" would cause the output to go to "0".

    My first thought was there could not be such a gate because usually you only see 2-input XOR gates, and their inputs need to be at "different" states to give a "1" at the output. That would be a different definition. Multiple inputs XOR gates would be impossible following this definition because the inputs can have only two different states.
     
  3. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    You cannot make a XOR gate with three or more inputs (by the definition).

    However, considering that a XOR gate will change its output if there is a change at one of its input, you can build a logic circuit with a similar behaviour with three or more inputs, by cascading XOR gates. That circuit cannot be considered a XOR gate, though.
     
  4. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    Can you please provide the "definition" you are referring to?

    Maybe we should first find the correct definition. :D
     
  5. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    Sure you can make a 3 input gate because XOR is an associative operation. It is also commutative, but that it not necessarily relevant here. It is called Boolean Algebra for a reason. It satisfies the necessary and sufficient conditions to be called that. The definition is quite precise. For the same reason that three is possible, four or more is also possible. In addition it can be expressed in terms of the operations of inversion, AND, and OR.
     
    Last edited: Jan 29, 2012
  6. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,673
    2,711
    I could be wrong about this, but a multi-input xor gate would provide a high output when an odd number of inputs are high. Basically, an odd parity generator.
     
  7. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    Another one from Wiki:

    The Oxford English Dictionary explains "either ... or" as follows:
    The primary function of either, etc., is to emphasize the indifference of the two (or more) things or courses ... but a secondary function is to emphasize the mutual exclusiveness, = either of the two, but not both. The exclusive-or explicitly states "one or the other, but not neither nor both."

    It's all about finding the right definition for the OPs question... :confused:
     
  8. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    Exactly, but that would not be a XOR gate. If you cascade two or more XOR gates, that's what you get.

    XOR is associative, but the resulting "gate" wouldn't be a XOR. A true 3 input XOR gate would have its output high only if one and only one of its inputs is high.
     
  9. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    You can make a gate with any number of inputs have any output function that you want. By the same logic you could not have a 3-input AND gate or a three input OR gate. Associative binary operations can be combined to make multi input gates. Any other analysis is quite simply wrong.
     
  10. holnis

    Member

    Nov 25, 2011
    50
    4
    The XORs are two-bit operations, So I don't believe there is such a thing as a 4 input XOR function. An XOR function is by definition a 2 bit operation and while it can be performed on multi-bit variables it is still a bit by bit operation and any 4 input bit gate function (with one bit output) will be some logic function other then a true XOR function.
     
  11. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    This argument is wrong. The logical AND is also a 2 bit operation, as is OR, Peirce Arrow, and Sheffer Stroke. Listen carefully and pay attention. ANY associative binary operation can be cascaded in such a way as to produce the same output as a multi input gate. To argue otherwise is just plain wrong. I'm sorry to put such a sharp edge on my comments but mathematics is what it is and not what you think it should be.

    Would you be more convinced by an actual datasheet?

    http://www.nxp.com/documents/data_sheet/74LVC1G386.pdf

    I can hardly wait to hear the weasel words on this one.
     
    Last edited: Jan 29, 2012
  12. 1chance

    Member

    Nov 26, 2011
    42
    184
    From a mathematical perspective, we usually deal with dicotomies. That is, a statement is either true or false, x = 5 or x ≠ 5. But you can expand things into three categories, a tricotomy, (think of a flow chart where x>5, x<5, or x=5). One cannot come up with 4 unique situations. So therefore I think the answer is NO, if I understand the question correctly.
     
  13. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    Why is the output high when all inputs are high? Does that mean it's more like an odd/parity indicator? Where is the OR? I would have expected a HIGH at the ouput when only 1 input is HIGH...
     
  14. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    Don't forget that a XOR is a complex operation, based on ANDs, ORs and NOTs. Associativity doesn't play well with XORs, especially if other operations are involved. I was not careful enough and made mistakes because I did overlook this same aspect, when doing some boolean algebra.

    I ask the same question too. I predicted that cascading two XOR gates would lead to something like this. But why is that called an exclusive OR? Wouldn't that be some kind of misnomer?
     
    Last edited: Jan 29, 2012
  15. Papabravo

    Expert

    Feb 24, 2006
    10,135
    1,786
    Nice try, but the fact of the matter is that:

    A .XOR. B .XOR. C gives the result given in the datasheet precisely because it is an associative binary operator; in the same sense that .AND. is an associative binary operator, and .OR. is an associative binary operator.

    Since we also know that the .XOR. function can also be expressed a Sum of Products we know that the three input expression can also be expressed in that form. The dual of course is that it can also be expressed as a Product of Sums. Now we are no longer talking about the .XOR. function but combinations of .AND. ,.OR., and .NOT. which is functionally complete.

    I doesn't matter what YOU THINK the output of a 3-input XOR should be the mathematics and the datasheet say the you are just plain wrong and that is my last word on the subject. You can keep beating this horse but the mathematics won't change.
     
  16. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    If we are to accept that the following two configurations represent a 3-input XOR function, then the two circuits give identical results and we can say the XOR operator is associative.

    [​IMG]


    The result is an odd-parity generator circuit and also for a 4-input circuit.
     
  17. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,673
    2,711
    So, I was right! :D
     
  18. praondevou

    AAC Fanatic!

    Jul 9, 2011
    2,936
    488
    I'm sure the reason why the OP asked that question is because there is no definition someone put in words for a 4-input XOR gate. The only definition you will find is one for a 2-input XOR gate. I assume for simplification purposes they write that both inputs have to be different or only one input can be HIGH for the output to go HIGH. This is where confusion starts because if you assume the same to be valid for more than 2 inputs then the above diagram and the XOR gate PapaBravo posted wouldn't be XOR gates.

    So in other words, the answer to the OPs question is yes but it is not what one may think and it is not intuitive.... if applying the classical definition of a 2-input XOR gate.
     
  19. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    From Wikipedia:

    http://en.wikipedia.org/wiki/XOR_gate

    More than two inputs

    Strict reading of the definition of exclusive or, or observation of the IEC symbol, raises the question of correct behaviour with additional inputs. If a logic gate were to accept three or more inputs and produce a true output if exactly one of those inputs were true, then it would in effect be a one-hot detector (and indeed this is the case for only two inputs).

    However, it is rarely implemented this way in practice.

    It is most common to regard subsequent inputs as being applied through a cascade of binary exclusive-or operations: the first two signals are fed into an XOR gate, then the output of that gate is fed into a second XOR gate together with the third signal, and so on for any remaining signals.

    The result is a circuit that outputs a 1 when the number of 1s at its inputs is odd, and a 0 when the number of incoming 1s is even. This makes it practically useful as a parity generator or a modulo-2 adder.

    For example, the 74LVC1G386 microchip is advertised as a three-input logic gate, and implements a parity generator.
     
    praondevou likes this.
  20. Dan Syrstad

    New Member

    Sep 11, 2015
    2
    2
    It is indeed possible if your definition of a multi-input XOR is: result is high if exactly one of the inputs is high. For 3 inputs, in boolean algebra, given inputs a, b, and c, and output y (& = AND, ^ = XOR, | = OR):

    y = ((a ^ b) ^ c) ^ (a & b & c)

    This can be expanded to support four inputs:

    y = (((a ^ b) ^ c) ^ d) ^ (a & b & c & d) ^ ((a & b & c) | (b & c & d) | (a & c & d) | (a & b & d))

    and so on. It's provable by running it through a truth table.

    A 3 input XOR as a circuit:
    xor-3input.png
     
Loading...
Thread Status:
Not open for further replies.