---
url: /dyad/stable/stdlib/BlockComponents/components/Logical.Xor.md
description: 'Dyad Logical.Xor docs.  Logical ''xor'': y = u1 xor u2.'
---

# `Logical.Xor` {#Logical.Xor}

Logical 'xor': y = u1 xor u2.

The output is **true** if exactly one input is **true**, otherwise the output is **false**.

This component extends from [`BlockComponents.Interfaces.PartialBooleanSI2SO`](../types/Interfaces.PartialBooleanSI2SO.md)

## Usage {#Usage}

`BlockComponents.Logical.Xor()`

## Connectors {#Connectors}

* `u1` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `u2` - This connector represents a boolean signal as an input to a component ([`BooleanInput`](/stdlib/Dyad/connectors/BooleanInput#BooleanInput))

* `y` - This connector represents a boolean signal as an output from a component ([`BooleanOutput`](/stdlib/Dyad/connectors/BooleanOutput#BooleanOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= \neg \mathtt{u1}\left( t \right) \wedge \mathtt{u2}\left( t \right) \vee \neg \mathtt{u1}\left( t \right) \wedge \neg \mathtt{u2}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Logical 'xor': y = u1 xor u2.

The output is **true** if exactly one input is **true**, otherwise the output is **false**.
"""
component Xor
  extends BlockComponents.Interfaces.PartialBooleanSI2SO
relations
  y = !((u1 and u2) or (!u1 and !u2))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Xor.svg"}
  }
}
end
```

```dyad
"""
Logical 'xor': y = u1 xor u2.

The output is **true** if exactly one input is **true**, otherwise the output is **false**.
"""
component Xor
  "Connector of first Boolean input signal"
  u1 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 150, "x2": 0, "y2": 250, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of second Boolean input signal"
  u2 = BooleanInput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 710, "x2": 0, "y2": 810, "rot": 0}
      },
      "tags": []
    }
  }
  "Connector of Boolean output signal"
  y = BooleanOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  y = !((u1 and u2) or (!u1 and !u2))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Xor.svg"}
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`LogicGates`](Logical.Xor.md)

  * [`Logical`](Logical.Xor.md)
