2

I'm from math.stackexchange and I wanted to know the name of an operation on multiple variables. I thgouth what I wanted was the XOR gate, but this is not the case. When I looked on this site I noticed the XOR truth table was this:

\begin{matrix} FFF & 0 \\ FFT & 1 \\ FTF & 1 \\ FTT & 0 \\ TFF & 1 \\ TFT & 0 \\ TTF & 0 \\ TTT & 1 \end{matrix} I would have excpeted, and what I'm after is, this \begin{matrix} FFF & 0 \\ FFT & 1 \\ FTF & 1 \\ FTT & 0 \\ TFF & 1 \\ TFT & 0 \\ TTF & 0 \\ TTT & 0 \end{matrix}

Is there a name for this second table as that is what I would like to use and I would like to stick to convention. Thanks in advance, Ben

Ben Crossley
  • 123
  • 5
  • 1
    In the second table, the three inputs are not commutative. Is that really what you want? – CL. Jun 06 '19 at 07:22
  • Yes, I want it for non-electrical purposes. – Ben Crossley Jun 06 '19 at 07:26
  • What is F and what is T all about? – Andy aka Jun 06 '19 at 07:34
  • @Andyaka True and False. 1 and 0. – Ben Crossley Jun 06 '19 at 07:36
  • I am working with propositions rather than electric gates, so my outputs are true and false. – Ben Crossley Jun 06 '19 at 07:44
  • 3
    Why do you expect 1 xor 1 xor 1 to be 0? – Steve G Jun 06 '19 at 07:45
  • @SteveG I didn't specify A xor B xor C, I am thinking xor(A,B,C). Whether or not that should be thought of as A xor B xor C to me, is a different question. And to be clear, I don't think 1 xor 1 xor 1 should be 0, since (1 xor 1) = 0 and then (0 xor 1) = 1 – Ben Crossley Jun 06 '19 at 08:04
  • 2
    By asking for a name for that truth table, I would hope I'm being clear that I don't think it is called XOR. I have shown that I understand XOR not to be that truth table and that I wanted a name for the second truth table. If one doesn't exist, I will make one up for what I am doing. – Ben Crossley Jun 06 '19 at 08:07
  • 1
    I don't believe it unreasonable to think a three-input XOR would have produced the truth-table the OP wanted... `XOR(A,B)` is true when one, or the other, but not both inputs are true. It wouldn't have been _unreasonable_ to define `XOR(A,B,C)` as true when any _one_ input is true, but not when any two, nor all three are true (_exclusively_ A or B or C but no combination of multiple being true). – TripeHound Jun 06 '19 at 11:42
  • 2
    Possible duplicate of [How is an XOR with more than 2 inputs supposed to work?](https://electronics.stackexchange.com/questions/93713/how-is-an-xor-with-more-than-2-inputs-supposed-to-work) – Elliot Alderson Jun 06 '19 at 11:58
  • @ElliotAlderson I saw that question and it didn't answer my question. – Ben Crossley Jun 06 '19 at 12:07
  • 1
    I does answer your question. Both of the truth tables you give are called an XOR gate, depending on who you ask. So, the real answer is that you can not assume that there is a standard "convention" for the name for **either** function. – Elliot Alderson Jun 06 '19 at 12:15
  • @ElliotAlderson Saying that XOR gates are used in two ways is not the same as saying my truth table has only that name. I would have thought to people who deal will logic this would be apparent. – Ben Crossley Jun 06 '19 at 12:58
  • 1
    What I'm saying is that you asked about "convention" and sometimes the common, conventional names for things are not the correct names. Try buying "yams" or "wasabi peas" and you'll see what I mean. Do you care about published standards or do you care about opinions on the internet? It's entirely up to you. – Elliot Alderson Jun 06 '19 at 16:00
  • 2
    Probably needs to go back to maths yhis is nothing to do with EE. – RoyC Jun 07 '19 at 11:00

3 Answers3

2

No, there is no name for that custom logic operation.

You'll have to implement the function below in whatever environment you are working in.

\$ f(a,b,c)=\begin{cases} \displaystyle 0 & ,\text{when } abc=1 \\ \displaystyle \text{xor}(a,b,c) & ,\text{otherwise} & \end{cases}\$

Or, if you don't want to deal with cases, this function gives the same answer:

\$ f(a,b,c)=\text{xor}(a,b,c)(1-abc) \$

Harry Svensson
  • 8,139
  • 3
  • 33
  • 53
  • 1
    Sorry, but your definition of XOR for >2 inputs is not a universal standard. Some definitions of such an XOR function specify that the output is true when **one and only one** input is true. – Elliot Alderson Jun 06 '19 at 12:01
  • @ElliotAlderson Hmm, it appears that it's up for interpretation according to your answer. And OP has shown how he views xor for 3 inputs with his truth table, which is the one I agree with, and all computers agree with. And since OP is the one that is going to use it then I suppose it's up to his interpretation which matters. - I would love to see any computational execution in any modern programming language that evaluates \$1\oplus1\oplus1\$ to anything other than 1. In my world xor for inputs >2 are just a sum of the ones modulo 2. I mean, this is how parity is calculated. – Harry Svensson Jun 06 '19 at 12:14
  • Take a look at the answers to https://electronics.stackexchange.com/questions/93713/how-is-an-xor-with-more-than-2-inputs-supposed-to-work/93719#93719 The OP asked about the **convention** for the name of the function, and according to some sources (such as the IEEE) the second function is the real XOR. By the way, the IEEE standards recommend a different symbol for parity functions. Can you provide citations for your claim that "all computers" agree with your definition? – Elliot Alderson Jun 06 '19 at 12:20
  • @ElliotAlderson No, I don't have any citation anywhere, unless you want me to start linking to datasheets for microcontrollers, I just know what happens if I have three registers, *a*, *b*, *c*, with LSB set to 1 and perform `a^b^c` then I get 1. And I've so far never come across any microcontroller / processor that gives me 0. Nor have I come across that when dealing with FPGA's, CRC, modulo 2 arithmetic or other boolean logic or truth tables for that matter. But fine, you can call it xor if you want, I won't. – Harry Svensson Jun 06 '19 at 12:29
  • 1
    I think the point is that \$\mathrm{xor}(A,B,C)\$ is not necessarily the same as \$\mathrm{xor}(\mathrm{xor}(A,B),C)\$. When you write assembly code or HDL you always use binary xor operators, so the question doesn't come up. – Elliot Alderson Jun 06 '19 at 15:56
  • @ElliotAlderson Hmm, okay, so fine, according to IEEE, XOR for more than 2 inputs is defined as output = 1 if only one input is 1 and rest are 0. So let's see what else I've learned here on EE.SE through comments. BJT's are voltage controlled because the current through its base can be described by \$V_{BE}\$. What else, [diodes don't follow ohm's law](https://electronics.stackexchange.com/questions/339055/does-a-diode-really-follow-ohms-law). I'll take the IEEE XOR to heart and apply it for the rest of my life. – Harry Svensson Jun 06 '19 at 19:33
  • It's your call. I just wanted the next person to come along and read this to have the facts. – Elliot Alderson Jun 06 '19 at 20:08
1

I think this truth table would result in something like the circuit below, unless I've made a mistake :)

As you mentioned it would be like a 3 Gate XOR (what's represented by your first table) but you have to exclude the case where all three inputs are 1 "True".

schematic

simulate this circuit – Schematic created using CircuitLab

This construct doesn't have a specific name it's XOR(NOT(AND(A,B,C)), XOR(A,B,C))

po.pe
  • 2,548
  • 1
  • 10
  • 25
  • Thank you for taking the time to make this however, the answer I am looking for is in the form of a name. I.e. ONE(A,B,C) – Ben Crossley Jun 06 '19 at 08:16
  • 2
    This construct doesn't have a specific name it's XOR(NOT(AND(A,B,C)), XOR(A,B,C)) – po.pe Jun 06 '19 at 08:27
0

Yes, this gate is called an exclusive-OR (XOR) gate. Some definitions of the XOR gate that has more than 2 inputs state that the output is true if one and only one input is true. This has been discussed at some length before: How is an XOR with more than 2 inputs supposed to work?

Elliot Alderson
  • 31,192
  • 5
  • 29
  • 67