Sie sind auf Seite 1von 6

c 

This is also called


 
   . This coding system has a property that
there is only one bit change between consecutive gray codes. The following table would show
gray codes of decimal values.


   
 


Starting from right to left

1. ×f it is MSB then place it as it is


2. Otherwise, Add the bit to the previous bit and place the sum in GRAY, ignoring any
carry
3. Repeat step 2 till end

Eg. Convert 1011 to gray

c  
 
 

Starting from right to left

1. ×f it is MSB then place it as it is


2. Otherwise, Add the bit to the previous than corresponding bit of GRAY code and place
the sum in GRAY, ignoring any carry
3. Repeat step 2 till end

Eg. Convert 1110 to gray

Ô  

A parity bit is an extra bit that is attached to the information that is being sent from one position
to the other. This bit is attached just to detect the error if any in the information during the
transmission. This bit is used to make number of 1¶s in the message or information either even
or odd. So if there is any change in any bit during transmission then there would be change in
number of 1¶s hence error would change the number of 1¶s from odd to even or even to odd
which can be detected. This way parity bit helps to detects errors. So whenever we need to send
information we¶ll pass the information firstly through PAR×TY GENERATOR C×RCU×T and
then send. Also at the receiver end information received is passed trough the PAR×TY CHECK
C×RCU×T and if parity matches, only then we use the information. ×f we make number of 1¶s
even then it is called even parity and if number of 1¶s is made odd then it is called odd parity.

But there are few drawbacks attached with this method:

Y This system can detect only odd combinations of error, not even combinations.
That means if there is 2 or 4 or 6 etc number of then it would go undetected while
it can easily detect 1, 3, 5 etc number of errors.
Y ÿe can not check the position of error even if we are able to detect it.
2. Eg2 
              
      

 
 
3. As 1101 has 3 i.e. odd number of 1¶s so P=0 so that we still have the odd number of 1¶s
in the combination of 5 bits(message(4 bits) and parity bit(1 bit))
4. So message we send with parity is 11010 (5th bit from left is parity bit)
5. Let¶s now see the effect of errors on this message
6.     Suppose we have error in 3rd bit from left so bit at 3rd position would change
from 0 to 1. Hence message received would be 11110 instead of 11010 and at the
receiver we check the parity of message and we see message has even number 1¶s in the
received signal which should have been odd so we have detected the error although we
are not sure about the position of the error. So as error is detected we can make a request
for another send of the same message.
7.    Suppose we have error at positions 1 and 4 from left so we have a bit change
from 1 to 0 at 1st and 1 to 0 at 2nd position. ÿe messaged received is 01000 and we have
odd number of 1¶s in received message which is also the parity status of sent message so
no detection of errors so we can see this method is unable to detect even number of errors
8.     Suppose we have error in 2nd , 3rd and 4th bit from left so bit change at 2nd
position is 1 to 0, at 3rd position would from 0 to 1 and at 4th from 1 to 0. Hence message
received would be 10100 instead of 11010 and at the receiver we check the parity of
message and we see message has even number 1¶s in the received signal which should
have been odd so we have detected the error although we are not sure about the positions
of the error. So as error is detected we can make a request for another send of the same
message.
9. So from here one can easily conclude that PAR×TY B×T method can detect only odd
number of errors independent on whether we have odd parity message or even parity
message.
10. ¦2
      
11. As 1100 has 2 i.e. even number of 1¶s so we take parity bit (odd) as 1 to make odd
number of 1¶s out of 5 bits
12. So message we send is 11001 (5th is the parity bit)
13. ¦2
    
  
14. As we have 2 i.e. even number of 1¶s so we take parity bit (even) as 0 so that number of
1¶s remain even. Hence the message is 11000 (5th is the parity bit)
15. ¦2
    
  
16. As we have 1 i.e. odd number of 1¶s so we take parity bit (even) as 1 so that number of
1¶s as even. Hence the message is 10001 (5th is the parity bit)
17. u

18. This code is used for single error correction i.e. using this code we can detect only single
error. ×n parity bit method we used only single extra bit but in this method number of
extra bits (which also are parity bits) vary with the number of bits of the message.

19.
20. Suppose we have the number of information bits as m=4 then we have to determine
number of parity bits using above relation
21. 2p >= 4 + p + 1
22. 2p >= 5 + p
23. From this we can check for values of p, which one satisfies
24. For p=1 2 >= 6 doesn¶t satisfy
25. For p=2 4>= 7 doesn¶t satisfy
26. For p=3 8>=8 satisfies hence we have p=3
27. So now we have 4 information bits and 3 parity bits so total of 7 bits. ×n the parity bit
method, we placed the parity bit at rightmost position. But here we don¶t place the extra
bits consecutively but the positions are fixed by following rule:

28.
29. As we need only three positions so we have to pick first 3 which are 1, 2, and 4.
30. So we have the composition of hamming code as follow:
31. Bit1 bit2 bit3 bit4 bit5 bit6 bit7
32. Parity parity parity
33. P1 P2 M1 P3 M2 M3 M4
34. Now we have to decide positions in the hamming code which would be covered by the
parity bit i.e. the positions considering which value of parity bit would be decided. ÿe¶ll
be using following rule for this:

35.
36. ¦22 
       Ô 
    
   
     
       .
37. Firstly write the binary equivalents of positions of message bit
38. Bit1 bit2 bit3 bit4 bit5 bit6 bit7
39. Parity parity parity
40. P1 P2 M1 P3 M2 M3 M4
41. 001 010 011 100 101 110 111
42. Now let¶s see in the binary equivalent of position of parity bit P1 that at which position
we have 1and we see 1 is at LSB so we select the message bits which have positions with
1 at LSB which are M1, M2 and M4 So P1 bit would check the parity for M1, M2 and M4
43. ¦22 
       Ô 
    
   
     
      
44. ÿe have 1 at second position from left so we choose message bits which have 1 at 2nd
position n their position¶s binary equivalent. Hence we get message bits M1 M3 and M4.
So Ôchecks parity for message bits of M1 M3 and M4
45. Similarly we have 1 at 3rd position of P3 message bits with 1 at 3rd position are M2M3 M4
46. So we now have
47. ÔChecks bit number 1,3,5,7
48. ÔChecks bit number 2,3,6,7
49. ԏChecks bit number 4,5,6,7
50. These parity bits can be either even or odd parity bits but all parity bits must be same i.e.
all odd or all even
51. ¦2       
 
 !              

  
"     
    2
52. As we have already decided parity bit positions and their corresponding message bits for
a 4-bit message
53. For the moment we have hamming code as P1 P2 1 P3 1 0 1
54. As we have already seen ÔChecks bit number 1,3,5,7
55. So Ô# "
     22

 
$$%$&
56. ÔChecks bit number 2,3,6,7
57. Ô# "
    22

 
$$'$&
58. ԏChecks bit number 4,5,6,7
59. ԏ# "
    22

 
 $%$'$&
60. Hence we have the hamming code as 1010101
61. As we have already mentioned that hamming code can only detect and correct only single
error. So we have error at 5th position which means bit changes from 1 to 0 so we have
data changed from 1010101 to 1010001
62. Now let¶s start checking all 3 parity bits starting from Ô
63. Ô " bit number 1,3,5,7 and we see we have number 1¶s in these bits is 3 i.e. odd
which is wrong as it should have been even so put a 1
64. Ô " bit number 2,3,6,7 and we see we have number 1¶s in these bits is 2 i.e. even
which is right so put a 0
65. ԏ " bit number 4,5,6,7 and we see we have number 1¶s in these bits is 1 i.e. odd
which is wrong as it should have been even so put a 1
66. Now we collect all the bits recorded with bit from Ôas LSB
67. So we get 101 hence we get bit 5 with
68.   Ô 
 ԏ    
    
  
       
 

 
 

  
  Ô 
   %

&
 Ô
ԏ &    

Ô     

%2
69. a ¦()*+,Ô)*(*)+)¦aa)aÿe start from Ôand start checking
whether bit is correct or wrong and if it is wrong then we put a 1 and put a zero if it is
correct. And while we reach end we collect all those bits taking bit from Ôas LSB. The
decimal equivalent we get from the bits collected is the bit position of error
70.
71. Hence we have the bit change in position 5 so re-change it to get the correct value.
Hence we change 5th bit of received message which is 1010001, we get 1010101 which is
correct one.
72. So we see hamming code is able to detect and correct single error.
73.
74. ¦2+ 
 %! 
  
   
75. m=5 and we have to follow 2p >= m + p + 1
76. The value of p as 4 to satisfy 24 (16) >= 5 + 4 + 1 but p=3 doesn¶t satisfy as 23 (8) >= 5 +
3+1
77. So p=4 and hence a total of 9 bits
78. Parity bit positions are 1, 2, 4, 8
79. And hence hamming code composition is as follow
80. 0001 0010 0011 0100 0101 0110 0111 1000 1001
81. 1 2 3 4 5 6 7 8 9
82. ÔÔ-ԏ--- Ô -%
83. Now if we see Ôhas 1 at LSB so message bits with this parity bit are --- -%
84. Similarly we see P2 checks M1 M3 M4
85. Similarly we see P3 checks M2 M3 M4
86. Similarly we see P4 checks M5
87. ) 
    
88. Ô"  $$%$&$.
89. Ô"  $$'$&
90. ԏ"   $%$'$&
91. Ô "  /$.
92.   

93. Bit positions
94. 1 2 3 4 5 6 7 8 9
ÔÔԏÔ 
95. ÿe see P1=1 to make no. of 1¶s to 3 i.e. odd
96. ÿe see P2=0 to make no. of 1¶s to 3 i.e. odd
97. ÿe see P3=1 to make no. of 1¶s to 3 i.e. odd
98. ÿe see P4=1 to make no. of 1¶s to 1 i.e. odd
99.   
 

Das könnte Ihnen auch gefallen