Jump to content

XOR Gate: Difference between revisions

From Logic World Wiki
m Fix casing
mNo edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Infobox component|title=XOR Gate|id=MHG.XorGate|caption=XOR gate|configurable=0|io.minInputs=2|io.maxInputs=2|io.outputs=1|io.propagationDelay=1}}
{{Infobox component
|title=XOR Gate
|id=MHG.XorGate
|caption=XOR gate
|configurable=0
|io.minInputs=2
|io.maxInputs=2
|io.outputs=1
|io.propagationDelay=1
}}


The '''XOR gate''' is a basic digital logic component whose output will be {{on}} if only '''one''' of its inputs are '''ON'''.
The '''XOR Gate''' is a [[component]] used for [[digital logic]]. Its output will be {{on}} if '''exactly one''' of its inputs are {{on}}.


An XOR gate is 2 tiles wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.
An XOR Gate is 2 tiles wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.


== Logic ==
== Behavior ==
The XOR gate's output will only be active if '''one''' of its inputs are '''ON'''.{{Truth table|0 0 0|1 0 1|0 1 1|1 1 0|inputs=Input 1, Input 2|outputs=1|caption=XOR Gate Truth Table}}
Below are alternative XOR definitions.<br>
The XOR gate's output will only be {{on}}:


*if inputs are '''not equal'''.
The XOR Gate's output will be {{on}} if and only if exactly one of its inputs are {{on}}.
:Helpful to compare values.
*if number of {{on}} inputs is '''odd'''.
:Helpful for XOR's with multiple inputs.


== Timing ==
{{Truth table auto
[[File:XOR gate activation delay.png|thumb|A demonstration of two XOR gates being activated. The top XOR gate has one of its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom XOR gate has had one of its inputs active for at least 1 tick, and its output is therefore active.]]
| inputs=2
The XOR gate has a latency of 1 tick, so in the instance when all inputs are {{on}}, the output will become active 1 tick later. As demonstrated in the example on the right.
| outputs=1
| caption=XOR Gate Truth Table
| expr1=a ^ b
}}


== Configurability ==
There are a few ways to think about this behavior. Using different approaches can help you see more situations where XOR is useful.Below are alternative XOR definitions.<br>
The XOR gate cannot have its number of inputs changed, but can have its output position flipped by pressing 'F' on it. The bottom XOR gate in the image on the right has had its output flipped.
The XOR Gate's output will only be {{on}}:
 
* if exactly one of its inputs are {{on}}.
* if the inputs are '''not equal'''.
* if the number of inputs in the {{on}} state is '''odd'''.
 
The XOR Gate takes one [[tick]] to update the state of its output after a change to the state of its inputs.
 
== Placement ==
 
XOR Gates have two attachment points, one for each square covered by the body of the component. These attachment points can be placed in the center of a [[Circuit Board]] square or on top of a [[Mount]].
 
An XOR Gate can be [[Flipping|flipped]] upside down. This moves its output to the other side, which is useful when you are space-constrained or when building mirrored circuitry.
 
{{todo|image of different ways XOR Gates can be placed}}
 
== Trivia ==
 
* "XOR" is a short form of "Exclusive OR".
 
{{Navbox components}}


[[Category:Vanilla components]]
[[Category:Vanilla components]]
[[Category:Circuitry components]]
[[Category:Circuitry components]]

Latest revision as of 22:53, 8 September 2025

XOR Gate

XOR gate
Component info
Internal ID MHG.XorGate
Configurable No
Input and output
Input count 2
Output count 1
Propagation delay 1 tick

The XOR Gate is a component used for digital logic. Its output will be ON if exactly one of its inputs are ON.

An XOR Gate is 2 tiles wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.

Behavior

The XOR Gate's output will be ON if and only if exactly one of its inputs are ON.

XOR Gate Truth Table
Input 1Input 2Output
000
011
101
110

There are a few ways to think about this behavior. Using different approaches can help you see more situations where XOR is useful.Below are alternative XOR definitions.
The XOR Gate's output will only be ON:

  • if exactly one of its inputs are ON.
  • if the inputs are not equal.
  • if the number of inputs in the ON state is odd.

The XOR Gate takes one tick to update the state of its output after a change to the state of its inputs.

Placement

XOR Gates have two attachment points, one for each square covered by the body of the component. These attachment points can be placed in the center of a Circuit Board square or on top of a Mount.

An XOR Gate can be flipped upside down. This moves its output to the other side, which is useful when you are space-constrained or when building mirrored circuitry.


TODO: image of different ways XOR Gates can be placed

Trivia

  • "XOR" is a short form of "Exclusive OR".