One of the most common ways to achieve error detection is by means of parity code. A parity code is generated by adding an extra parity bit (information redundancy) to the string of data bits. There are two types of parity, such as even parity and odd parity. A given system operates with either even parity or with odd parity but not with both.
In the case of even parity, a parity bit is added to the data bits to make the total number of 1s even, including the parity bit. Similarly, in the case of odd parity, the total number of 1s, including the parity bit, becomes odd. The most common convention in digital systems is to use even parity. The following example shows the even as well as odd parity bit generation for a particular data bit stream. However, in a real system, either even or odd parity will be generated for the data transmission based on the system type (not both).
Example: Consider the ASCII code for the character ‘A’. Suppose you want to transmit this character. So, generate the even parity as well as the odd parity bit for the character ‘A’.
Solution:
The ASCII code of the character ‘A’ is 01000001. Now we need to generate both the even parity and odd parity bit for the character ‘A’.
The ASCII code of ‘A’ already has two 1s, that is, even. So the even parity bit will be ‘0’ so that the total number of 1s, including the parity bit, will be even.
Peven = 0
The odd parity bit will be ‘1’ so that the total number of 1s, including the parity bit, will be odd.
Podd = 1
The following table lists down the even parity bit as well as the odd parity bit for all the 4-bit binary numbers.
4-bit Binary Message | Even Parity bit (Peven) | Odd Parity bit (Podd) |
0000 | 0 | 1 |
0001 | 1 | 0 |
0010 | 1 | 0 |
0011 | 0 | 1 |
0100 | 1 | 0 |
0101 | 0 | 1 |
0110 | 0 | 1 |
0111 | 1 | 0 |
1000 | 1 | 0 |
1001 | 0 | 1 |
1010 | 0 | 1 |
1011 | 1 | 0 |
1100 | 0 | 1 |
1101 | 1 | 0 |
1110 | 1 | 0 |
1111 | 0 | 1 |
When the message is transmitted, it is transmitted along with the parity bit (either even parity bit or odd parity bit, depending on the system type). The placement of the parity bit again depends upon the system (MSB / LSB / any intermediate bit). However, for a particular system, the parity bit location is fixed for all the transmissions. The MSB is more popularly used for the parity bit.
You may find the following articles related to even parity interesting:
Error Detection using Parity
Let’s consider the same example of the ASCII code of ‘A’ for understanding error detection using parity.
Assume that the system is an even parity system, and the parity bit is placed at the MSB of the message. So, the correct message with the parity bit would be as follows:
001000001 (for the data transmission)
As discussed earlier, as the message has two 1s (even number of 1s), the even parity bit at the MSB of the message is ‘0’ (highlighted in blue).
Let’s say, during the message transmission, due to a noise signal, the ‘1’ at the LSB flipped to ‘0’, and the message received at the receiver is as below:
001000000
At the receiver end, again, a parity bit would be generated for the received data bits “01000000”. To maintain the even parity, now the generated parity bit would be ‘1‘, which does not match with the received parity bit that is ‘0‘. Since the parity check fails, it indicates that there is an error in the received message.
What is done after an Error is Detected
What is done after an error is detected depends upon the type of application. One example is to retransmit the data with the belief that the error is transient and will go away after some time. If there is an error, the receiver sends a negative acknowledgement so that the transmitter resends the data. This process repeats till the time the correct parity is not generated. If the error persists, then a message can be sent to the human operator to check for malfunctions on the transmission path.
Limitations of simple Parity Code
The simple parity code has two limitations, as mentioned below:
- The simple parity code can not detect an error if even number of data bits get corrupted.
- The simple parity code can not localize and correct the error.
Previous Table of Content Next