Implementation of Hamming Code Using Verilog
Implementation of Hamming Code Using Verilog
Implementation of Hamming Code Using Verilog
[email protected]*5
Assistant Professor, SIR C R REDDY COLLEGE OF ENGG
7 0 1 1 1
Now the value at this position 7 is to be
11 10 9 8 7 6 5 4 3 2 1 complimented so that the error can be corrected. So
that we can get the original encoded data. Now this
data is to be decoded to get the original information
d7 d6 d5 r4 d4 d3 d2 r3 d1 r2 r1 data without any errors.
Position of redundancy bits in hamming code
PRESENT TECHNIQUE
Here the d1 to d7 are data bits to be transmitted and
r1 to r4 are redundancy bits. Let the data be 1100110. This process is also similar to previous technique at
Now the values of r1, r2, r3 and r4 are calculated the same steps including encoding, error detection
based on the even parity condition for those positions and correction, decoding. But the only difference is in
given in (a), (b), (c) and (d) respectively. the previous technique redundancy bit positions are
taken at 2^r positions, where as in this proposed
Since the number of 1’s at positions 3, 5, 7, 9, 11 is 2. improved method the redundancy bit positions are
It satisfies the even parity condition, so the required taken at the end of the data. In the previous technique
value of r1 is ‘0’. Since the number of 1’s at positions a total of 20 bits are involved in the process of
3, 6, 7, 10, 11 is 3. It does not satisfies the even parity calculation of redundancy bits, where as in this
condition, so the required value of r2 is ‘1’. Since the proposed improved method a total of 19 bits are
number of 1’s at positions 5, 6, 7 is 2. It satisfies the involved in the process of calculations of redundancy
even parity condition, so the required value of r3 is bits. This is the advantage of this proposed method
‘0’. Since the number of 1’s at positions 9, 10, 11 is over the previous method where there is a reduction
2. It satisfies the even parity condition, so the in the usage of 1 bit.
required value of r4 is ‘0’. So the encoded data
obtained is “11000110010”. ENCODING :
ERROR DETECTION, CORRECTION AND Similar to previous technique here the data bits(d) are
DECODING : encoded with redundancy bits(r) that are to be
transmitted. Here the value of r is obtained by using
If there is any error in received data here we need to the formula
detect and correct. Here the error position is
indentified with the help of c3 c2 c1 c0 whose values 2^r >= d+r+1 ….. (1)
obtained after checking the even parity condition by
considering the parity of the bit positions as given in Where r = number of redundancy bits
(a), (b), (c) and (d). Now let the received data is
“11001110010”, which has error at position 7 by d = number of data bits
Let us consider the same example, The 7-bit data to If there is any error in received data here we need to
be transmitted is “0110010”. For this the smallest detect and correct. Here the error position is
value of r that satisfies the above condition (1) is 4. indentified with the help of c3 c2 c1 c0 whose values
So a total of 11-bit encoded data is transmitted. Here obtained after checking the even parity condition by
let us consider r1, r2, r3 and r4 as 4 redundancy bits. considering the parity of the bit positions as given in
Each r bit is parity bit for one combination of data (a), (b), (c) and (d). Now let the received data is
bits as shown below: “10010100010”, which has error at position 5 by
comparing with above obtained encoded data. Now
r1 - 1, 3, 5, 7 ……….. (a) the values of c3, c2, c1 and c0 are calculated as
r2 - 2, 3, 6, 7 .………. (b) follows:
r3 – 4, 5, 6, 7 ….……. (c) Since the number of 1’s at positions 1, 3, 5, 7, 8 is 1.
r4 – r1, r2, r3 ……….. (d) It does not satisfies the even parity condition, so the
required value of c0 is ‘1’. Since the number of 1’s at
positions 2, 3, 6, 7, 9 is 2. It satisfies the even parity
condition, so the required value of c1 is ‘0’. Since the
11 10 9 8 7 6 5 4 3 2 1 number of 1’s at positions 4, 5, 6, 7, 10 is 1. It does
not satisfies the even parity condition, so the required
value of c2 is ‘1’. Since the number of 1’s at
r4 r3 r2 r1 d7 d6 d5 d4 d3 d2 d1 positions 8, 9, 10, 11 is 2. It satisfies the even parity
Position of redundancy bits in hamming code condition, so the required value of c3 is ‘0’. Now the
error position is identified with help of c3 c2 c1 c0 as
Here in this table the d1 to d7 are data bits to be shown below:
transmitted and r1 to r4 are redundancy bits. Now the
values of r1, r2, r3 and r4 are calculated based on the Error
even parity condition for those positions given in (a), position C3 C2 C1 C0
(b), (c) and (d) respectively.
5 0 1 0 1
Since the number of 1’s at positions 1, 3, 5, 7 is 1. It Now the value at this position 5 is to be
does not satisfies the even parity condition, so the complimented so that the error can be corrected. So
required value of r1 is ‘1’. Since the number of 1’s at that we can get the original encoded data. Now the
positions 2, 3, 6, 7 is 2. It satisfies the even parity 11-bit encoded data is to be decoded to get the
condition, so the required value of r2 is ‘0’. Since the original 7-bit information data without any errors.
number of 1’s at positions 4, 5, 6, 7 is 2. It satisfies
the even parity condition, so the required value of r3
is ‘0’. Since the number of 1’s at positions 8, 9, 10
is 1. It does not satisfies the even parity condition, so
the required value of r4 is ‘1’. So the encoded data
obtained is “10010110010”.
NOTE :
Fig : Hamming encoder
If we get error at positions 8, 9, 10 or 11. It can noit
ERROR DETECTION,CORRECTION AND able to detect the correct position. Since the bits at
DECODING : these positions are redundancy bits which are just
used for the purpose of encoding and to provide help
11 10 9 8 7 6 5 4 3 2 1 C3 C2 C1 C0 ERRORPOSITION
1 0 0 1 0 1 1 0 0 1 0 T T T T No error
CONCLUSION