Recognized XOR Gate

    Joined
    Jul 3, 2013
    Messages
    1,114
    Reaction score
    41
    • Legacy Citizen 5
    • Top Forum Contributor
    Not sure if this has been looked upon before but I would like it to be implemented so I can build other logic circuits with it.

    For those of you who don't know, the XOR Gate (exclusive-or) is a gate that functions like an OR gate, except it works a bit differently.

    Just like an OR gate, the output is low when all inputs are low and if at least one input is a high the output is high. However when all inputs are high, the output is low. A truth table with a two input XOR Gate is shown below.



    I've made this logic gate already using AND gates and OR gates, but I have to use four or five gates just to make the logic function.

    With it I believe we can expand our understanding of logic even more. I would like to see if this be added to logic if it could. I appreciate any thoughts you have.
     

    MeRobo

    Scrub
    Joined
    Apr 1, 2015
    Messages
    422
    Reaction score
    650
    • Purchased!
    • Competition Winner - Small Fleets
    • Legacy Citizen 4
    XOR I agree, because it's 2 NOT, 2 AND and 1 OR. However, I don't think NAND and so on are needed as seperate gates because you only need to add a NOT.
     
    Joined
    Jul 3, 2013
    Messages
    1,114
    Reaction score
    41
    • Legacy Citizen 5
    • Top Forum Contributor
    I agree with MeRobo. It only takes two blocks to make any gate perform a NOT function.

    I'm glad that people could find this useful though. I'm finally noticed by StarMade senpais~
     
    • Like
    Reactions: MeRobo
    Joined
    Jul 20, 2013
    Messages
    603
    Reaction score
    203
    • Legacy Citizen 2
    • Community Content - Bronze 2
    • Purchased!
    I suppose you're both right, but I just think it couldn't hurt really. I always push for miniaturization. XOR really should get priority for implementation here though.
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    The only big problem with XOR [as pointed out here], is that there are multiple conflicting definitions for more than 2 inputs. All definitions of XOR match up for exactly 2 inputs, but don't for more than 2 inputs. A logic block in starmade has to work with any number of inputs.
    I am not opposing the addition of XOR blocks, but pointing out, that there probably should be multiple XOR blocks, one for each reasonable conflicting definition.
    Odd-parity gate
    One-hot gate
    Not Equal gate
     
    Joined
    Jul 3, 2013
    Messages
    1,114
    Reaction score
    41
    • Legacy Citizen 5
    • Top Forum Contributor
    The only big problem with XOR [as pointed out here], is that there are multiple conflicting definitions for more than 2 inputs. All definitions of XOR match up for exactly 2 inputs, but don't for more than 2 inputs. A logic block in starmade has to work with any number of inputs.
    I am not opposing the addition of XOR blocks, but pointing out, that there probably should be multiple XOR blocks, one for each reasonable conflicting definition.
    Odd-parity gate
    One-hot gate
    Not Equal gate
    I see what you mean. It will obviously take time to make the code for the XOR Gate. Maybe we could start off by simply having two types of blocks: even-input and odd-input. It might make the whole concept of XOR gates simpler for programming.
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    I see what you mean. It will obviously take time to make the code for the XOR Gate. Maybe we could start off by simply having two types of blocks: even-input and odd-input. It might make the whole concept of XOR gates simpler for programming.
    The programming part is trivial:
    Odd-parity gate: n%2!=0
    One hot gate: n==1
    Not equal gate: n%N!=0
    In addition, the even parity gate is trivial, as it is the negated odd parity gate.

    As for simply prefering one extendable definition over all others: The official definition of XOR only applies to 2 inputs, and is the truthtable in your OP. It cannot be applied to less or more inputs without modification. Most commonly XOR gates with 3 or more inputs act like odd parity gates, however, there is no general definition for it to be that way, so there are 3 or more input XOR gates that behave differently from odd parity gate. As a result prefering one extended definition will lead to people expecting different behaviours of 3+ input XOR gates.
     
    Joined
    Jul 3, 2013
    Messages
    1,114
    Reaction score
    41
    • Legacy Citizen 5
    • Top Forum Contributor
    The programming part is trivial:
    Odd-parity gate: n%2!=0
    One hot gate: n==1
    Not equal gate: n%N!=0
    In addition, the even parity gate is trivial, as it is the negated odd parity gate.

    As for simply prefering one extendable definition over all others: The official definition of XOR only applies to 2 inputs, and is the truthtable in your OP. It cannot be applied to less or more inputs without modification. Most commonly XOR gates with 3 or more inputs act like odd parity gates, however, there is no general definition for it to be that way, so there are 3 or more input XOR gates that behave differently from odd parity gate. As a result prefering one extended definition will lead to people expecting different behaviours of 3+ input XOR gates.
    So say we had different XOR blocks as you proposed. Would that be considered the easiest solution?
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    So say we had different XOR blocks as you proposed. Would that be considered the easiest solution?
    IMO yes, as the additional effort is trivial, the amount of block IDs taken is trivial too(2 or 3 more than just 1), and the problem is fully solved.
    To avoid confusing those not well versed in gate names, call them "Odd-parity XOR gate", "One-hot XOR gate" and "Inequals XOR gate", highlighting both their XOR properties and extended definitions.
     
    Joined
    Aug 17, 2013
    Messages
    49
    Reaction score
    52
    • Purchased!
    • Community Content - Bronze 1
    • Legacy Citizen 5
    The only big problem with XOR [as pointed out here], is that there are multiple conflicting definitions for more than 2 inputs...
    While this is true, and I like the suggestions in this thread for multiple XOR blocks with different properties, I would like to point out that they already dealt with this issue in the past with their solution with the Flip-Flop. There are numerous types of Flip-Flops, most of which would be welcome, but they picked one, the T type Flip-Flop (Flip-flop (electronics) - Wikipedia, the free encyclopedia) and went with it.

    All that is to say that I love the idea of an XOR and doubt that most of the community would be up in arms if they took the most basic version of a multi-input XOR and gave us that block. (to start :) )
     

    Valiant70

    That crazy cyborg
    Joined
    Oct 27, 2013
    Messages
    2,189
    Reaction score
    1,168
    • Thinking Positive
    • Purchased!
    • Legacy Citizen 4
    If I'm remembering my boolean algebra correctly,
    a XOR b XOR c = a XOR (b XOR c) = (a XOR b) XOR c
    Thus, just XOR each input onto the result for the last two.

    Now I might be remembering this incorrectly but I'm too sleepy and lazy to look it up right now.
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    If I'm remembering my boolean algebra correctly,
    a XOR b XOR c = a XOR (b XOR c) = (a XOR b) XOR c
    Thus, just XOR each input onto the result for the last two.

    Now I might be remembering this incorrectly but I'm too sleepy and lazy to look it up right now.
    That is correct, but it just proves, that in a chain of 2-input XOR gates, the order of the gates does not matter. You would need to additionally define, that XOR(a,b,c):=a XOR b XOR c
    [and yes, I am viewing XOR with more than 2 inputs as a function, not as a relation]