LINEAR BLOCK CODES
Minimum Distance for Linear Block Codes
Some Linear Block Codes
In a linear block code, the exclusive OR
(XOR) of any two valid codewords
creates another valid codeword.
Example
Find if the two codes we defined below, belong to the
class of linear block codes.
Table 1
Table 2
1. The scheme in Table 1 is a linear block code
because the result of XORing any codeword with any
other codeword is a valid codeword. For example, the
XORing of the second and third codewords createsthe
fourth one.
2. The scheme in Table 2 is also a linear block code.
We can create all four codewords by XORing two
other codewords.
Example
In our first code table 1, the numbers of 1s in the nonzero codewords
are 2, 2, and 2. So the minimum Hamming distance is dmin = 2. In our
second code (Table 2), the numbers of 1s in the nonzero codewords
are 3, 3, and 4. So in this code we have dmin = 3.
•A simple parity-check code is a
single-bit error-detecting
code in which
n = k + 1 with dmin = 2.
•i.e. it can detect only one err and can’t
correct any error.
Simple parity-check code C(5, 4)
Encoder and decoder for simple parity-check code
Example
Let us look at some transmission scenarios. Assume the sender sends
the dataword 1011. The codeword created from this dataword is
10111, which is sent to the receiver. We examine five cases:
1. No error occurs; the received codeword is 10111
2. One single-bit error changes a1 .
3. One single-bit error changes r0 .
4. An error changes r0 and a second error changes a3 .
5. Three bits—a3, a2, and a1—are changed by errors.
A simple parity-check code can detect
an odd number of errors.
CASE 1:A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 0
A adds parity bit and sends: 10010
B receives: 10010
B computes overall parity: 1^0^0^1^0 = 0
B reports correct transmission after observing expected even result
CASE 2:A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 0
A adds parity bit and sends: 10010
*** TRANSMISSION ERROR ***
B receives: 11010
B computes overall parity: 1^1^0^1^0 = 1
B reports incorrect transmission after observing unexpected odd result
CASE 3:A wants to transmit: 1001
A computes even parity value: 1^0^0^1 = 0
A sends: 10010
*** TRANSMISSION ERROR ***
B receives: 11011
B computes overall parity: 1^1^0^1^1 = 0
B reports correct transmission though actually incorrect
Two-dimensional parity-check code
Two-dimensional parity-check code
Two-dimensional parity-check code
2D parity can detect upto 3 errors
Hamming code:
It is error correcting code
Original Hamming code was with Dmin=3
For which relation between n,r,k is
Let m any number such that ( m >=3)
Hamming code sates that n = 2m − 1
And k = n-m
And then number of check bits required are r=m
Eg if m=3 then n=7 and k=4
This is Hamming code C(7,4) with Dmin=3
Next slide shows dataword and codeword for this code
Hamming code C(7, 4)
Q: How are the code words decided?
The structure of the encoder and decoder for a Hamming code
Generator generates three parity bits as shown:
R0 = a2+a1+a0 modulo-2
R1 = a3+a2+a1 modulo-2
R2 = a3+a1+a0 modulo-2
i.e. Ri is set such that number of 1’s in each of the three equations is even.
While at Rx , the decoder generates 3bit syndrome ( S2S1S0) as shown:
S0 = b2+b1+b0+q0 modulo-2
S1 = b3+b2+b1+q1 modulo-2
S2 = b3+b1+b0+q2 modulo-2
And depending upon the syndrome value the correction logic can find which
received bit has error and hence corrects it just by inverting it. See example in
next slide
Logical decision made by the correction logic analyzer
Generate code words using hamming code for
1011 ,0101
R0 = a2+a1+a0 modulo-2
R1 = a3+a2+a1 modulo-2
R2 = a3+a1+a0 modulo-2 A3 A2 A1 A0
1 0 1 1
FOR 1) 1011
R0 =0+1+1 =0
R1 = 1+0+1 =0
R2 = 1+1+1 = 1
SO CODE WORD IS 1011100
Find the error and hence correct it to find actual data
word
( code is C(7,4)), if the received codewords are
1) 0100011
2) 0011001
3) 0001000
Hint :actual datawords are
0100
0111
1101 *
0100011
B3 B2 B1 B0 Q2 Q1 Q0
0 1 0 0 0 1 1
S0 = b2+b1+b0+q0 modulo-2
S1 = b3+b2+b1+q1 modulo-2
S2 = b3+b1+b0+q2 modulo-2
S0 =1+0+0+1 = 0
S1 = 0+1+0+1 =0
S2 = 0+0+0+0 =0
Syndrome is 000 , so looking at the table, there is no error
0011001
B3 B2 B1 B0 Q2 Q1 Q0
0 0 1 1 0 0 1
S0 = b2+b1+b0+q0 modulo-2
S1 = b3+b2+b1+q1 modulo-2
S2 = b3+b1+b0+q2 modulo-2
S0 =0+1+1+1 = 1
S1 = 0+0+1+0=1
S2 = 0+1+1+0 =0
Syndrome is 011 . Looking at the table, there is error the bit b2 ,
so simply invert it . Actual dataword sent by Tx is 0111
Hamming code C(7,4) can detect double error and can
correct only single error .