Parity is probably the simplest form of Integrity Check that can be added to a piece of data.
The most well-known is Character or byte parity. This is an error detection technique that is typically used on asynchronous links to provide an integrity check of individual received bytes. When used, each character is protected at the sender by adding a single parity baud (also known as a parity bit) to each character (byte) that is transmitted. This is sent after the last data bits of a byte.
The value of the parity bit is calculated by performing a logical exclusive OR (XOR) to combine all of the bits in the byte. This calculation can be peformed in hardware by the UART, as a part of the transmission function. Two types of parity are used:
A receiver needs to be configured to use a specific type of parity (if any) at the sender and at the receiver. When each byte (character) has been received, a parity value is accumulated (XOR-ing all the data bits). The receiver must use the same algorithm as set at the sender. The receiver compares the receiver-calculated parity value with the received value in the parity baud. There are two outcomes possible:
The parity value may alternatively be calculated using either an exclusive-or adder or a Finite State Machine (FSM). An implementation using XOR gates is shown below:
Hardware to Implement a Parity Checker
Software can also be used to calculate the character parity using a shift register to count the number of '1' bits in each byte. When the calculated parity from the received character does not match the value of the received parity bit, then a parity error is said to have occurred, and the character is normally discarded.
Here are some examples to check your understanding: A message "Hello" was sent as a serial command using the C programming statement "printf("Hello\n").
The original sequence of characters are shown in column 1.
The binary bit patterns that are sent are shown in the second column (use an ASCII table to see if this is represented in computer bit order or transmission bit order!)
The third column shows the sequence of received bits, including some transmission errors (can you identify which bits were corrupted?).
The received ASCII characters and the parity condition are shown in the final columns. (Can you validate that the parity logic detects these errors?)
H S010010011SS S010010011SS H Valid 'H' e S011001010SS S011011010SS ¿ Parity Error l S011011000SS S0110110000S ¿ Invalid l S011011000SS S011111001SS v Valid 'v' o S011011110SS S011011110SS o Valid 'o' cr S000011011SS S111011011SS ¿ Parity Error
In summary, parity, is good at detecting single errors, and will always detect any odd number of errors within a received character. If there are an even number of errors, the parity checker will be unable to detect the error. Consider the transmission of the same message and the received sequence below. Can you spot a line which contains a good parity value, but actually contains some bit errors?
S010010011SS S011001010SS S011011000SS S011011000SS S011011110SS S000011011SS
Longitudinal Parity can be used across the length of a block of data to perform an integrity check. This calculates one byte per block. The check can detect errors, especially when a parity baud is also added to each byte of data.
A more powerful block error detection mechanism can be provided using a Cyclic Redundancy Check (CRC).
See also: Prof. Gorry Fairhurst, School of Engineering, University of Aberdeen, Scotland (2025).