Altifigence Academy

5 / 63 · Khái niệm

XOR and XNOR: difference, equality and parity

Distinguish two-input XOR from multi-input parity and explain its detection limits.

Chưa có bản dịch. Nội dung bài học gốc được hiển thị. (English)

Difference and equality

Two-input XOR is 1 when its inputs differ; XNOR is 1 when they agree:

ab=ab+ab,ab=ab+aba\oplus b=\overline a b+a\overline b,\qquad \overline{a\oplus b}=ab+\overline a\,\overline b

OR and XOR differ at 11. In these symbols, the extra input-side curve marks XOR and an output circle makes it XNOR.

Compare OR and XOR at input 11
XOR · Truth table
aby
000
011
101
110

More inputs mean odd parity

For three inputs, abca\oplus b\oplus c is 1 when an odd number of inputs are 1. It is not an “exactly one” test: 111 also gives 1. The full-adder sum is this parityparity Whether the number of one bits is odd or even. Parity detects an odd number of bit flips but can miss an even number. function, while its carrycarry The value carried from one addition column to the next. The final carry and signed overflow are different conditions. Learn more is a majority function.

Odd parity is different from majority

a + b + cin = sum + 2 × cout

At 111, sum=1 and cout=1 represent the integer sum 1+2×1=31+2\times1=3.

What parity can detect

For data 1011, the even-parity bit p=d3d2d1d0p=d_3\oplus d_2\oplus d_1\oplus d_0 is 1. XOR of the data and parity bit is therefore zero. Any odd number of flips changes that check to one. Even numbers of flips can escape detection, and one parity bit cannot locate the error.

Vector equality needs an OR of bit mismatches, followed by inversioninversion The NOT operation exchanges 0 and 1. An overline applies NOT to the entire expression covered by the line. Learn more:

equal=i(AiBi)equal=\overline{\bigvee_i(A_i\oplus B_i)}

XOR-reducing the mismatches instead would allow two differences to cancel.

Tự thử

Find A XOR B and equality for A=1010, B=1001. What goes wrong if equality is inferred from XOR-reducing the mismatch vector?

Đọc giải thích

The mismatch vector is 0011 and equality is 0. XOR-reducing two mismatches gives zero; inverting that would incorrectly indicate equality. OR-reduce the mismatches instead.

Lựa chọn áp dụng cho trình duyệt này. Có thể đổi ở chân trang bất cứ lúc nào.