stanford coding theory

Upload: sandipg

Post on 05-Apr-2018

244 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Stanford Coding Theory

    1/24

    EE 387, John Gill, Stanford University Notes #5, October 22, Handout #15

    Cyclic codes: overview

    A linear block code is called cyclic if every cyclic shift of a codeword is a codeword.

    Cyclic codes have many advantages.

    Elegant algebraic descriptions:

    c(x) = m(x)g(x) , where g(x) is generator polynomial

    c(x)h(x) = 0 mod (xn 1) , where h(x) is parity-check polynomial

    c(1) = 0, . . . , c(t) = 0 , where i GF(qm)

    Shift register encoders and syndrome units

    Simple burst error correction (error trapping)

    Random error correction by solving polynomial equationsCyclic codes are (by definition) a very special case of linear codes.

    But nearly all commonly used block codes are (shortened) cyclic codes.

    EE 387 Notes #5, Page 1

    Cyclic shifts of n-tuples and polynomials

    Definition: The right cyclic shift of (v0, v1, . . . , vn1) is (vn1, v0, . . . , vn2) .

    CLK

    D QQ D QQ D QQ D QQ D QQ D QQ D QQ

    The right cyclic shift of v is denoted by v(1).

    When n-tuples are polynomials of degree n 1, the right cyclic shift of

    v(x) = (v0, v1, . . . , vn2, vn1)

    = v0 + v1x + + vn2xn2 + vn1xn1

    is also a polynomial of degree n 1:

    v(1)(x) = (vn1, v0, v1, . . . , vn2)

    = vn1 + v0x + v1x2 + + vn2x

    n1

    The right cyclic shift of v = v(x) by i positions is denoted by v(i) = v(i)(x) .

    EE 387 Notes #5, Page 2

  • 7/31/2019 Stanford Coding Theory

    2/24

    Properties of cyclic shifts

    Some obvious facts about cyclic shifts of n-tuples:

    v(n) = v.

    Left cyclic shift i positions v(i) is same as right cyclic shift v(ni).

    v(i) = v(i mod n).

    The first two statements are special cases of the third.

    The right cyclic shift operation is a linear transformation v(1) = vS1, where S1 isthe permutation matrix

    S1 =

    0 1 0 00 0 1 0... ... ... . . . ...0 0 0 1

    1 0 0 0

    .

    Every linear feedback shift register corresponds to a matrix in rational canonicalform. The cyclic register is the simplest feedback shift register.

    EE 387 Notes #5, Page 3

    Numbers vs. polynomials

    When binary n-tuples represent integers, bit shifts perform multiplication anddivision by powers of 2.

    Logical left shift is multiplication by 2.

    Logical right shift is unsigned division by 2.

    Cyclic left and rights shifts are multiplication and division by 2 mod 2n 1.

    When n-tuples represent polynomials over a field, cyclic shifts correspond tomultiplication and division by powers of x mod (xn 1).

    We write polynomials with the most significant coefficients on the right.

    (v0, v1, . . . , vn1) v0 + v1x + + vn1xn1

    Cyclic right shifts are multiplication by x, except coefficient of xn becomescoefficient of x0 = 1.

    Thus the right cyclic shift differs from product with x by a multiple of xn 1.

    EE 387 Notes #5, Page 4

  • 7/31/2019 Stanford Coding Theory

    3/24

    Polynomial description of cyclic shifts

    Lemma: The right cyclic shift of v(x) is

    v(1)(x) = xv(x) vn1(xn 1)

    = xv(x) mod (xn 1) .

    Proof: By the definition of right cyclic shift,

    v(1)(x) = vn1 + v0x + + vn2xn1

    = vn1 + v0x + + vn2xn1 + vn1x

    n vn1xn

    = xv(x) vn1(xn 1)

    = xv(x) mod (xn 1)

    When vn1 = 0, the right cyclic shift is same as the right logical shift:

    vn1 = 0 v(1)(x) = xv(x)

    EE 387 Notes #5, Page 5

    Cyclic codes: definition and basic properties

    Definition: A cyclic code is a linear block code such that the right cyclic shift ofany codeword is a codeword.

    By iteration, all cyclic shifts of codewords are codewords; thus the right cyclic shifti positions of any codeword c(x) is a codeword:

    c(i)(x) = xic(x) mod (xn 1)

    Since cyclic codes are linear, sums of cyclic shifts are codewords; thus for anypolynomial a(x) = a0 + a1x + + amx

    m,

    a(x)c(x) mod (xn

    1) =

    mi=0

    aix

    i

    c(x) mod (xn

    1)

    is a codeword. Important special case: deg a(x) < ndeg c(x). Then

    deg a(x)c(x) < n a(x)c(x) mod (xn 1) = a(x)c(x) .

    Therefore a(x)c(x) is a codeword.

    EE 387 Notes #5, Page 6

  • 7/31/2019 Stanford Coding Theory

    4/24

    Generator polynomial

    Theorem: Let C be an (n, k) cyclic code over GF(q).

    1. There exists a monic polynomial g(x), called the generator polynomial, suchthat n-tuple c(x) is a codeword if and only if g(x) is a divisor of c(x).

    2. The generator polynomial is unique.

    3. The degree of the generator polynomial is n k.

    4. The generator polynomial is a divisor ofxn 1.

    Proof: When k = 0 we can take g(x) = xn 1.

    In this case all the statements are obviously true.

    So assume k > 0 and therefore n k < n.

    xn 1 is called the cyclic polynomial of degree n. The zero polynomial is the only polynomial of degree < n that isdivisible by xn 1. So xn 1 generates the code consisting of only the zero vector.

    EE 387 Notes #5, Page 7

    Generator polynomial proof (1)

    1. Let g(x) be the monic greatest common divisor of {ci(x)}, the set of nonzerocodewords. Then there exist polynomials {ai(x)} such that

    g(x) =

    i

    ai(x)ci(x)

    =

    i

    ai(x)ci(x)

    mod (xn 1) since deg g(x) < n

    =

    i

    ai(x)ci(x) mod (x

    n 1)

    The final expression shows that g(x) is a linear combination of codewords and istherefore a codeword that is a divisor of all other codewords.

    2. If there were two generator polynomials, each would be a divisor of the other,and since both are monic, the ratio is 1.

    EE 387 Notes #5, Page 8

  • 7/31/2019 Stanford Coding Theory

    5/24

    Generator polynomial proof (2)

    3. Let r = deg g(x).

    If deg m(x) < n r then deg m(x)g(x) < n, so m(x)g(x) is a codeword.

    Conversely, every codeword is c(x) = m(x)g(x) where deg m(x) < n r.

    So there are qnr

    codewords. An (n, k) code over GF(q) has qk

    codewords.Therefore qnr = qk n r = k r = n k .

    4. (Cute trick.) The right cyclic shift of g(x) by k digits is a codeword:

    g(k)(x) = (1, 0, . . . , 0, g0, g1, . . . , gnk1)

    = 1 + g0xk + g1x

    k+1 + + gnk1xn1 + xn xn

    = xkg(x) (xn 1)

    Therefore

    xn 1 = xkg(x) g(k)(x)

    is a sum of multiples of g(x) and so itself is a multiple of g(x).

    EE 387 Notes #5, Page 9

    Nonsystematic generator matrix

    Let C be an (n, k) cyclic code generated by g(x) of degree r = n k.Codewords xig(x) (i = 0, 1, . . . , k 1) form a basis for C, since every codeword

    m(x)g(x) = m0g(x) + m1xg(x) + + mk1xk1g(x)

    is a linear combination of xig(x).

    Matrix with rows xig(x) is a nonsystematic generator matrix for C.

    G1 =

    g(x)xg(x)

    ..

    .xk2g(x)

    xk1g(x)

    =

    g0 g1 gr 0 0 00 g0 g1 gr 0 0...

    .

    .. . . . . . . . . . . . ....

    0 0 0 g0 g1 gr 00 0 0 0 g0 g1 gr

    Every row of G1 is a right (cyclic) shift of the first row.

    Each message symbol produces the same output from encoder, time delayed.

    G1 leads to two simple encoders using polynomial multiplication by g(x).

    EE 387 Notes #5, Page 10

  • 7/31/2019 Stanford Coding Theory

    6/24

    Examples of binary cyclic codes (1)

    The (n, 0) code consisting of the zero vector: gn(x) = xn 1.

    The (n, n) code of all n-tuples is another trivial cyclic code: g0(x) = 1.

    The (n, 0) and (n, n) codes are duals. Note: g0(x)gn(x) = xn 1.

    Even-parity simple parity-check codes are cyclic: g1(x) = x 1 = x + 1.Nonsystematic generator matrix:

    G =

    1 1 0 0 0 00 1 1 0 0 0... ... ... . . . ... ... ...0 0 0 1 1 00 0 0 0 1 1

    Repetition codes have generator polynomial gn1 = 1 + x + + x

    n1

    , henceG =

    1 1 1 1 1 1

    .

    Odd parity-check codes are not linear and therefore not cyclic by definition. They are cosets of cyclic codes and havethe same error protection ability in most situations.

    EE 387 Notes #5, Page 11

    Systematic generator matrix (1)

    A systematic encoder copies message digits to consecutive positions in codeword.Convention: most significant digits are transmitted first: cn1, cn2, . . . , cnn

    In order for k message digits to appear at beginning of a codeword, they must beshifted right by n k positions:

    m(x) (0, 0, . . . , 0, m0, m1, . . . , mk1)

    = xnkm(x) .

    To generate a valid codeword, low order n k coefficients must be chosen so that

    the complete n-tuple is a multiple of g(x).Suppose that xnkm(x) has nonzero remainder when divided by g(x).

    Then a codeword can be formed by subtracting the remainder from xnkm(x) .

    Integer example: 31 mod 7 = 3 hence 31 3 = 28 is a multiple of 7.

    EE 387 Notes #5, Page 12

  • 7/31/2019 Stanford Coding Theory

    7/24

    Systematic generator matrix (2)

    The systematic encoder for cyclic code with generator polynomial g(x):

    m(x) xnkm(x) (xnkm(x) mod g(x))

    = xnkm(x) Rg(x)xnkm(x)

    = (0, . . . , 0, m0, . . . , mk1) (p0, . . . , pnk1, 0, . . . , 0)

    The two polynomials in the above sum have no nonzero coefficients of powers of xin common. The polynomial subtraction is in fact a multiplexing operation.

    1

    m(x)

    c(x)

    xnk mod g(x)

    This encoder creates a codeword by appending to the message digits the negativeof the remainder modulo g(x) of the shifted message polynomial.

    EE 387 Notes #5, Page 13

    Systematic generator matrix (3)

    Systematic encoder uses division to produce multiple of generator polynomial.The remainder of division by a fixed polynomial is a linear function.

    The systematic encoder is a linear transformation, so its output is determined bythe output values for any basis.

    The standard basis consists of the k unit vectors {1, x , . . . , xk1}.

    Check symbols for message xi are

    (xnk xi) mod g(x) = xnk+i mod g(x) .

    The rows of the systematic generator matrix for i = 0, 1, . . . , k 1 are

    gi(x) = xnk+i mod g(x) + xnk+i

    = s[nk+i](x) + xnk+i ,

    where s[j](x) = xj mod g(x).

    We will see that s[j](x) is the j-th feedback shift of s[0](x).

    EE 387 Notes #5, Page 14

  • 7/31/2019 Stanford Coding Theory

    8/24

    Systematic generator matrix (4)

    Coefficients of s[j](x) form the parity-check portion of the systematic generatormatrix.

    G2 =

    s[nk]0 s

    [nk]nk1 1 0 0

    s[nk+1]

    0

    s[nk+1]

    nk1

    0 1 0... . . . ... ... ... . . . ...

    s[n1]0 s

    [n1]nk1 0 0 1

    First row of G2 is simply g(x), same as first row of nonsystematic G1.

    Systematic generator matrix has k(n k + 1) nonzero elements, same as G1.

    Both G1 and G2 are determined by n k values (coefficients of g(x)).

    The parity-check portion of each row of G2 comes from the first row by using alinear feedback shift register whose scalers are the coefficients of g(x).

    For example, this shift register multiplies by x modulo x16 + x12 + x5 + 1.

    EE 387 Notes #5, Page 15

    Examples of binary cyclic codes (2)

    Systematic generator matrix for (4, 3) simple parity-check code:

    g(x) = x + 1 xj mod g(x) = 1 G =

    1 1 0 01 0 1 0

    1 0 0 1

    Over GF(2), x7 1 = (x + 1)(x3 + x + 1)(x3 + x2 + 1).

    There are 23 = 8 divisors of x7 1 and thus 8 cyclic codes of blocklength 7. Ifg(x) = x3 + x + 1, a primitive polynomial, we obtain a cyclic Hamming code.

    G =

    1 1 0 1 0 0 00 1 1 0 1 0 01 1 1 0 0 1 01 0 1 0 0 0 1

    H =1 0 0 1 0 1 10 1 0 1 1 1 0

    0 0 1 0 1 1 1

    The dual code has generator matrix H, the (7, 3) maximum-length code.

    All nonzero maximum-length codewords have the same weight, 2m1 = 4.

    EE 387 Notes #5, Page 16

  • 7/31/2019 Stanford Coding Theory

    9/24

    Cyclic codes of blocklength 15

    Over GF(2) the cyclic polynomial x15 1 has five distinct prime factors:

    x15 1 =(x + 1)(x2 + x + 1)

    (x4 + x + 1)(x4 + x3 + 1)(x4 + x3 + x2 + x + 1)

    There are 25 cyclic codes. Some of the more useful generator polynomials:

    (x4 + x + 1) (15,11) binary cyclic Hamming

    (x4

    + x + 1)(x4

    + x3

    + x2

    + x + 1) (15,7) 2-error-correcting BCH

    (x4 + x + 1)(x

    4 + x3 + x

    2 + x + 1)(x2 + x + 1) (15,5) 3EC BCH

    (x4

    + x + 1)(x4

    + x3

    + x2

    + x + 1)(x2

    + x + 1)(x + 1) (15,4) maximum-length

    These codes, with minimum distances 3, 5, 7, 8 , are obtained by expurgation.

    Weightdistributions of

    blocklength 15

    cyclic codes

    1 0 0 35 105 168 280 435 435 280 168 105 35 0 0 11 0 0 0 0 18 30 15 15 30 18 0 0 0 0 1

    1 0 0 0 0 0 0 15 15 0 0 0 0 0 0 1

    1 0 0 0 0 0 0 0 15 0 0 0 0 0 0 0

    EE 387 Notes #5, Page 17

    Cyclic codes: review

    A cyclic code is a LBC such that every cyclic shift of a codeword is a codeword.

    A cyclic code has generator polynomial g(x) that is a divisor of every codeword.

    The generator polynomial is a divisor of xn 1, where n is the blocklength.

    The parity-check polynomial is h(x) =xn 1

    g(x).

    Codewords can be generated by:

    nonsystematic: m(x) m(x)g(x)

    systematic: m(x) xnkm(x) Rg(x)

    xnkm(x)

    Codewords can be characterized by (and errors detected by):

    c(x) mod g(x) = 0

    c(x)h(x) = 0 mod (xn 1)

    EE 387 Notes #5, Page 18

  • 7/31/2019 Stanford Coding Theory

    10/24

    Equivalent codes

    The cyclic (7, 4) Hamming code is not the same as the (7, 4) Hamming code fromlecture #3; the check bits are in positions 1, 2, 3 instead of 1, 2, 4.

    Hold =

    1 0 1 0 1 0 10 1 1 0 0 1 1

    0 0 0 1 1 1 1

    = Hcyclic =

    1 0 0 1 0 1 10 1 0 1 1 1 0

    0 0 1 0 1 1 1

    Definition: Two block codes that are the same except for a permutation of thesymbol positions are called equivalent.

    Equivalent codes have the same weight distribution and same minimum weight.

    Not every linear block code is systematic. Consider this generator matrix:

    G =

    1 1 0 00 0 1 1

    Every linear block code is equivalent to a linear block code that has asystematic generator matrix G = [ P | I] (or G = [ I | P ] in Blahut chapter 3).

    EE 387 Notes #5, Page 19

    Parity-check polynomial

    The parity-check polynomial of a cyclic code with generator g(x) is h(x) =

    xn 1

    g(x) .The degree of the parity-check polynomial is n (n k) = k.

    Parity-check polynomial defines a relation satisfied by all codewords:

    c(x)h(x) = m(x)g(x)h(x) = m(x)(xn 1)

    = xnm(x) m(x) = 0 mod (xn 1)

    = (0, . . . , 0, m0, . . . , mk1) (m0, . . . , mk1, 0, . . . , 0)

    Since deg m(x) < k, coefficients of xi in c(x)h(x) are 0 for i = k , . . . , n 1.

    This corresponds to n k check equations:

    xk 0 = c0hk + c1hk1 + + ck1h1 + ckh0xk+1 0 = c1hk + c2hk1 + + ckh1 + ck+1h0... ...

    xn1 0 = cnk1hk + cnk hk1 + + cn2h1 + cn1h0

    EE 387 Notes #5, Page 20

  • 7/31/2019 Stanford Coding Theory

    11/24

    Parity-check matrix: nonsystematic

    The n k check equations obtained from c(x)h(x) = 0 mod (xn1) correspond toa nonsystematic parity-check matrix:

    c0 c1 ck1 ck ck+1 ck+2 cn1

    H1 =

    hk hk1 h1 h0 0 0 00 hk hk1 h1 h0 0 0... . . . . . . . . . . . . . . . . . . ...0 0 hk hk1 h1 h0 0

    0 0 0 hk hk1 h1 h0

    =

    hR(x)xhR(x)

    ...

    xnk2hR(x)xnk1hR(x)

    This matrix has the same form as the nonsystematic generator matrix.

    The rows of H1 are shifts of the reverse of h(x).

    hR(x) = hk + hk1x + + h1xk1 + h0xk .

    Since h(x) is also a divisor of xn 1, it generates an (n, n k) cyclic code.

    EE 387 Notes #5, Page 21

    Parity-check matrix: nonsystematic (2)

    Since hR

    (x) = xk

    h(x1

    ), zeroes of hR

    (x) are reciprocals of zeroes of h(x).Thus hR(x) is also called the reciprocal polynomial.

    The equation

    gR(x)hR(x) = (g(x)h(x))R

    = (xn 1)R = 1 xn = (xn 1)

    shows that hR(x) is a divisor of xn 1.

    The parity-check matrix H1 has the form of a nonsystematic generator matrix.

    The rows of H1 are shifts of the reversal polynomial hR(x).

    Thus h10 hR(x) generates a cyclic code that is dual of code generated by g(x).

    The cyclic code generated by h(x) consists of the reversals of the dual of the cycliccode generated by g(x).

    EE 387 Notes #5, Page 22

  • 7/31/2019 Stanford Coding Theory

    12/24

    Syndrome circuit #1

    The syndrome computation circuit corresponding to H1 performs multiplication bythe fixed polynomial h(x).

    h0h1h2h3h4

    r(x)

    r(x)h(x)

    This circuit convolves input sequence r0, r1, . . . , rn1 with parity-check polynomialcoefficient sequence h0, h1, . . . , hk.

    Since deg r(x) n 1, the product r(x)h(x) has degree n 1 + k.

    Only n k of the n + k coefficients of r(x)h(x) are used as the syndrome.

    The syndrome consists of the coefficients of xk, . . . , xn1 in r(x)h(x).

    These are generated after rn1, . . . , rnk have been shifted into the register.

    EE 387 Notes #5, Page 23

    Syndrome polynomial

    We could obtain the systematic parity-check matrix from the systematic generatormatrix using the general approach:

    G = [ P | I] H = [ I| PT ]

    Direct construction: define syndrome polynomial to be the remainder of division bygenerator polynomial:

    s(x) = r(x) mod g(x) = s0 + s1x + + snk1xnk1

    Every codeword is a multiple of g(x), so codewords have syndrome 0. Thus

    s(x) = r(x) mod g(x) = (c(x) + e(x)) mod g(x)= c(x) mod g(x) + e(x) mod g(x) = e(x) mod g(x)

    The remainder function is linear in the dividend r(x).

    Therefore remainders of all n-tuples are linear combinations of

    xi mod g(x) (i = 0, 1, . . . , n 1)

    EE 387 Notes #5, Page 24

  • 7/31/2019 Stanford Coding Theory

    13/24

    Parity-check matrix: systematic

    The polynomial syndrome s(x) corresponds to systematic parity-check matrix:

    H2 =

    1x...

    xnk1xnk mod g(x)

    ...xn1 mod g(x)

    T

    =

    1 0 0 s[nk]0 s

    [n2]0 s

    [n1]0

    0 1 0 s

    [nk]

    1 s

    [n2]

    1 s

    [n1]

    1... ... . . . ... ... . . . ... ...

    0 0 1 s[nk]nk1 s

    [n2]nk1 s

    [n1]nk1

    Column i of H2 is syndrome of xi and consists of coefficients of xi mod g(x).

    Special case: column n k consists of coefficients of g(x) (except for xnk).

    Column i is obtained from column i 1 by a linear feedback shift.

    EE 387 Notes #5, Page 25

    Syndrome circuit #2

    Syndromes corresponding to H2 can be calculated very efficiently using linearfeedback shift register circuits that implement polynomial division.

    g0 g1 g2 g3

    r(x)

    1

    r(x) mod g(x)

    r(x)div g(x)

    Encoding circuits can also be used for syndrome computation:

    syndrome = actual check symbols expected check symbols

    where expected check symbols are computed from received message symbols.

    EE 387 Notes #5, Page 26

  • 7/31/2019 Stanford Coding Theory

    14/24

    Partial syndromes

    The zeroes of the generator polynomial determine codewords:

    c(x) is a codeword if and only if c() = 0 for every zero of g(x).

    (The if holds when g(x) has no repeated zeroes, i.e., repeated factors.)

    The zeroes of g(x) typically belong to extension field GF(qm) of GF(q).

    Let {1, . . . , t} include at least one zero of each prime factor of g(x) .

    The partial syndromes S1, . . . , S t of r(x) are

    Si = r(i) = r0 + r1i + + rn1n1i (i = 1, . . . , t)

    The partial syndromes belong to the same extension field as 1, . . . , t.

    Each syndrome component Si corresponds to m linear equations over GF(q).

    The equations are linearly dependent if i is in a proper subfield of GF(qm

    ).

    EE 387 Notes #5, Page 27

    Example: cyclic Hamming code

    Let p(x) be a primitive polynomial over GF(2) of degree m.The smallest value of n such that p(x) | (xn 1) is n = 2m 1.

    Cyclic code generated by p(x) has blocklength n = 2m 1.

    The parity-check matrix H whose columns are xi mod p(x) has distinct nonzerocolumns, so the code can correct all single errors.

    The columns of H are powers of = x in GF(2m):

    H =

    1 2 n2 n1

    Assume a single error in location i, i.e., e(x) = xi. Partial syndrome for :

    S1 = r() = r0 + r1 + + rn1n1

    = c() + e() = e() = i .

    Decoder must find error location i from syndrome S1 = i. It must compute a

    discrete logarithm base .

    EE 387 Notes #5, Page 28

  • 7/31/2019 Stanford Coding Theory

    15/24

  • 7/31/2019 Stanford Coding Theory

    16/24

    Cyclic Golay code

    Multiplicative orders of elements of GF(211) divide 211 1 = 2047 = 23 89.

    There are (23) = 22 elements of order 23. The conjugates of any such are

    , 2, 4, 8, 16, 9, 18, 13, 3, 6, 12

    The minimal polynomial has degree 11. Prime polynomials of degree 11 are

    g(x) = x11 + x10 + x6 + x5 + x4 + x2 + 1

    g(x) = x11 + x9 + x7 + x6 + x5 + x + 1

    These polynomials are mirror images; their zeroes are reciprocals.

    The consecutive powers , 2, 3, 4 among the conjugates guarantee d 5.

    Lemma: Golay codewords of even weight have weight a multiple of 4.

    Theorem: The cyclic Golay codes has d

    = 7 and in fact are perfect codes.

    Weight enumerator: 1 + 253x7 + 506x8 + 1288x11 + 1288x12 + 506x15 + 253x16 + x23

    EE 387 Notes #5, Page 31

    Examples of cyclic codes: CRC-16

    Cyclic codes are often used for error detection because the encoding and syndromecalculation circuits are very simple.

    The most common generator polynomial is CRC-16:

    CRC-16 = x16 + x15 + x2 + 1 = (x + 1)(x15 + x + 1)

    The factor x15

    + x + 1 is primitive of degree 15 hence has order 215

    1 .Therefore the design blocklength of CRC-16 is 215 1 = 32767 bits.

    A significantly shortened code is almost always used.

    Recall that the order of a polynomial is the least integer n > 0 such that g(x) | (xn 1) .

    EE 387 Notes #5, Page 32

  • 7/31/2019 Stanford Coding Theory

    17/24

    Examples of cyclic codes: CRC-CCITT

    Another popular generator polynomial is

    CRC-CCITT = x16 + x12 + x5 + 1 = (x + 1)p2(x) ,

    where p2(x) is a primitive polynomial of degree 15:

    p2(x) = x15 + x14 + x13 + x12 + x4 + x3 + x2 + x + 1

    CRC-16 and CRC-CCITTT polynomials have only 4 nonzero coefficients, so theshift register coding circuits need only 3 exclusive-or gates.

    Minimum distance for CRC-16, CRC-CCITT is 4. Both codes correct single errors

    while detecting double errors, or detect up to 3 errors.Any cyclic code with n k = 16 detects burst errors up to length 16 bits, which isoptimal.

    EE 387 Notes #5, Page 33

    Syndromes of cyclic codes: review

    For any check matrix H, the vector syndrome iss

    =r

    H

    T

    . For H based on check polynomial h(x) = (xn 1)/g(x),

    rHT

    r(x)h(x) mod (xn 1)

    xk

    For systematic H, the j-th column is xj mod g(x), so

    rHT r(x) mod g(x) = Rg(x)

    r(x)

    Polynomial syndrome: s(x) = r(x) mod g(x).

    Partial syndromes are defined using the zeroes 1, . . . , s of g(x):

    Sj = r(j) , j = 1, . . . , s

    The zeroes j and partial syndromes Sj belong to an extension field GF(qm) of

    the channel alphabet GF(q).

    All the above syndromes contain the same information and can be obtained fromeach other by linear transformations.

    The case where g(x) has multiple zeroes requires special consideration.EE 387 Notes #5, Page 34

  • 7/31/2019 Stanford Coding Theory

    18/24

    Double-error-correcting binary BCH code

    If is primitive in GF(2m), it defines a (2m1, 2m1m) Hamming code:

    c(x) C c() = 0 = c0 + c1 + + cn1n1

    Key idea: to correct more errors, we use more equations of the form c() = 0.

    Conjugates of over GF(2) cannot be used, because c() = 0 c(2i) = 0.

    In other words, the m equations over GF(2) corresponding to 2i

    Hi =

    1 2i

    22i

    (n1)2i

    are linearly dependent on the m equations corresponding to .

    Fortunately most other choices work.

    Exercise: Any nonconjugate i that does not belong to a proper subfield

    of GF(2m) can be used.

    EE 387 Notes #5, Page 35

    2EC BCH code (2)

    Lets try 3

    . This apparently obvious choice works quite well.The parity-check matrix represented over GF(2m) is the following:

    H =

    1 2 n1

    1 3 6 3(n1)

    The codewords defined by H are the polynomials c(x) with zeroes and 3.

    Therefore every codeword is a multiple of the minimal polynomials of and 3.

    Let f1(x) and f3(x) be the minimal polynomials over GF(2) of and 3.

    The generator polynomial is g(x) = f1(x)f3(x),

    The minimal polynomials of and 3 have degree m. Thus deg g(x) 2m.

    H has two rows over GF(2m) 2m rows over GF(2).

    Therefore the number of check bits satisfies n k 2m .

    Fact: If m 3 then n k = 2m.

    EE 387 Notes #5, Page 36

  • 7/31/2019 Stanford Coding Theory

    19/24

    Syndromes for 2EC BCH code

    Consider any error pattern of weight 2 :

    e(x) = xi1 + xi2 , 0 i1 < i2 < n

    Syndrome of r(x) has two partial syndrome components S1, S3:

    S1 = r() = e() = i1 + i2

    S3 = r(3) = e(3) = 3i1 + 3i2 = (i1)3 + (i2)3

    Partial syndromes can be computed from r(x) by multiply-accumulate circuits.

    m

    S1r0, . . . , rn1

    3

    m

    S3r0, . . . , rn1

    They are known quantities in this system of equations (computed at runtime).

    Unknowns i1 and i2 appear in the exponent equations are transcendental.

    EE 387 Notes #5, Page 37

    2EC BCH decoding: change of variable

    Let us simplify the problem by a change of variables:X1 =

    i1 , X2 = i2

    This yields a system of algebraic equations of degree 3:

    S1 = i1 + i2 = X1 + X2

    S3 = 3i1 + 3i2 = X31 + X

    32

    X1 and X2 are called the error locators.

    Error locations are obtained from X1, X2 by taking logarithms to base :

    i1 = log X1 , i2 = log X2

    Some books use the term error location numbers instead of error locators. Wrong: error locators are not numbers butare elements of a finite field GF(2m).

    EE 387 Notes #5, Page 38

  • 7/31/2019 Stanford Coding Theory

    20/24

    2EC BCH decoding: degree reduction

    We can reduce the degree of this system of equations:

    S3S1

    =X31 + X

    32

    X1 + X2= X21 + X1X2 + X

    22

    = (X1 + X2)

    2

    + X1X2 = S

    2

    1 + X1X2Next we rewrite the two equations for X1, X2 to obtain a system of degree 2:

    X1+X2 = S1

    X1 X2 =S3S1

    + S21 =S3 + S

    31

    S1

    The sum and the product of the unknowns X1, X2 can be computed from knownquantities, the partial syndromes S1, S3.

    We now know the coefficients of a quadratic polynomial whose zeroes are X1, X2.

    EE 387 Notes #5, Page 39

    2EC BCH decoding: polynomial equation

    Given the sum and product of X1, X2, we can construct the quadratic polynomialR(x) whose zeroes are X1 and X2:

    R(x) = (x X1)(x X2) = x2 (X1 + X2)x + X1X2

    = x2 + S1x +S3 + S

    31

    S1= x2 + 1x + 2

    If there are two errors, then X1 = X2. Therefore

    1 = S1 = X1 + X2 = 0

    and the coefficient

    2 =S3 + S31

    S1

    is well defined and nonzero because X1 = 0 and X2 = 0.

    If 1 = 0, 2 = 0 then (x) has only one zero because every element of GF(2m) has a unique square root:

    i =

    i/2 i even

    (i+2m1)/2 i odd

    EE 387 Notes #5, Page 40

  • 7/31/2019 Stanford Coding Theory

    21/24

    2EC BCH decoding: other cases

    When there are two errors, the error locators are the zeroes of R(x).

    Bit error locations could be found by evaluating R(i) for i = 0, 1, . . . , n 1.

    (Quadratic formula cannot be used in GF(2m). However, there are efficient

    methods for factoring quadratic polynomials over GF(2m

    ).)What about < 2 errors?

    If one error, the error pattern e(x) = xi1 has syndrome components:

    S1 = e() = i1 = X1

    S3 = e(3) = 3i1 = X31

    In this case, S3 = S31 and 2 = 0.

    When there is no error, S1 = S3 = 0.

    EE 387 Notes #5, Page 41

    2EC BCH code: decoding procedure

    1. Compute partial syndromes: S1 = r(), S3 = r(3

    ).

    2. IfS1 = 0 and S3 = 0 then assume no error most plausible assumption.

    3. IfS1 = 0 and S3 = S31 then assume 1 error.

    Error locator is X1 = S1. Error location is i1 satisfying X1 = i1.

    4. IfS1 = 0 and S3 = S31 then assume 2 errors.

    Error locators are the zeroes in GF(2m) of R(x):

    R(x) = x2 + S1x +S

    3+ S3

    1S1 .

    If X1 = i1, X2 =

    i2 are zeroes of R(x), errors are in locations i1, i2.

    5. IfR(x) does not have 2 zeroes in GF(2m), or ifS1 = 0 and S3 = 0, then 3errors have occurred (uncorrectable but detectable).

    EE 387 Notes #5, Page 42

  • 7/31/2019 Stanford Coding Theory

    22/24

    2EC BCH code: miscorrection, computational cost

    When more than 2 errors, decoder may miscorrect.

    When there are 3 errors, decoder will miscorrect with probability 1/2.(Why? About half the syndromes correspond to correctable errors.)

    When 3 errors are miscorrected, 2 correct bits will be changed, for a total of 5bit errors in miscorrected codeword.

    Computation of partial syndromes requires only scalers for and 3.

    Error correction uses one division and a few general multiplication operations tocalculate R(x) and to find zeroes of the polynomial.

    Almost all computational cost comes from syndrome computation.

    Also needed: efficient method to find exponents i1 and i2 from X1 and X2.

    In order to reduce total energy consumption, we must consider tradeoffs between decoder complexity andencoder/syndrome complexity.

    EE 387 Notes #5, Page 43

    Summary of cyclic codes

    A cyclic code is a linear block code such that any cyclic shift of a codeword is acodeword.

    The right cyclic shift by i positions of n-tuple v(x) is denoted by v(i)(x).

    Left cyclic shift is equivalent to right cyclic shift:

    v(i)(x) = v(ni)(x)

    The right cyclic shift of an n-tuple is equivalent to multiplication by xmodulo (xn 1):

    v(1)(x) = xv(x) mod (xn 1)By induction on i,

    v(i)(x) = xiv(x) mod (xn 1)

    EE 387 Notes #5, Page 44

  • 7/31/2019 Stanford Coding Theory

    23/24

    Summary continued

    Every (n, k) cyclic code C has a generator polynomial g(x).

    The generator polynomial is the monic polynomial of least degree that is acodeword.

    Every codeword c(x) is a polynomial multiple of g(x). The generator polynomial is unique.

    The degree of g(x) is n k.

    The generator polynomial is a divisor of xn 1 .

    The parity-check polynomial of a cyclic code is

    h(x) =xn 1

    g(x).

    An n-tuple c(x) is in a cyclic code C if and only if

    c(x)h(x) = 0 mod (xn 1) .

    EE 387 Notes #5, Page 45

    Summary continued

    An n-tuple c(x) is in a cyclic code C if and only ifc(1) = 0, c(2) = 0, . . . , c(t) = 0

    where 1, . . . , t are the zeroes of g(x) in an extension field.

    Encoders for cyclic codes.

    Let m(x) be a message k-tuple of degree < k.

    Nonsystematic:m(x) m(x)g(x)

    The rows of G are shifts of g(x).

    Systematic:

    m(x) xnkm(x) xnkm(x) mod g(x)

    The parity-check portion of G consists of rows of the form xi mod g(x) fori = 0, 1, . . . , n k .

    EE 387 Notes #5, Page 46

  • 7/31/2019 Stanford Coding Theory

    24/24

    Summary continued

    Syndrome computation for cyclic codes. Let r(x) be an n-tuple.

    Nonsystematic: Rows of H are n k right shifts of hR(x), the reversal of h(x).

    Systematic: columns of H are xi mod g(x) for i = 0, 1, . . . , n 1.

    Syndrome polynomial: s(x) = r(x) mod g(x) has degree < n k and thereforen k components.

    Partial syndromes: Si = r(i) where 1, . . . , t are the zeroes of g(x).

    Not all zeroes of g(x) are needed; one element from each conjugacy class issufficient.

    Examples of cyclic codes.

    Useless (n, 0) code has g(x) = xn

    1. Repetition (n, n) code has g(x) = 1.

    Simple binary (n, n1) parity-check codes have generator polynomial x + 1.

    EE 387 Notes #5, Page 47

    Summary continued

    Examples of cyclic codes (continued). Binary Hamming codes of blocklength 2m 1 have a generator polynomial that

    is a primitive polynomial of degree m.

    Expurgated binary Hamming codes have generator polynomial (x + 1)p(x).

    The factor x + 1 increases the minimum distance to 4.

    The (23, 12, 7) Golay codes have generator polynomials of degree 11 whosezeroes are elements of GF(211) of order 23.

    CRC (Cyclic Redundancy Check) codes defined in terms of generatorpolynomials such as

    CRC-16 = x16 + x15 + x2 + 1

    CRC-CCITT = x16 + x12 + x5 + 1

    Every cyclic code over GF(q) is also a cyclic code over any extensionfield GF(Q) and has the same generator polynomial.