Parity Bit Tutorial: Single-Bit Error Detection
Derive even and odd parity with XOR, build a balanced generator and checker, quantify undetected errors, and understand what UART parity can—and cannot—prove.
TL;DR: A parity bit extends a data word so its total number of ones is even or odd. XOR implements both generation and checking. The resulting code detects every odd number of flipped bits—including every single-bit error—but every even-weight error pattern is invisible.
Parity is the smallest useful error-detecting code. It adds one bit, needs a reduction XOR, and gives a precise guarantee: changing an odd number of bits changes the word’s parity.
That guarantee is narrower than “the data is valid.” A clean check cannot distinguish an unchanged word from one in which two, four, or another even number of positions flipped. Professional use starts by stating that limit and deciding whether the residual undetected-error probability is acceptable.
Even and Odd Parity
For an -bit data word
define the reduction XOR:
exactly when the data contains an odd number of ones.
For even parity, choose:
Then the XOR of all transmitted positions is zero:
For odd parity, invert that bit:
and the combined XOR is one. Neither convention is intrinsically stronger. Sender and receiver must use the same convention and agree on exactly which fields are covered.
Four-Bit Generator Table
| Number of ones | |||
|---|---|---|---|
0000 | 0 | 0 | 1 |
0001 | 1 | 1 | 0 |
0011 | 2 | 0 | 1 |
0111 | 3 | 1 | 0 |
1111 | 4 | 0 | 1 |
The omitted rows follow the same rule; the bit pattern’s numeric value is irrelevant. Only the number of ones modulo two matters.
This is addition over the two-element field:
Two flips cancel in the parity sum, which explains both the circuit and the limitation.
Building the Generator
Two-input XOR gates are associative:
so several topologies implement the same Boolean function.
Linear chain
D7 ─┐
XOR─┐
D6 ─┘ XOR─┐
D5 ─────┘ XOR─ ... ─ P
For inputs, a simple chain uses two-input XOR operations and has up to logical gate levels.
Balanced tree
D7 ─┐
XOR─┐
D6 ─┘ │
XOR─┐
D5 ─┐ │ │
XOR─┘ │
D4 ─┘ │
XOR─ P
D3 ─┐ │
XOR─┐ │
D2 ─┘ │ │
XOR─┘
D1 ─┐ │
XOR─┘
D0 ─┘
For eight inputs, a balanced binary tree has three logical XOR levels. It usually offers less logic depth than a seven-level chain.
Do not attach a universal nanosecond value to either diagram. Actual delay depends on the gate family or FPGA mapping, routing, fan-out, supply, temperature, and input arrival times. If a wide parity tree lies on a timed path, verify it with the target implementation’s timing tools.
The Receiver’s Checker
For received data and received even-parity bit :
is often called a parity syndrome or parity error indication:
- : no odd-weight error was detected;
- : an odd number of covered positions differs from what was sent.
The checker cannot identify a position and therefore cannot correct the word. Its output should feed a defined response: mark the word invalid, raise a status bit, increment a diagnostic counter, or request retransmission through a higher-level protocol.
For odd parity, invert the pass/fail interpretation or compare the combined XOR with one.
Worked 8-Bit Example
Let the data byte be:
D = 10110100
It contains four ones, so even parity appends P=0:
transmitted codeword = 10110100 0
Clean reception
The XOR of all nine positions is 0, so the checker reports no detected parity error.
One flipped position
If D3 changes from 0 to 1:
received = 10111100 0
The combined XOR is 1. The receiver knows the codeword is corrupt, but not whether the fault is in D3, another data position, or P.
Two flipped positions
If D3 changes 0→1 and D5 changes 1→0:
received = 10011100 0
The combined XOR returns to 0. The corrupted word passes the parity check because the error pattern has even weight.
What Parity Guarantees
A single parity bit creates a code with minimum Hamming distance 2. It detects every error pattern of weight 1, and more generally:
| Number of flipped covered positions | Detected? |
|---|---|
| 1 | always |
| 2 | never |
| 3 | always |
| 4 | never |
| any odd number | always |
| any positive even number | never |
“Never” here means parity alone has no way to distinguish that error pattern from a valid codeword. Another layer—such as a CRC, sequence number, framing rule, or application constraint—might still expose it.
Parity does not:
- locate the changed bit;
- correct data;
- detect every burst;
- authenticate a message;
- prove that a physical link is healthy;
- protect fields excluded from its coverage.
An attacker can deliberately modify data and recompute parity. Use a cryptographic message-authentication mechanism when malicious tampering is in scope.
Quantifying Random Undetected Errors
Assume a codeword contains covered positions and each flips independently with probability . The probability of an even number of flips is:
That includes the no-error event, whose probability is . Therefore the probability of an undetected corrupted codeword is:
For small , the dominant term is:
An 8-bit data word plus parity has , so the first-order undetected contribution is approximately , not ; the parity position can fail too.
This model assumes independent, identically distributed bit flips. Real channels can have correlated noise and bursts, so measured or specified channel behavior should drive the code choice.
UART Parity in Context
A configurable asynchronous serial frame is commonly described with strings such as:
8N1: 8 data bits, no parity, 1 stop bit;8E1: 8 data bits, even parity, 1 stop bit;8O1: 8 data bits, odd parity, 1 stop bit.
UART framing and the RS-232 electrical interface are related in many systems but are not the same specification. The UART defines how characters are serialized and checked; an RS-232 transceiver defines voltage-level signaling for an interface.
A receiver that detects the wrong parity normally reports a parity error. A framing error is a different condition, commonly associated with an invalid stop bit. Microcontroller USARTs often expose separate status flags for these events.
Whether the receiver discards the character, delivers it with an error flag, or triggers an interrupt is implementation and software policy. Do not assume parity automatically requests retransmission; a protocol above the UART must define that behavior.
Parity, Hamming Codes, and CRCs
| Property | Single parity | Hamming(7,4) decoder | CRC |
|---|---|---|---|
| core operation | XOR reduction | parity-check syndrome | polynomial remainder over GF(2) |
| corrects errors | no | one bit, under its error model | normally no |
| detects all one-bit errors | yes | yes | depends on polynomial; standard choices generally do |
| even-weight error visibility | none from parity alone | code- and decoder-dependent | polynomial- and message-length-dependent |
| typical role | lightweight per-word check | forward correction for small blocks | strong frame/block detection |
Extended Hamming adds overall parity to support single-error correction and double-error detection under the assumed error limit. CRC strength depends on the generator polynomial and protected length; it should not be summarized as “catches all bursts” without those parameters.
Build It in DigiSim
Use the 8-bit serial transmitter/receiver template or a fresh canvas:
- Place eight data switches.
- Build a balanced XOR tree for even parity.
- Append P to the data word.
- Build a second XOR tree across all nine received positions.
- Add one fault-injection XOR per transmitted position.
- Verify every single-position fault produces
S=1. - Inject selected two-position faults and verify they pass undetected.
- Change to odd parity by inverting P and update the expected check value.
Also test transitions, not only static words. Unequal path delays can produce a temporary parity pulse while several data inputs change. Register the complete data word before checking it, or sample the syndrome only when the protocol says the word is stable.
When single-bit correction is the next requirement, continue with Hamming(7,4). Its several parity checks turn one error indication into a syndrome that identifies the position.



