Skip to main content

Chapter 8 · 7 hours

Error Detection and Correction Coding

IOE past exam questions

Past questions and answers

23 questions set from this chapter, 4 of them more than once. Most asked first.

  • Asked 5 times
  • 2071 Magh (old course) · 4 marks
  • 2068 Jestha (old course) · 5 marks
  • 2080 Bhadra (CS II) · 4 marks
  • 2079 Bhadra (CS II) · 5 marks
  • 2075 Chaitra (CS II) · 5 marks

Write a short note on convolutional codes.

Answer

A convolutional code is an error-correcting code in which the encoder has memory: each group of output bits depends on the current input bit and on the previous K−1K-1 input bits stored in a shift register. The code is described by (n,k,K)(n,k,K): kk input bits produce nn output bits, giving code rate r=k/nr=k/n, and KK is the constraint length.

Encoder

A rate-1/2, K=3K=3 encoder with generators g(1)=(1,1,1)g^{(1)}=(1,1,1) and g(2)=(1,0,1)g^{(2)}=(1,0,1):

 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |  \        |         /  |
        |   \--(+)--+--------/   |   c1 = mi+mi-1+mi-2
        |                        |
        +---------(+)------------+   c2 = mi+mi-2
                 output: c1 c2 c1 c2 ...

Each output is the modulo-2 convolution of the input with a generator sequence: ci(j)=∑lgl(j)mi−lc_i^{(j)}=\sum_l g_l^{(j)}m_{i-l}.

Example: input 1 0 0 1 1 (plus two flushing 0s) gives 11 10 11 11 01 01 11.

Representations

  • Code tree: branches up for 0, down for 1, labelled with output bits.
  • Trellis diagram: states (contents of memory) against time; repeats after K−1K-1 steps.
  • State diagram: 2K−12^{K-1} states with transitions labelled input/output.

Decoding

The Viterbi algorithm (maximum-likelihood) finds the trellis path with minimum Hamming distance from the received sequence; sequential decoding is used for large KK.

Features

  • Works on a continuous bit stream, no block division.
  • Strong error correction with soft-decision decoding; free distance dfreed_{free} measures power.
  • Used in GSM, satellite and deep-space links, Wi-Fi (often with interleaving).
  • Asked 2 times
  • 2080 Baisakh (CS II) · 10 marks
  • 2070 Asar (CS II) · 1+4 marks

What is binary Cyclic code? Construct a (7,4) binary Cyclic Code using a generator polynomial g(x) = x³ + x² + 1 with data Vector (1011).

Answer

Binary cyclic code

A binary cyclic code is a linear block code in which every cyclic shift of a codeword is also a codeword. If (c0,c1,…,cn−1)(c_0,c_1,\dots,c_{n-1}) is a codeword, so is (cn−1,c0,…,cn−2)(c_{n-1},c_0,\dots,c_{n-2}).

Code vectors are treated as polynomials c(x)=c0+c1x+⋯+cn−1xn−1c(x)=c_0+c_1x+\dots+c_{n-1}x^{n-1}. An (n,k)(n,k) cyclic code is defined by a generator polynomial g(x)g(x) of degree n−kn-k that divides xn+1x^n+1. Every codeword is a multiple of g(x)g(x). Cyclic codes are easy to encode and decode with shift registers (used in CRC).

Given

(n,k)=(7,4)(n,k)=(7,4), n−k=3n-k=3, g(x)=x3+x2+1g(x)=x^3+x^2+1. It is a valid generator since x7+1=(x+1)(x3+x+1)(x3+x2+1)x^7+1=(x+1)(x^3+x+1)(x^3+x^2+1).

Convention: the leftmost data bit is the highest power. Data 10111011:

d(x)=x3+x+1d(x)=x^3+x+1

All arithmetic is modulo 2 (1+1=01+1=0).

(a) Non-systematic codeword

c(x)=d(x) g(x)=(x3+x+1)(x3+x2+1)=x6+x5+x3+x4+x3+x+x3+x2+1=x6+x5+x4+x3+x2+x+1\begin{aligned} c(x)&=d(x)\,g(x)=(x^3+x+1)(x^3+x^2+1)\\ &=x^6+x^5+x^3+x^4+x^3+x+x^3+x^2+1\\ &=x^6+x^5+x^4+x^3+x^2+x+1 \end{aligned}

(three x3x^3 terms leave one x3x^3.)

Non-systematic code vector: 1 1 1 1 1 1 1

(b) Systematic codeword

Steps: multiply by xn−k=x3x^{n-k}=x^3, divide by g(x)g(x), append the remainder as parity bits.

x3d(x)=x6+x4+x3x^3d(x)=x^6+x^4+x^3

Long division by g(x)=x3+x2+1g(x)=x^3+x^2+1:

              x^3 + x^2            <- quotient
          ---------------------------
x^3+x^2+1 ) x^6 +     x^4 + x^3
            x^6 + x^5 +       x^3
            -----------------------
                  x^5 + x^4
                  x^5 + x^4 +       x^2
                  -------------------
                                    x^2   <- remainder

Remainder p(x)=x2p(x)=x^2, i.e. parity bits (x2,x1,x0)=1 0 0(x^2,x^1,x^0)=1\,0\,0.

c(x)=x3d(x)+p(x)=x6+x4+x3+x2c(x)=x^3d(x)+p(x)=x^6+x^4+x^3+x^2

Check: c(x)=(x3+x2) g(x)c(x)=(x^3+x^2)\,g(x), a multiple of g(x)g(x), so it is a valid codeword.

Systematic code vector: 1 0 1 1 | 1 0 0 (data bits followed by parity bits).

Shift-register encoder check

The remainder can be produced by a 3-stage feedback shift register (taps at the non-zero coefficients of g(x)=1+x2+x3g(x)=1+x^2+x^3). With feedback f=input⊕r2f=\text{input}\oplus r_2, the update is r0←fr_0\leftarrow f, r1←r0r_1\leftarrow r_0, r2←r1⊕fr_2\leftarrow r_1\oplus f.

Input (MSB first)ffr0r_0r1r_1r2r_2
start000
11101
01111
10011
10001

After 4 shifts the register holds (r0,r1,r2)=(0,0,1)(r_0,r_1,r_2)=(0,0,1), i.e. remainder x2x^2; read out r2r1r0=100r_2r_1r_0=100, the same parity bits as the long division. The 4 data bits are sent first, then the gate opens and the 3 parity bits follow.

FormCode vector
Non-systematic1111111
Systematic1011100
  • Asked 2 times
  • 2076 Asoj (CS II) · 4+5 marks
  • 2074 Asoj (CS II) · 2+6 marks

Define Hamming Weight and Hamming Distance. Construct a (7, 4) cyclic code using a generator polynomial g(x) = x³ + x² + 1 with data vector 1011.

Answer

Hamming weight

The Hamming weight w(c)w(\mathbf{c}) of a code vector is the number of non-zero (1) elements in it.

Example: w(1011100)=4w(1011100)=4, w(0000000)=0w(0000000)=0.

Hamming distance

The Hamming distance d(c1,c2)d(\mathbf{c}_1,\mathbf{c}_2) between two code vectors of equal length is the number of positions in which they differ. It equals the weight of their modulo-2 sum: d(c1,c2)=w(c1⊕c2)d(\mathbf{c}_1,\mathbf{c}_2)=w(\mathbf{c}_1\oplus\mathbf{c}_2).

Example: c1=1011100\mathbf{c}_1=1011100, c2=1111111\mathbf{c}_2=1111111; c1⊕c2=0100011\mathbf{c}_1\oplus\mathbf{c}_2=0100011, so d=3d=3.

The smallest distance between any two codewords is the minimum distance dmind_{min}; for a linear code it equals the smallest non-zero weight. A code detects up to dmin−1d_{min}-1 errors and corrects up to ⌊(dmin−1)/2⌋\lfloor (d_{min}-1)/2\rfloor. For the (7,4) cyclic Hamming code dmin=3d_{min}=3: it detects 2 and corrects 1 error.

(7,4) cyclic code for data 1011

Given g(x)=x3+x2+1g(x)=x^3+x^2+1, n−k=3n-k=3. Convention: leftmost bit = highest power, so d(x)=x3+x+1d(x)=x^3+x+1. Modulo-2 arithmetic.

Non-systematic form: c(x)=d(x)g(x)c(x)=d(x)g(x)

c(x)=(x3+x+1)(x3+x2+1)=x6+x5+x3  +  x4+x3+x  +  x3+x2+1=x6+x5+x4+x3+x2+x+1\begin{aligned} c(x)&=(x^3+x+1)(x^3+x^2+1)\\ &=x^6+x^5+x^3\;+\;x^4+x^3+x\;+\;x^3+x^2+1\\ &=x^6+x^5+x^4+x^3+x^2+x+1 \end{aligned}

Non-systematic code vector: 1111111.

Systematic form:

  1. x3d(x)=x6+x4+x3x^3d(x)=x^6+x^4+x^3
  2. Divide by g(x)g(x):
              x^3 + x^2
          -------------------------
x^3+x^2+1 ) x^6 +     x^4 + x^3
            x^6 + x^5 +       x^3
            -----------------------
                  x^5 + x^4
                  x^5 + x^4 +       x^2
                  -------------------
                                    x^2
  1. Remainder p(x)=x2p(x)=x^2, parity bits =100= 100.
  2. c(x)=x6+x4+x3+x2c(x)=x^6+x^4+x^3+x^2.

Systematic code vector: 1011 100 (message, then parity).

Check: c(x)=(x3+x2)g(x)c(x)=(x^3+x^2)g(x), so c(x)c(x) is divisible by g(x)g(x) and is a valid codeword.

FormCode vectorWeight
Non-systematic11111117
Systematic10111004
  • Asked 2 times
  • 2072 Chaitra (CS II) · 2+4 marks
  • 2071 Chaitra (CS II) · 2+4 marks

Define Hamming weight and Hamming distance for a code vector x = (0111000) and the parity check matrix H given below. Prove that, the given code is valid. H = [1 1 1 0 1 0 0; 1 1 0 1 0 1 1; 1 0 1 1 0 0 1] (3×7)

Answer

Hamming weight

The Hamming weight w(x)w(\mathbf{x}) of a code vector is the number of 1s in it. For x=(0111000)\mathbf{x}=(0111000):

w(x)=0+1+1+1+0+0+0=3w(\mathbf{x})=0+1+1+1+0+0+0=3

Hamming distance

The Hamming distance between two code vectors is the number of positions in which they differ, d(x,y)=w(x⊕y)d(\mathbf{x},\mathbf{y})=w(\mathbf{x}\oplus\mathbf{y}). For example, distance of x\mathbf{x} from the all-zero codeword is d(0111000,0000000)=3d(0111000,0000000)=3, and from y=1111111\mathbf{y}=1111111 it is w(1000111)=4w(1000111)=4.

Proof that x is a valid codeword

A vector is a valid codeword of the code if and only if its syndrome is zero:

s=HxT=0(equivalently xHT=0)\mathbf{s}=H\mathbf{x}^T=\mathbf{0}\quad(\text{equivalently } \mathbf{x}H^T=\mathbf{0}) H=[111010011010111011001],xT=[0111000]H=\begin{bmatrix}1&1&1&0&1&0&0\\1&1&0&1&0&1&1\\1&0&1&1&0&0&1\end{bmatrix},\qquad \mathbf{x}^T=\begin{bmatrix}0\\1\\1\\1\\0\\0\\0\end{bmatrix}

Only positions 2, 3 and 4 of x\mathbf{x} are 1, so HxTH\mathbf{x}^T is the modulo-2 sum of columns 2, 3 and 4 of HH:

RowCol 2Col 3Col 4Sum (mod 2)
11101+1+0=01+1+0=0
21011+0+1=01+0+1=0
30110+1+1=00+1+1=0
s=HxT=[000]\mathbf{s}=H\mathbf{x}^T=\begin{bmatrix}0\\0\\0\end{bmatrix}

Since the syndrome is the zero vector, x=(0111000)\mathbf{x}=(0111000) satisfies all three parity-check equations. Hence the given code vector is valid.

  • 2081 Chaitra · 2+4+4 marks

A (6, 3) error control code has the following parity check matrix. H = [1 0 1 1 0 0; 1 1 0 0 1 0; 0 1 1 0 0 1] a) Determine the generator matrix G b) Generate a codeword for message 110 c) Check whether the received code word 110111 has error or not.

Answer

For a systematic (n,k)(n,k) linear block code, G=[Ik∣P]G=[I_k\mid P] and H=[PT∣In−k]H=[P^T\mid I_{n-k}], with GHT=0GH^T=0. A codeword is c=mG\mathbf{c}=\mathbf{m}G, and for a received vector r\mathbf{r} the syndrome is s=rHT\mathbf{s}=\mathbf{r}H^T. All arithmetic is modulo 2.

a) Generator matrix

H=[101100110010011001]=[PT∣I3],PT=[101110011]H=\begin{bmatrix}1&0&1&1&0&0\\1&1&0&0&1&0\\0&1&1&0&0&1\end{bmatrix}=[P^T\mid I_3],\qquad P^T=\begin{bmatrix}1&0&1\\1&1&0\\0&1&1\end{bmatrix}

Transposing:

P=[110011101],G=[I3∣P]=[100110010011001101]P=\begin{bmatrix}1&1&0\\0&1&1\\1&0&1\end{bmatrix},\qquad G=[I_3\mid P]=\begin{bmatrix}1&0&0&1&1&0\\0&1&0&0&1&1\\0&0&1&1&0&1\end{bmatrix}

b) Codeword for message 110

c=mG=1⋅(100110)⊕1⋅(010011)⊕0⋅(001101)=110101\mathbf{c}=\mathbf{m}G=1\cdot(100110)\oplus1\cdot(010011)\oplus0\cdot(001101)=110101

Parity bits directly: p1=m1⊕m3=1⊕0=1p_1=m_1\oplus m_3=1\oplus0=1, p2=m1⊕m2=1⊕1=0p_2=m_1\oplus m_2=1\oplus1=0, p3=m2⊕m3=1⊕0=1p_3=m_2\oplus m_3=1\oplus0=1.

Codeword = 110 101

Check: cHT\mathbf{c}H^T: row 1: 1+0+0+1=01+0+0+1=0, row 2: 1+1+0+0=01+1+0+0=0, row 3: 1+0+0+1=01+0+0+1=0. Syndrome 000000, so it is valid.

All codewords (for reference; dmin=3d_{min}=3, corrects 1 error):

m\mathbf{m}c\mathbf{c}m\mathbf{m}c\mathbf{c}
000000000100100110
001001101101101011
010010011110110101
011011110111111000

c) Check received word 110111

s=rHT,r=(1 1 0 1 1 1)\mathbf{s}=\mathbf{r}H^T,\quad \mathbf{r}=(1\,1\,0\,1\,1\,1)

Each syndrome bit is one row of HH dotted with r\mathbf{r}:

Row of HHProduct termsss
1 0 1 1 0 01+0+0+1+0+01+0+0+1+0+00
1 1 0 0 1 01+1+0+0+1+01+1+0+0+1+01
0 1 1 0 0 10+1+0+0+0+10+1+0+0+0+10
s=(0 1 0)≠0\mathbf{s}=(0\ 1\ 0)\neq\mathbf{0}

The syndrome is non-zero, so the received word has an error.

Locating it: s=010\mathbf{s}=010 equals the 5th column of HH (0,1,0)T(0,1,0)^T, so assuming a single error, bit 5 is wrong: e=000010\mathbf{e}=000010.

c^=r⊕e=110111⊕000010=110101\hat{\mathbf{c}}=\mathbf{r}\oplus\mathbf{e}=110111\oplus000010=110101

Answer: GG as above; codeword for 110 is 110101; received 110111 is in error (syndrome 010), corrected codeword 110101, message 110.

  • 2081 Chaitra · 5 marks

Write a short note on trellis diagram of a message 1010 using a ½ rate 3-state memory block convolutional encoder.

Answer

A trellis diagram is a time-expanded state diagram of a convolutional encoder. The encoder states (contents of the memory) are drawn as rows of nodes, time runs left to right, and each branch shows the transition caused by one input bit, labelled with the output bits. Each message traces one path through the trellis; the Viterbi decoder searches the trellis for the closest path.

Assumed encoder ("3-stage register" read as constraint length K=3K=3: present bit plus 2 memory flip-flops, so 22=42^2=4 states), rate 1/2, generators g(1)=111g^{(1)}=111, g(2)=101g^{(2)}=101:

c1=mi⊕mi−1⊕mi−2,c2=mi⊕mi−2c_1=m_i\oplus m_{i-1}\oplus m_{i-2},\qquad c_2=m_i\oplus m_{i-2}

States (mi−1mi−2)(m_{i-1}m_{i-2}): a = 00, b = 10, c = 01, d = 11.

Encoding 1010 (with two 0s to flush)

InputState beforeOutputState after
1a (00)11b (10)
0b (10)10c (01)
1c (01)00b (10)
0b (10)10c (01)
0 (flush)c (01)11a (00)
0 (flush)a (00)00a (00)

Encoded sequence: 11 10 00 10 11 00.

Trellis with the message path

      t0     t1     t2     t3     t4     t5     t6
a 00  *      o      o      o      o      *======*
        \                               /
           \                           /
b 10  o      *      o      *      o   /  o      o
               \         /   \      /
                  \   /         \  /
c 01  o      o      *      o      *      o      o


d 11  o      o      o      o      o      o      o
in:      1      0      1      0      0      0
out:    11     10     00     10     11     00

In the full trellis every state has two branches leaving it (input 0 and input 1). After K−1=2K-1=2 steps the pattern of branches repeats at every stage. The path marked with * (= for a horizontal branch) is the unique path for 1010; any received sequence is decoded by finding the path with minimum Hamming distance.

  • 2080 Chaitra · 8 marks

Determine the encoded sequence for the following input message (m₀, m₁, m₂, m₃, m₄) = (1 0 0 1 1) using convolutional encoder having shift registers with three flip flops. Draw state and trellis diagrams.

Answer

Assumption: the encoder is the standard rate-1/2 encoder with a three-stage shift register (present bit and two delay flip-flops, constraint length K=3K=3) and generator sequences g(1)=(1,1,1)g^{(1)}=(1,1,1), g(2)=(1,0,1)g^{(2)}=(1,0,1).

 Encoder: g1 = 111, g2 = 101 (K = 3, rate 1/2)

 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |          |           |
        +---(+)----+-----------+---> c1 = mi+mi-1+mi-2
        |                      |
        +---(+)----------------+---> c2 = mi+mi-2
            output per bit: c1 c2
ci(1)=mi⊕mi−1⊕mi−2,ci(2)=mi⊕mi−2c_i^{(1)}=m_i\oplus m_{i-1}\oplus m_{i-2},\qquad c_i^{(2)}=m_i\oplus m_{i-2}

Encoded sequence

Message (m0…m4)=10011(m_0\dots m_4)=10011, followed by two 0s to return the register to 00.

iimim_imi−1m_{i-1}mi−2m_{i-2}c(1)c^{(1)}c(2)c^{(2)}
010011
101010
200111
310011
411001
501101
600111

By polynomials: c(1)(D)=(1+D3+D4)(1+D+D2)=1+D+D2+D3+D6c^{(1)}(D)=(1+D^3+D^4)(1+D+D^2)=1+D+D^2+D^3+D^6 and c(2)(D)=(1+D3+D4)(1+D2)=1+D2+D3+D4+D5+D6c^{(2)}(D)=(1+D^3+D^4)(1+D^2)=1+D^2+D^3+D^4+D^5+D^6, which give the same bits.

Encoded sequence: 11 10 11 11 01 01 11

State diagram

State = previous two inputs (mi−1mi−2)(m_{i-1}m_{i-2}): a = 00, b = 10, c = 01, d = 11.

Present stateInputOutput c1c2c_1c_2Next state
a (00)000a (00)
a (00)111b (10)
b (10)010c (01)
b (10)101d (11)
c (01)011a (00)
c (01)100b (10)
d (11)001c (01)
d (11)110d (11)
            +--0/00--+
            v        |
          [ a 00 ]---+
           ^     \
      0/11 |      \ 1/11
           |       v
        [ c 01 ]<--0/10--[ b 10 ]
           |  ----1/00--->   |
           ^                 | 1/01
      0/01 |                 v
           +-------------[ d 11 ]--+
                            ^      | 1/10
                            +------+
 label = input/output bits

Trellis diagram

      t0     t1     t2     t3     t4     t5     t6     t7
a 00  *      o      o      *      o      o      o      *
        \                 /  \                        /
           \             /      \                    /
b 10  o      *      o   /  o      *      o      o   /  o
               \      /            \              /
                  \  /              \            /
c 01  o      o      *      o      o   \  o      *      o
                                       \      /
                                        \  /
d 11  o      o      o      o      o      *      o      o
in:      1      0      0      1      1      0      0
out:    11     10     11     11     01     01     11

At each stage every state has two branches (input 0 and 1) as in the table; the path for 10011 is marked with *. The output read along the path is 11 10 11 11 01 01 11.

  • 2079 Chaitra · 2+4+4 marks

Differentiate error-detection and error-correction. Design a convolutional encoder having code-rate of ½. Also, draw the code-tree and trellis diagram for the same assuming any three-bit input.

Answer

Error detection vs error correction

PointError detectionError correction
AimOnly finds that an error occurredFinds and fixes the error
RedundancyFew check bits (parity, CRC)More check bits
Action on errorRequest retransmission (ARQ)Corrected at receiver (FEC)
CapabilityDetects dmin−1d_{min}-1 errorsCorrects ⌊(dmin−1)/2⌋\lfloor (d_{min}-1)/2\rfloor
Return channelNeededNot needed
ExamplesParity, checksum, CRCHamming, BCH, convolutional

Rate-1/2 convolutional encoder (design)

Choose k=1k=1 input bit, n=2n=2 output bits (r=1/2r=1/2), constraint length K=3K=3 (two memory flip-flops, 4 states) and generators g(1)=111g^{(1)}=111, g(2)=101g^{(2)}=101.

 Encoder: g1 = 111, g2 = 101 (K = 3, rate 1/2)

 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |          |           |
        +---(+)----+-----------+---> c1 = mi+mi-1+mi-2
        |                      |
        +---(+)----------------+---> c2 = mi+mi-2
            output per bit: c1 c2

A commutator samples c1c_1 then c2c_2 for each input bit, so two bits go out for every bit in.

State = previous two inputs (mi−1mi−2)(m_{i-1}m_{i-2}): a = 00, b = 10, c = 01, d = 11.

Present stateInputOutput c1c2c_1c_2Next state
a (00)000a (00)
a (00)111b (10)
b (10)010c (01)
b (10)101d (11)
c (01)011a (00)
c (01)100b (10)
d (11)001c (01)
d (11)110d (11)

Code tree (three-bit input)

Upper branch = input 0, lower branch = input 1; labels are outputs.

                              00 a  (000)
                    00 a ---<
                   /          11 b  (001)
          00 a ---<
         /         \          10 c  (010)
        /           11 b ---<
       /                      01 d  (011)
 start<
       \                      11 a  (100)
        \           10 c ---<
         \         /          00 b  (101)
          11 b ---<
                   \          01 c  (110)
                    01 d ---<
                              10 d  (111)
   bit:    1          2          3

Read along a path: input 101 gives 11, 10, 00, i.e. root (down 11) to b, (up 10) to c, (down 00) to b.

Trellis diagram, input 101 (plus 00 to flush)

      t0     t1     t2     t3     t4     t5
a 00  *      o      o      o      o      *
        \                               /
           \                           /
b 10  o      *      o      *      o   /  o
               \         /   \      /
                  \   /         \  /
c 01  o      o      *      o      *      o


d 11  o      o      o      o      o      o
in:      1      0      1      0      0
out:    11     10     00     10     11

Encoded output for 101: 11 10 00 10 11. Every state in the full trellis has two outgoing branches; after the first two stages the trellis structure repeats.

  • 2078 Chaitra · 2+5 marks

Why convolution coder is better than block coder? Determine systematic and non-systematic code vector for a (7,4) cyclic hamming code for message vector {1011} with generator polynomial g(x) = 1 + X + X³.

Answer

Why a convolutional coder is better than a block coder

  • It works on a continuous stream, so no need to wait for a full block; encoding delay and buffering are small.
  • It has memory: each output depends on several past bits, so redundancy is spread over many bits and burst-like noise is handled better with interleaving.
  • Soft-decision Viterbi decoding is easy, giving 2 to 3 dB more coding gain than hard-decision block decoding at the same rate.
  • Simple shift-register encoder and good performance at low rates (used in GSM, satellite, Wi-Fi).

(7,4) cyclic Hamming code, g(x)=1+x+x3g(x)=1+x+x^3, message 1011

Convention (Haykin): message (m0m1m2m3)=1011(m_0m_1m_2m_3)=1011 in ascending powers, so

m(x)=1+x2+x3m(x)=1+x^2+x^3

Modulo-2 arithmetic.

Non-systematic: c(x)=m(x)g(x)c(x)=m(x)g(x)

c(x)=(1+x2+x3)(1+x+x3)=1+x+x3  +  x2+x3+x5  +  x3+x4+x6=1+x+x2+x3+x4+x5+x6\begin{aligned} c(x)&=(1+x^2+x^3)(1+x+x^3)\\ &=1+x+x^3\;+\;x^2+x^3+x^5\;+\;x^3+x^4+x^6\\ &=1+x+x^2+x^3+x^4+x^5+x^6 \end{aligned}

Non-systematic code vector (c0…c6)(c_0\dots c_6) = 1111111.

Systematic: c(x)=b(x)+xn−km(x)c(x)=b(x)+x^{n-k}m(x), with b(x)b(x) = remainder of x3m(x)/g(x)x^3m(x)/g(x).

x3m(x)=x3+x5+x6x^3m(x)=x^3+x^5+x^6
              x^3 + x^2 + x + 1
          ---------------------------
x^3+x+1 ) x^6 + x^5 +       x^3
          x^6 +       x^4 + x^3
          -------------------------
                x^5 + x^4
                x^5 +       x^3 + x^2
                -----------------------
                      x^4 + x^3 + x^2
                      x^4 +       x^2 + x
                      -------------------
                            x^3 +       x
                            x^3 +       x + 1
                            -----------------
                                          1

b(x)=1b(x)=1, so parity bits (b0b1b2)=100(b_0b_1b_2)=100.

c(x)=1+x3+x5+x6c(x)=1+x^3+x^5+x^6

Systematic code vector (b0b1b2 m0m1m2m3)(b_0b_1b_2\,m_0m_1m_2m_3) = 100 1011.

Check: c(x)=(1+x+x2+x3)g(x)c(x)=(1+x+x^2+x^3)g(x), which expands to 1+x3+x5+x61+x^3+x^5+x^6, so it is a valid codeword.

FormCode vector
Non-systematic1111111
Systematic1001011
  • 2081 Bhadra (CS II) · 2+6 marks

What is the significance of (dmin) minimum hamming distance? Determine the systematic and non-systematic code vector for a (7,4) cyclic code for message vector (m₀, m₁, m₂, m₃) = (1101) for a given generator polynomial g(x) = 1 + x + x².

Answer

Significance of dmind_{min}

The minimum Hamming distance dmind_{min} is the smallest number of positions in which any two codewords differ (for a linear code, the smallest non-zero codeword weight). It fixes the power of the code:

  • Detects up to ss errors if dmin≥s+1d_{min}\ge s+1.
  • Corrects up to tt errors if dmin≥2t+1d_{min}\ge 2t+1, i.e. t=⌊(dmin−1)/2⌋t=\lfloor(d_{min}-1)/2\rfloor.

For a (7,4) Hamming code dmin=3d_{min}=3: detects 2, corrects 1 error.

Note on the generator polynomial

A generator for a (7,4) cyclic code must have degree n−k=3n-k=3 and divide x7+1=(1+x)(1+x+x3)(1+x2+x3)x^7+1=(1+x)(1+x+x^3)(1+x^2+x^3). The printed g(x)=1+x+x2g(x)=1+x+x^2 has degree 2 and does not divide x7+1x^7+1, so it is taken as a misprint of the standard g(x)=1+x+x3g(x)=1+x+x^3.

Message (m0m1m2m3)=1101(m_0m_1m_2m_3)=1101, ascending powers:

m(x)=1+x+x3m(x)=1+x+x^3

Non-systematic code vector

c(x)=m(x)g(x)=(1+x+x3)(1+x+x3)=1+x2+x6(cross terms cancel in mod 2: (a+b+c)2=a2+b2+c2)\begin{aligned} c(x)&=m(x)g(x)=(1+x+x^3)(1+x+x^3)\\ &=1+x^2+x^6\quad(\text{cross terms cancel in mod 2: }(a+b+c)^2=a^2+b^2+c^2) \end{aligned}

(c0c1…c6)(c_0c_1\dots c_6) = 1010001

Systematic code vector

x3m(x)=x3+x4+x6x^3m(x)=x^3+x^4+x^6

Divide by g(x)=1+x+x3g(x)=1+x+x^3:

              x^3
          -----------------------
x^3+x+1 ) x^6 + x^4 + x^3
          x^6 + x^4 + x^3
          ---------------
                          0

Remainder b(x)=0b(x)=0, parity bits (b0b1b2)=000(b_0b_1b_2)=000.

c(x)=b(x)+x3m(x)=x3+x4+x6c(x)=b(x)+x^3m(x)=x^3+x^4+x^6

(b0b1b2 m0m1m2m3)(b_0b_1b_2\,m_0m_1m_2m_3) = 000 1101

This happens because m(x)m(x) itself equals g(x)g(x), so x3m(x)x^3m(x) is already a multiple of g(x)g(x).

FormCode vectorWeight
Non-systematic10100013
Systematic00011013

Both have weight 3, equal to dmind_{min} of the code.

  • 2081 Bhadra (CS II) · 4 marks

Write a short note on error detection and correction capability of a codeword.

Answer

The error detection and correction capability of a block code depends on its minimum Hamming distance dmind_{min}, the smallest number of bit positions in which any two codewords differ. For a linear code, dmind_{min} equals the smallest weight of a non-zero codeword.

Detection

If fewer than dmind_{min} bits are changed, a codeword cannot turn into another valid codeword, so the error is noticed:

s≤dmin−1s\le d_{min}-1

Correction

The decoder chooses the nearest codeword. This is always right if the received word is closer to the sent codeword than to any other, which needs

t≤⌊dmin−12⌋(dmin≥2t+1)t\le\left\lfloor\frac{d_{min}-1}{2}\right\rfloor\quad(d_{min}\ge 2t+1)

To correct tt and also detect s>ts>t errors: dmin≥t+s+1d_{min}\ge t+s+1.

  c1 o----x----x----o c2     d_min = 3
       radius t = 1 spheres do not overlap
Codedmind_{min}DetectsCorrects
Single parity210
(7,4) Hamming321
Repetition (3,1)321
Extended (8,4) Hamming431
(5,1) repetition542

Larger dmind_{min} needs more redundancy (lower code rate k/nk/n).

  • 2081 Baisakh (CS II) · 7 marks

Prove that (4,3) even parity code is a linear block code and (4,3) odd parity code is not a linear block code.

Answer

A block code is linear if (1) the all-zero word is a codeword and (2) the modulo-2 sum of any two codewords is also a codeword (closure). For binary codes, (2) implies (1) since c⊕c=0\mathbf{c}\oplus\mathbf{c}=\mathbf{0}.

A (4,3) parity code takes 3 message bits m1m2m3m_1m_2m_3 and adds one parity bit pp.

Even parity code is linear

p=m1⊕m2⊕m3p=m_1\oplus m_2\oplus m_3, so every codeword has an even number of 1s:

MessageCodewordMessageCodeword
00000001001001
00100111011010
01001011101100
01101101111111

General proof: let c1,c2\mathbf{c}_1,\mathbf{c}_2 be codewords, with weights w1,w2w_1,w_2 both even. Then

w(c1⊕c2)=w1+w2−2 w(c1⋅c2)w(\mathbf{c}_1\oplus\mathbf{c}_2)=w_1+w_2-2\,w(\mathbf{c}_1\cdot\mathbf{c}_2)

where c1⋅c2\mathbf{c}_1\cdot\mathbf{c}_2 counts positions where both are 1. Even + even − even = even, so the sum is again an even-weight 4-bit word, i.e. a codeword. Also 00000000 is a codeword.

Equivalently, the code can be generated by a matrix:

G=[100101010011],c=mGG=\begin{bmatrix}1&0&0&1\\0&1&0&1\\0&0&1&1\end{bmatrix},\qquad \mathbf{c}=\mathbf{m}G

and m1G⊕m2G=(m1⊕m2)G\mathbf{m}_1G\oplus\mathbf{m}_2G=(\mathbf{m}_1\oplus\mathbf{m}_2)G, which is a codeword.

Example: 0011⊕0101=01100011\oplus0101=0110 (codeword), 1001⊕1111=01101001\oplus1111=0110 (codeword). Hence the (4,3) even parity code is a linear block code.

Odd parity code is not linear

p=m1⊕m2⊕m3⊕1p=m_1\oplus m_2\oplus m_3\oplus1, so every codeword has an odd number of 1s:

MessageCodewordMessageCodeword
00000011001000
00100101011011
01001001101101
01101111111110
  1. The all-zero word 00000000 has even weight, so it is not a codeword.
  2. Closure fails: for odd w1,w2w_1,w_2, w1+w2−2(⋅)w_1+w_2-2(\cdot) is even, so the sum of two codewords always has even weight and is never a codeword. Example: 0001⊕0010=00110001\oplus0010=0011, weight 2, not in the code.

Hence the (4,3) odd parity code is not a linear block code.

  • 2076 Chaitra (CS II) · 8 marks

The 1/3 rate convolutional encoder with constraint length equal to 3 has following three generator sequences each of length 3. (g₀⁽¹⁾, g₁⁽¹⁾, g₂⁽¹⁾) = (0, 1, 1) (g₀⁽²⁾, g₁⁽²⁾, g₂⁽²⁾) = (1, 0, 1) (g₀⁽³⁾, g₁⁽³⁾, g₂⁽³⁾) = (1, 1, 0) Determine the encoded sequence for the following input message (m₀, m₁, m₂, m₃, m₄) = (1 0 0 1 1)

Answer

Rate 1/31/3: each input bit gives 3 output bits. Constraint length K=3K=3, so the register holds mi,mi−1,mi−2m_i,m_{i-1},m_{i-2}. Each output is the modulo-2 convolution of the input with its generator:

ci(j)=∑l=02gl(j)mi−l(mod2)c_i^{(j)}=\sum_{l=0}^{2}g_l^{(j)}m_{i-l}\pmod 2

With the given generators:

ci(1)=0⋅mi+mi−1+mi−2=mi−1⊕mi−2ci(2)=mi⊕mi−2ci(3)=mi⊕mi−1\begin{aligned} c_i^{(1)}&=0\cdot m_i+m_{i-1}+m_{i-2}=m_{i-1}\oplus m_{i-2}\\ c_i^{(2)}&=m_i\oplus m_{i-2}\\ c_i^{(3)}&=m_i\oplus m_{i-1} \end{aligned}
 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |           |           |
        |           +----(+)----+------> c1 = mi-1+mi-2
        +----------(+)----------+------> c2 = mi+mi-2
        +----(+)----+------------------> c3 = mi+mi-1
     commutator: c1 c2 c3 per input bit

Encoding

Message (m0…m4)=10011(m_0\dots m_4)=10011, then two 0s (K−1K-1) to flush the register. Register starts at 00.

iimim_imi−1m_{i-1}mi−2m_{i-2}c(1)c^{(1)}c(2)c^{(2)}c(3)c^{(3)}
0100011
1010101
2001110
3100011
4110110
5011011
6001110

Check by polynomial (transform-domain) method

m(D)=1+D3+D4m(D)=1+D^3+D^4; g(1)(D)=D+D2g^{(1)}(D)=D+D^2, g(2)(D)=1+D2g^{(2)}(D)=1+D^2, g(3)(D)=1+Dg^{(3)}(D)=1+D.

c(1)(D)=(1+D3+D4)(D+D2)=D+D2+D4+D6 ⇒0110101c(2)(D)=(1+D3+D4)(1+D2)=1+D2+D3+D4+D5+D6 ⇒1011111c(3)(D)=(1+D3+D4)(1+D)=1+D+D3+D5 ⇒1101010\begin{aligned} c^{(1)}(D)&=(1+D^3+D^4)(D+D^2)=D+D^2+D^4+D^6\ \Rightarrow 0110101\\ c^{(2)}(D)&=(1+D^3+D^4)(1+D^2)=1+D^2+D^3+D^4+D^5+D^6\ \Rightarrow 1011111\\ c^{(3)}(D)&=(1+D^3+D^4)(1+D)=1+D+D^3+D^5\ \Rightarrow 1101010 \end{aligned}

Interleaving the three sequences bit by bit gives the same result.

Encoded sequence: 011 101 110 011 110 011 110 (21 bits; the first 15 bits, 011 101 110 011 110, correspond to the message itself and the last 6 come from flushing.)

  • 2075 Chaitra (CS II) · 2+5 marks

Define hamming distance and hamming weight. For a (6,3) code, the parity check matrix is given by H = [1 0 1 _ 0 0; 0 1 1 _ 1 0; 1 1 0 _ 0 1] (as printed, one column of H is blank; it is most likely H = [1 0 1 1 0 0; 0 1 1 0 1 0; 1 1 0 0 0 1]). Determine whether a received code vector 100101 is erroneous.

Answer

Hamming weight

The Hamming weight of a code vector is the number of 1s in it. Example: w(100101)=3w(100101)=3.

Hamming distance

The Hamming distance between two vectors is the number of positions where they differ, d(x,y)=w(x⊕y)d(\mathbf{x},\mathbf{y})=w(\mathbf{x}\oplus\mathbf{y}). Example: d(100101,101011)=w(001110)=3d(100101,101011)=w(001110)=3.

Checking the received vector

The printed HH has a blank column; it is taken as the standard systematic form H=[PT∣I3]H=[P^T\mid I_3]:

H=[101100011010110001]H=\begin{bmatrix}1&0&1&1&0&0\\0&1&1&0&1&0\\1&1&0&0&0&1\end{bmatrix}

A received vector r\mathbf{r} is error-free (a valid codeword) if its syndrome s=rHT\mathbf{s}=\mathbf{r}H^T is zero.

r=(1 0 0 1 0 1)\mathbf{r}=(1\,0\,0\,1\,0\,1): the 1s are in positions 1, 4 and 6, so s\mathbf{s} is the mod-2 sum of columns 1, 4 and 6 of HH:

RowCol 1Col 4Col 6Sum
11100
20000
31010
s=rHT=(0 0 0)\mathbf{s}=\mathbf{r}H^T=(0\ 0\ 0)

The syndrome is zero, so 100101 is a valid codeword (not erroneous), assuming no undetectable error pattern.

Check with the generator matrix G=[I3∣P]G=[I_3\mid P]:

G=[100101010011001110]G=\begin{bmatrix}1&0&0&1&0&1\\0&1&0&0&1&1\\0&0&1&1&1&0\end{bmatrix}

Message 100 gives c=100 101\mathbf{c}=100\,101, exactly the received vector. Message = 100.

(If a syndrome were non-zero, matching it to a column of HH would locate a single-bit error; this code has dmin=3d_{min}=3.)

  • 2075 Asoj (CS II) · 8 marks

The generator polynomial of a (7,4) cyclic code is G(p) = p³ + p + 1. Obtain the code vector for the code in non-systematic and systematic form with message vector 0101.

Answer

A cyclic code is a linear block code in which every cyclic shift of a codeword is also a codeword. An (n,k)(n,k) cyclic code is generated by a polynomial G(p)G(p) of degree n−kn-k that divides pn+1p^n+1:

  • Non-systematic encoding: X(p)=M(p) G(p)X(p)=M(p)\,G(p); message bits are not visible directly in the codeword.
  • Systematic encoding: X(p)=pn−kM(p)+rem[pn−kM(p)G(p)]X(p)=p^{n-k}M(p)+\text{rem}\left[\dfrac{p^{n-k}M(p)}{G(p)}\right]; the message appears unchanged and the remainder gives the n−kn-k parity bits.

Given (n,k)=(7,4)(n,k)=(7,4), G(p)=p3+p+1G(p)=p^3+p+1, n−k=3n-k=3. Convention: leftmost message bit is the highest power. Message 01010101:

M(p)=0⋅p3+1⋅p2+0⋅p+1=p2+1M(p)=0\cdot p^3+1\cdot p^2+0\cdot p+1=p^2+1

All additions are modulo 2.

Non-systematic form

X(p)=M(p) G(p)=(p2+1)(p3+p+1)=p5+p3+p2+p3+p+1=p5+p2+p+1\begin{aligned} X(p)&=M(p)\,G(p)=(p^2+1)(p^3+p+1)\\ &=p^5+p^3+p^2+p^3+p+1\\ &=p^5+p^2+p+1 \end{aligned}

Coefficients from p6p^6 down to p0p^0:

p6p^6p5p^5p4p^4p3p^3p2p^2p1p^1p0p^0
0100111

Non-systematic code vector: 0100111

Systematic form

  1. Multiply by pn−k=p3p^{n-k}=p^3: p3M(p)=p5+p3p^3M(p)=p^5+p^3.
  2. Divide by G(p)G(p):
              p^2
            -----------------
 p^3+p+1 )  p^5 +       p^3
            p^5 +       p^3 + p^2
            ---------------------
                              p^2   <- remainder
  1. Remainder C(p)=p2C(p)=p^2, so parity bits (p2,p1,p0)=100(p^2,p^1,p^0)=100.
  2. X(p)=p3M(p)+C(p)=p5+p3+p2X(p)=p^3M(p)+C(p)=p^5+p^3+p^2.

Check: X(p)=p2 G(p)=p5+p3+p2X(p)=p^2\,G(p)=p^5+p^3+p^2, a multiple of G(p)G(p).

Systematic code vector: 0101 100 (message bits, then check bits)

FormCode vector
Non-systematic0100111
Systematic0101100
  • 2074 Chaitra (CS II) · 2+6 marks

Define Hamming distance and Hamming weight. Explain the operation a 1/3 convolutional encoder.

Answer

Hamming weight and distance

  • Hamming weight w(c)w(\mathbf{c}): number of 1s in a code vector. w(1101001)=4w(1101001)=4.
  • Hamming distance d(c1,c2)d(\mathbf{c}_1,\mathbf{c}_2): number of positions in which two vectors differ, =w(c1⊕c2)=w(\mathbf{c}_1\oplus\mathbf{c}_2). d(1101001,1001011)=w(0100010)=2d(1101001,1001011)=w(0100010)=2.

The minimum distance dmind_{min} of a code decides that it detects dmin−1d_{min}-1 and corrects ⌊(dmin−1)/2⌋\lfloor(d_{min}-1)/2\rfloor errors.

Rate-1/3 convolutional encoder

A rate-1/3 convolutional encoder produces 3 output bits for every input bit. It uses a shift register of length KK (constraint length), three modulo-2 adders and a commutator. Example with K=3K=3 and generators g(1)=100g^{(1)}=100, g(2)=101g^{(2)}=101, g(3)=111g^{(3)}=111:

 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |           |           |
        +-----------------------------> c1 = mi
        +----------(+)----------+-----> c2 = mi+mi-2
        +----(+)----+----(+)----+-----> c3 = mi+mi-1+mi-2
           commutator reads c1, c2, c3 in turn

Operation:

  1. The register starts cleared (00).
  2. A message bit enters stage 1; older bits shift right.
  3. Each adder forms the mod-2 sum of the stages connected to it (taps given by its generator).
  4. The commutator sends c1c2c3c_1c_2c_3, so the output rate is three times the input rate (r=1/3r=1/3).
  5. After the message, K−1=2K-1=2 zeros flush the register back to 00.

Example: input 101

mim_iRegister (mi,mi−1,mi−2)(m_i,m_{i-1},m_{i-2})c1c2c3c_1c_2c_3
11 0 0111
00 1 0001
11 0 1100
0 (flush)0 1 0001
0 (flush)0 0 1011

Output: 111 001 100 001 011.

The encoder has 2K−1=42^{K-1}=4 states; its behaviour can be shown by a code tree, state diagram or trellis, and it is decoded with the Viterbi algorithm. The low rate gives a large free distance and strong error correction, at the cost of three times the bandwidth.

  • 2073 Shrawan (CS II) · 3+4 marks

Define Hamming weight and Hamming distance with examples. Validate the code if received code vector code is [100011] given that H = [1 0 1 1 0 0; 0 1 1 0 1 0; 1 1 0 0 0 1].

Answer

Hamming weight

The Hamming weight w(c)w(\mathbf{c}) is the number of non-zero elements in a code vector.

Example: w(101011)=4w(101011)=4, w(100011)=3w(100011)=3.

Hamming distance

The Hamming distance d(c1,c2)d(\mathbf{c}_1,\mathbf{c}_2) is the number of positions in which two code vectors differ, d=w(c1⊕c2)d=w(\mathbf{c}_1\oplus\mathbf{c}_2).

Example: c1=101011\mathbf{c}_1=101011, c2=100011\mathbf{c}_2=100011, c1⊕c2=001000\mathbf{c}_1\oplus\mathbf{c}_2=001000, so d=1d=1.

Validating the received vector

A received vector is a valid codeword only if the syndrome s=rHT=0\mathbf{s}=\mathbf{r}H^T=\mathbf{0}.

H=[101100011010110001],r=(1 0 0 0 1 1)H=\begin{bmatrix}1&0&1&1&0&0\\0&1&1&0&1&0\\1&1&0&0&0&1\end{bmatrix},\qquad \mathbf{r}=(1\,0\,0\,0\,1\,1)

The 1s of r\mathbf{r} are at positions 1, 5, 6, so add columns 1, 5 and 6 of HH:

RowCol 1Col 5Col 6Sum (mod 2)
11001
20101
31010
s=(1 1 0)≠0\mathbf{s}=(1\ 1\ 0)\neq\mathbf{0}

The received vector 100011 is not a valid codeword; it contains an error.

Correction (single error)

The syndrome 110110 matches column 3 of HH (1,1,0)T(1,1,0)^T, so the 3rd bit is in error: e=001000\mathbf{e}=001000.

c^=r⊕e=100011⊕001000=101011\hat{\mathbf{c}}=\mathbf{r}\oplus\mathbf{e}=100011\oplus001000=101011

Check: columns 1, 3, 5, 6 sum to (1+1+0+0, 0+1+1+0, 1+0+0+1)=(0,0,0)(1+1+0+0,\ 0+1+1+0,\ 1+0+0+1)=(0,0,0), so 101011 is valid. Corrected message (first 3 bits): 101.

  • 2073 Chaitra (CS II) · 2+6 marks

Why convolution coder are better suited than block coder? Determine systematic and non-systematic code vector for a (7,4) cyclic hamming code for message vector {1010} with generator polynomial g(x) = 1 + x + x³

Answer

Why convolutional coders are better suited than block coders

  • Continuous operation: they encode a serial bit stream directly; block coders must wait for kk bits, adding delay and buffering.
  • Memory: each output depends on the present and K−1K-1 previous bits, so redundancy is spread over a long span, giving good performance against random noise.
  • Soft-decision decoding: the Viterbi algorithm easily uses soft (analog) values, giving about 2 dB extra gain, which is hard for algebraic block decoders.
  • Simple hardware: shift registers and XOR gates; widely used in satellite, GSM and Wi-Fi links.

(7,4) cyclic Hamming code, g(x)=1+x+x3g(x)=1+x+x^3, message 1010

Convention (Haykin): (m0m1m2m3)=1010(m_0m_1m_2m_3)=1010, ascending powers:

m(x)=1+x2m(x)=1+x^2

Non-systematic:

c(x)=m(x)g(x)=(1+x2)(1+x+x3)=1+x+x3+x2+x3+x5=1+x+x2+x5\begin{aligned} c(x)&=m(x)g(x)=(1+x^2)(1+x+x^3)\\ &=1+x+x^3+x^2+x^3+x^5\\ &=1+x+x^2+x^5 \end{aligned}

(c0c1…c6)(c_0c_1\dots c_6) = 1110010

Systematic:

  1. xn−km(x)=x3(1+x2)=x3+x5x^{n-k}m(x)=x^3(1+x^2)=x^3+x^5
  2. Divide by g(x)g(x):
              x^2
          ------------------
x^3+x+1 ) x^5 +       x^3
          x^5 +       x^3 + x^2
          ---------------------
                            x^2   <- remainder
  1. b(x)=x2b(x)=x^2, parity bits (b0b1b2)=001(b_0b_1b_2)=001.
  2. c(x)=b(x)+x3m(x)=x2+x3+x5c(x)=b(x)+x^3m(x)=x^2+x^3+x^5.

(b0b1b2 m0m1m2m3)(b_0b_1b_2\,m_0m_1m_2m_3) = 001 1010

Check: c(x)=x2g(x)=x2+x3+x5c(x)=x^2g(x)=x^2+x^3+x^5, divisible by g(x)g(x), so valid.

FormCode vector
Non-systematic1110010
Systematic0011010
  • 2072 Kartik (CS II) · 6 marks

Explain Convolutional Coder with suitable example.

Answer

A convolutional coder is a forward error-correcting encoder with memory. It passes the message bits through a shift register and forms output bits as modulo-2 sums of selected stages, so each output depends on the present bit and the previous K−1K-1 bits. With kk inputs and nn outputs per step, the code rate is r=k/nr=k/n; KK is the constraint length.

Example: rate 1/2, K = 3

Generators g(1)=(1,1,1)g^{(1)}=(1,1,1), g(2)=(1,0,1)g^{(2)}=(1,0,1):

ci(1)=mi⊕mi−1⊕mi−2,ci(2)=mi⊕mi−2c_i^{(1)}=m_i\oplus m_{i-1}\oplus m_{i-2},\qquad c_i^{(2)}=m_i\oplus m_{i-2}
 Encoder: g1 = 111, g2 = 101 (K = 3, rate 1/2)

 m -->[ m_i ]-->[ m_i-1 ]-->[ m_i-2 ]
        |          |           |
        +---(+)----+-----------+---> c1 = mi+mi-1+mi-2
        |                      |
        +---(+)----------------+---> c2 = mi+mi-2
            output per bit: c1 c2

Encoding message 1001110011 (plus 00 to flush):

mim_i(mi−1mi−2)(m_{i-1}m_{i-2}) beforec(1)c(2)c^{(1)}c^{(2)}
10011
01010
00111
10011
11001
01101
00111

Output: 11 10 11 11 01 01 11.

Representations

  • Code tree: each input bit splits a branch (up = 0, down = 1), labelled with output bits.
  • State diagram: 4 states (a = 00, b = 10, c = 01, d = 11), e.g. a goes to b with output 11 on input 1.
  • Trellis: the state diagram drawn over time; used by the decoder.

Decoding

The Viterbi algorithm compares the received sequence with every trellis path, keeps the best (minimum distance) path into each state, and outputs the survivor; it is a maximum-likelihood decoder. The free distance of this code is dfree=5d_{free}=5, so it can correct 2 errors within a short span.

  • 2071 Shrawan (CS II) · 2+5 marks

What is the importance of hamming distance and hamming weight in coding theory? Explain with example the syndrome decoding method in linear block coding.

Answer

Importance of Hamming distance and weight

  • Hamming weight (number of 1s) and Hamming distance (number of differing positions) measure how far codewords are apart.
  • For a linear code, minimum distance dmind_{min} = minimum non-zero weight, so it is found easily.
  • dmind_{min} fixes the power of the code: detects dmin−1d_{min}-1 errors and corrects ⌊(dmin−1)/2⌋\lfloor(d_{min}-1)/2\rfloor.
  • Decoders choose the codeword at minimum Hamming distance from the received word (maximum-likelihood for a binary symmetric channel).

Syndrome decoding in linear block codes

For a code with generator G=[Ik∣P]G=[I_k\mid P] and parity-check matrix H=[PT∣In−k]H=[P^T\mid I_{n-k}], every codeword satisfies cHT=0\mathbf{c}H^T=\mathbf{0}. A received word is r=c⊕e\mathbf{r}=\mathbf{c}\oplus\mathbf{e}, where e\mathbf{e} is the error pattern. The syndrome is

s=rHT=cHT⊕eHT=eHT\mathbf{s}=\mathbf{r}H^T=\mathbf{c}H^T\oplus\mathbf{e}H^T=\mathbf{e}H^T

so it depends only on the error, not on the sent codeword.

Steps:

  1. Compute s=rHT\mathbf{s}=\mathbf{r}H^T.
  2. If s=0\mathbf{s}=\mathbf{0}, accept r\mathbf{r} as the codeword.
  3. Otherwise look up the coset leader (most likely error pattern, usually single-bit) with that syndrome; for a single error in bit ii, s\mathbf{s} equals the ii-th column of HH.
  4. Correct: c^=r⊕e\hat{\mathbf{c}}=\mathbf{r}\oplus\mathbf{e}.

Example: (6,3) code

H=[101100011010110001]H=\begin{bmatrix}1&0&1&1&0&0\\0&1&1&0&1&0\\1&1&0&0&0&1\end{bmatrix}

Syndrome table (single errors):

Error patternSyndrome
000000000
100000101
010000011
001000110
000100100
000010010
000001001

Message 101 gives codeword c=101011\mathbf{c}=101011. Suppose r=100011\mathbf{r}=100011 (bit 3 flipped).

s=rHT=col1⊕col5⊕col6=(1,0,1)⊕(0,1,0)⊕(0,0,1)=(1,1,0)\mathbf{s}=\mathbf{r}H^T=\text{col}_1\oplus\text{col}_5\oplus\text{col}_6=(1,0,1)\oplus(0,1,0)\oplus(0,0,1)=(1,1,0)

From the table, e=001000\mathbf{e}=001000, so c^=100011⊕001000=101011\hat{\mathbf{c}}=100011\oplus001000=101011, message 101 recovered.

  • 2070 Asar (CS II) · 2 marks

Define Hamming Weight and Hamming Distance.

Answer

  • Hamming weight w(c)w(\mathbf{c}): the number of non-zero (1) bits in a code vector. Example: w(1011001)=4w(1011001)=4.
  • Hamming distance d(c1,c2)d(\mathbf{c}_1,\mathbf{c}_2): the number of bit positions in which two code vectors of the same length differ; d(c1,c2)=w(c1⊕c2)d(\mathbf{c}_1,\mathbf{c}_2)=w(\mathbf{c}_1\oplus\mathbf{c}_2). Example: c1=1011001\mathbf{c}_1=1011001, c2=1001011\mathbf{c}_2=1001011; c1⊕c2=0010010\mathbf{c}_1\oplus\mathbf{c}_2=0010010, so d=2d=2.

The smallest distance between any pair of codewords, dmind_{min}, sets the error capability: a code detects dmin−1d_{min}-1 errors and corrects ⌊(dmin−1)/2⌋\lfloor(d_{min}-1)/2\rfloor errors.

  • 2070 Chaitra (CS II) · 6 marks

The generator polynomial of a (7,4) cyclic code is g(x) = 1 + x + x³. Find the code for the message vector 1011 in a non-systematic and systematic form.

Answer

A cyclic code is a linear block code in which every cyclic shift of a codeword is also a codeword. An (n,k)(n,k) cyclic code is generated by a polynomial g(x)g(x) of degree n−kn-k that divides xn+1x^n+1:

  • Non-systematic encoding: c(x)=m(x) g(x)c(x)=m(x)\,g(x); message bits are not visible directly in the codeword.
  • Systematic encoding: c(x)=xn−km(x)+rem[xn−km(x)g(x)]c(x)=x^{n-k}m(x)+\text{rem}\left[\dfrac{x^{n-k}m(x)}{g(x)}\right]; the message appears unchanged and the remainder gives the n−kn-k parity bits.

Given (n,k)=(7,4)(n,k)=(7,4), g(x)=1+x+x3g(x)=1+x+x^3, n−k=3n-k=3. Convention (Haykin): message (m0m1m2m3)=1011(m_0m_1m_2m_3)=1011 in ascending powers of xx:

m(x)=1+x2+x3m(x)=1+x^2+x^3

All arithmetic is modulo 2.

Non-systematic form

c(x)=m(x)g(x)=(1+x2+x3)(1+x+x3)=(1+x+x3)+(x2+x3+x5)+(x3+x4+x6)=1+x+x2+x3+x4+x5+x6\begin{aligned} c(x)&=m(x)g(x)=(1+x^2+x^3)(1+x+x^3)\\ &=(1+x+x^3)+(x^2+x^3+x^5)+(x^3+x^4+x^6)\\ &=1+x+x^2+x^3+x^4+x^5+x^6 \end{aligned}

(x3x^3 appears three times, leaving x3x^3.)

Non-systematic code vector (c0…c6)(c_0\dots c_6) = 1111111

Systematic form

  1. xn−km(x)=x3+x5+x6x^{n-k}m(x)=x^3+x^5+x^6
  2. Divide by g(x)=x3+x+1g(x)=x^3+x+1:
              x^3 + x^2 + x + 1
          ---------------------------
x^3+x+1 ) x^6 + x^5 +       x^3
          x^6 +       x^4 + x^3
          -------------------------
                x^5 + x^4
                x^5 +       x^3 + x^2
                -----------------------
                      x^4 + x^3 + x^2
                      x^4 +       x^2 + x
                      -------------------
                            x^3 +       x
                            x^3 +       x + 1
                            -----------------
                                          1
  1. Remainder b(x)=1b(x)=1, parity bits (b0b1b2)=100(b_0b_1b_2)=100.
  2. c(x)=b(x)+x3m(x)=1+x3+x5+x6c(x)=b(x)+x^3m(x)=1+x^3+x^5+x^6.

Check: quotient × g(x)=(1+x+x2+x3)(1+x+x3)=1+x3+x5+x6\times\,g(x)=(1+x+x^2+x^3)(1+x+x^3)=1+x^3+x^5+x^6. Valid.

Systematic code vector (b0b1b2 m0m1m2m3)(b_0b_1b_2\,m_0m_1m_2m_3) = 100 1011

FormCode vector
Non-systematic1111111
Systematic1001011
  • 2069 Chaitra (CS II) · 4 marks

Write a short note on syndrome calculation in linear systematic block code.

Answer

In a linear systematic (n,k)(n,k) block code, G=[Ik∣P]G=[I_k\mid P] and the parity-check matrix is H=[PT∣In−k]H=[P^T\mid I_{n-k}], so every codeword obeys cHT=0\mathbf{c}H^T=\mathbf{0}. The syndrome of a received vector r\mathbf{r} is the (n−k)(n-k)-bit vector

s=rHT\mathbf{s}=\mathbf{r}H^T

Properties

  • Writing r=c⊕e\mathbf{r}=\mathbf{c}\oplus\mathbf{e}: s=eHT\mathbf{s}=\mathbf{e}H^T, i.e. it depends only on the error pattern.
  • s=0\mathbf{s}=\mathbf{0}: no detectable error. s≠0\mathbf{s}\neq\mathbf{0}: error present.
  • For a single error in bit ii, s\mathbf{s} = ii-th column of HH, so the error is located directly.
  • All error patterns in one coset of the standard array share one syndrome; the coset leader is taken as the error.

Calculation

In systematic form, s\mathbf{s} = (parity bits recomputed from the received message bits) ⊕\oplus (received parity bits).

 r = [ received msg | received parity ]
         |                 |
   [recompute parity]      |
         |                 |
         +------(XOR)------+--> syndrome s

Example, (6,3)(6,3) code with H=[101100011010110001]H=\begin{bmatrix}1&0&1&1&0&0\\0&1&1&0&1&0\\1&1&0&0&0&1\end{bmatrix} and r=100011\mathbf{r}=100011:

s=col1⊕col5⊕col6=(1,1,0)\mathbf{s}=\text{col}_1\oplus\text{col}_5\oplus\text{col}_6=(1,1,0)

This equals column 3, so bit 3 is wrong; corrected word 101011. For cyclic codes, the syndrome is the remainder of r(x)/g(x)r(x)/g(x), computed with a shift register.

Questions from Old Question Collection (BEI EX 656) (BEI Communication Systems (EX 656) exam papers, 2078 to 2081 Chaitra), Communication System I (EX 652) (BEX Communication System I (EX 652) papers 2064 to 2080, plus two old BCT Communication Systems papers (2068, 2071)) and Communication System II (EX 702) (BEX Communication System II (EX 702) exam papers, 2069 to 2081). Answers are written for this site; check them against your class notes.

Chapter titles and hours from the IOE syllabus ↗