A parity decoder or parity generator is used to add an extra bit at the end of the signal or single byte. For example, you are transferring 3 bits of data so one more bit is added to the data making it 4 bits. The extra bit that is added is used for error checking.
When data is received at the receiver end then the parity bit is checked for error detection.
Two main types of parity decoder are explained below:-
Even parity decoder
Suppose a 3-bit message is to be sent to the sender. So one parity bit is added at the end of the message. If the sum of 3 bits is equal to an odd number then a parity bit of 1 is added to make the sum even. Suppose A=0, B=0, C=1 so the sum of A, B, C become 1 which is an odd number. To make the sum an even number 1 is added as a parity bit.
If A=0, B=1, C=1 so the sum of A, B, C becomes 2 which is an even number. So 0 is added as a parity bit because the sum is already even.
At the receiver end, the sum of A, B, C is compared with the parity bit. So if an error occurs during message transfer then one bit can be changed. Suppose A=1, B=0, C=1, parity bit = 1 that mean there is some error because the sum of A, B, C is even and parity should be 0 but parity bit is 1.
Odd parity decoder
If A=0, B=1, C=0 so the sum of A, B, C = 1 mean a sum is already an odd number, so the parity bit should be 0. If the sum of A, B, C is an even number then a parity bit of 1 is added to make the sum odd.
If A=0, B=1, C=1 so the sum of A, B, C is 2 that is an even number, so parity bit of 1 is added to make the sum odd. So 2 + 1 = 3 that makes the odd number.
If any error occurs in the receiver end then A, B, or C will be changed. Suppose an error occurs and the message becomes A=0, B=1, C=0, parity bit = 1. So the sum of A, B, C is 1 that is an odd number and parity should be 0 but it is 1 in this case. That means there occurs some error.
Parity decoder is used for detecting errors at the receiver end by matching parity bit with the message or data.