Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

XOR Gate (xor)

Outputs 1 when an odd number of inputs are above 0.5.

xor

Component reference · 繁體中文

Group: Control · Kind: {"block":"xor","kind":"control"}

When to use it

Use it to detect that two signals differ, such as a commanded and a measured gate state. Use OR Gate when several true inputs should still give 1.

Pins

Pin Domain Meaning
in1 signal First input; true above 0.5
in2 signal Second input; true above 0.5
in3 signal Third input, read if n is 3 or 4
in4 signal Fourth input, read if n is 4
out signal Output, always 0 or 1

Common parameters

  • n: How many inputs the gate has (Default: 2)

Parameters

Key Unit Default Typical range Description
n — 2 How many inputs the gate has

Parameter descriptions are in English in both languages.

Model

The first n inputs are read (n = 2 by default, up to 4). An input is true when it is above 0.5. The output is 1 when an odd number of the n inputs are true and 0 when the count is even. For two inputs this is true when they differ. The gate is combinational and has direct feedthrough.

Common mistakes

  • With three or four inputs this is a parity check, not exactly one: three true inputs give 1. The default n of 2 ignores in3 and in4, so set n to the number of inputs you use.
  • Two signals that change at slightly different solver steps make the output flash for one step, and a counter or latch may count it. Compare signals that come from the same clock; a loop made only of gates is refused.

Problems rules: compile.error

Datasheet and sources

There is no datasheet. n is the number of signals compared. The logic levels come from your design, for example a command signal against its feedback.

Example

Open the example with the command file.openExample and the name demo:xor.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.