CYCLIC CODE Submitted By: Farida Mohamed Ahmed 18P1474 Hagar Ahmed Mohamed 18P6623 Mariam Hany Wadie 18P5465 Nada Ayman Abd El Qader Rahma Ahmed Hesham 18P3028 18P9374 Submitted To: Dr. Fatma Newagy Eng. Moustafa Mohamed 1 Main Concept Agenda • Cyclic Code properties • Encoding • Decoding Encoder & Decoder Circuit Design Advantages & Disadvantages Standards & Applications Cyclic Code Subclass of linear block code Properties: Linearity property The Sum of two codewords gives another codeword → Ex: {101 , 110,011} → 101 + 110 = 011 → 101 + 011 = 110 → 110 + 011 = 101 Cyclic Shifting Property Cyclic shifting of any codeword right or left by any number of bits gives another codeword Ex: {000,011,101,110} shifting 011 right by 1 bit gives 101 shifting 101 right by 1 bit gives 110 shifting 110 right by 1 bit gives 011 shifting 000 right by 1 bit gives 000 Cyclic codes Encoding Systematic Division method Generator matrix method Non-systematic Multiplication method Generator matrix method Decoding Cyclic encoders Circuit (shift register) Syndrome decoding (error pattern) Cyclic Decoders Circuit (shift register) Non-systematic Codeword In Non-Systematic codeword → codeword ≠ [msg, parity] Else msg and parity bits are not in sequence. Cyclic code for non-systematic codeword (Multiplication Method) How to get codeword? c(x) = m(x)*g(x) , m(x) message polynomial , g(x) generator polynomial , c(x) codeword polynomial Note: • How to get polynomials from bits Ex: msg polynomial from msg bits, msg = 1011 1st (least significant) bit corresponds to x0 2nd bit corresponds to x1 3rd bit corresponds to x2 4th (most significant) bit corresponds to x3 ؞polynomial of the msg = 1(x ) + 0(x ) + 1(x ) + 1(x ) = x + x + 1 3 2 1 0 3 1 Cyclic Code for non-systematic codeword (Multiplication Method) Ex: construct Non-Systematic codeword (7,4) using cyclic codes , generator polynomial 𝑔(𝑥) = 𝑥 3 + 𝑥 2 + 1 , msg = 1010 msg polynomial = 𝑥 3 + 𝑥 c(x) = m(x)*g(x) = 𝑥 3 + 𝑥 ∗ 𝑥 3 + 𝑥2 + 1 = 𝑥 6 + 𝑥 5 + 𝑥 3 + 𝑥 4 + 𝑥 3 + 𝑥 = 𝑥6 + 𝑥5 + 𝑥4 + 𝑥 (note: we use modulo 2 sum x3 + x3 = 0) Then get codeword bits from codeword polynomial Coeff. of 𝑥 0 = 0 Coeff. of 𝑥 4 = 1 Coeff. of 𝑥 1 = 1 Coeff. of 𝑥 5 = 1 Coeff. of 𝑥 2 = 0 Coeff. of 𝑥 6 = 1 → codeword bits = 1110010 Coeff. of 𝑥 3 = 0 Cyclic Code for non-systematic codeword (Generator Matrix Method) How to get codeword?! c = m*g , m message matrix , g generator matrix , c codeword matrix Cyclic Code for non-systematic codeword (Generator Matrix Method) Getting Generator matrix from generator polynomial: • G is of size nxk • Rows of generator matrix is given by {Ri = xk-1 g(x)} , i= 1, 2…,k • EX: construct generator matrix (7,4), generator polynomial = x3 + x + 1 i=1 , R1 = x3(x3 + x + 1) = x6 + x4 + x3 , R1 matrix = [ 1011000] i=2 , R2 = x2(x3 + x + 1) = x5 + x3 + x2 , R1 matrix = [ 0101100] i=3 , R3 = x1(x3 + x + 1) = x4 + x2 + x1 , R1 matrix = [ 0010110] i=4 , R1 = x0(x3 + x + 1) = x3 + x + 1, R1 matrix = [ 0001011] Cyclic code for non-systematic codeword (Generator Matrix Method) R1 • G= R2 R3 R4 = 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 Cyclic code for non-systematic codeword (Generator Matrix Method) EX: construct Non-Systematic codeword (7,4) using cyclic codes, generator polynomial g(x) = x3 + x + 1, msg = 1011 G= 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 C =m * G = [1011] =1000101 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 Cyclic code for systematic codeword (Division Method) In Systematic codeword codeword = [msg, parity] How to get codeword?! c(x) = xn-k m(x) + p(x) , p(x) = rem [xn−k m(x)/g(x)] , m(x) message polynomial , g(x) generator polynomial , c(x) codeword polynomial Cyclic code for systematic codeword (Division Method) Ex: construct Systematic codeword (7,4) using cyclic codes, generator polynomial g(x) = x3 + x2 + 1, msg = 1010 msg polynomial = x3 + x c(x) = xn-k m(x) + p(x) , p(x) = rem [xn−k m(x)/g(x)] , n= 7 & k =4 xn−k m(x)/g(x) = x3 (x3 + x ) / (x3 + x2 + 1 ) = ( x6 + x4) / (x3 + x2 + 1 ) x3 + x2 + 1 ؞p(x) = rem [xn−k m(x)/g(x)] = 1 c(x) = xn-k m(x) + p(x) = x6 + x4 +1 x3 + x2 + 1 x6 + x4 x6 + x5 + x3 x5 + x4 + x3 x5 + x4 + x2 x3 + x2 x3 + x2 +1 1 Cyclic code for systematic codeword (Division Method) Then get codeword bits from codeword polynomial Coeff. of x0 = 1 Coeff. of x1 = 0 Coeff. of x2 = 0 Coeff. of x3 = 0 Coeff. of x4 = 1 Coeff. of x5 = 0 Coeff. of x6 = 1 codeword bits = 1010 001 msg Parity bits Cyclic code for systematic codeword (Generator Matrix Method) In Systematic codeword codeword = [msg , parity] How to get codeword?! c= m* g , m message matrix , g generator matrix , c codeword matrix Cyclic code for systematic codeword (Generator Matrix Method) Getting Generator matrix from generator polynomial: • G = [I : P], G is of size nxk • Identity matrix is of size kxk • To get parity matrix → 1st row : rem [xn−1 /g(x)] → 2nd row : rem [xn−2 /g(x)] .. . → kth row: rem [xn−k /g(x)] Cyclic code for systematic codeword (Generator Matrix Method) Generator Matrix: • Ex: construct generator matrix (7,4), generator polynomial = x3 + x + 1 To get parity matrix → 1st row : rem [x6 / (x3 + x + 1)] 1st row bits = 101 x3 + x + 1 x3 + x + 1 x6 x6 + x4 + x3 x4 + x3 x4 + x2 + x x3 + x2 + x x3 + x +1 x2 + 1 Cyclic code for systematic codeword (Generator Matrix Method) 2nd row : rem [x5 / (x3 + x + 1)] 2nd row bits = 111 3rd row : rem [x4 / (x3 + x + 1)]] 3rd row bits = 110 x2 + 1 x3 + x + 1 x5 x5 + x3 + x2 x3 + x2 x3 + x + 1 x2 + x + 1 x x3 + x + 1 x4 x4 + x2 + x x2 + x Cyclic code for systematic codeword (Generator Matrix Method) → 4th row : rem [x3 / (x3 + x + 1)]] = x+1 1 x3 + x + 1 x3 x3 + x + 1 x+ 1 4th row bits = 011 G = [I : P] = 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 Cyclic code for systematic codeword (Generator Matrix Method) Ex: construct Systematic codeword (7,4) using cyclic codes, generator polynomial g(x) = x3 + x + 1, msg = 1011 G= 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 C = m * G = 1011 1 0 0 0 1 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 0 0 0 0 1 0 1 1 = 1011000 Decoding of cyclic codes a. Syndrome Decoding: It’s used in cyclic codes in order to decode the sequence and to decode and correct it. Syndrome polynomial is obtained as S(x)= Reminder of R 𝑥 𝑔 𝑥 If S(x) =0, then No errors If S(x)≠ 0, there are some errors Decoding of cyclic codes a. Syndrome Decoding: Ex: Consider received sequence is R=1011000 for (7,4) code dimension and generator polynomial g(x)=𝑥 3 + 𝑥 + 1 Find received sequence is valid or not? 𝑅 𝑥 = 𝑥6 + 𝑥4 + 𝑥3 𝑔 𝑥 = 𝑥3 + 𝑥 + 1 𝑥3 𝑥3 + 𝑥 + 1 𝑥6 + 𝑥4 + 𝑥3 𝑥6 + 𝑥4 + 𝑥3 0 0 0 S(x)=0 → No Error Cyclic encoder Circuit design Codewords could be generated using n-k flipflops Ex: For generator polynomial = 1 + x + x3 = 1 + x +0(x2) + x3 1 1 FF FF FF P1 LSB 1 0 P2 P3 MSB Input message Cyclic encoder Circuit Design Construct codeword (7,4) using cyclic codes, generator polynomial g(x) = x3 + x + 1, msg = 1011 ؞Codeword = [msg |p] = [1011000] FF FF FF P1 LSB P2 P3 Input MSB message Input P1 = inputi-1 xor P3i-1 P2 = inputi-1 xor P1i-1 xor P3i-1 P3 = P2i-1 1 0 0 0 After 1st clk cycle 0 1 1 0 After 2nd clk cycle 1 0 1 1 After 3rd clk cycle 1 0 0 1 0 0 0 After 4th clk cycle P1 LSB P2 P3 MSB Cyclic Decoder Circuit Design b. Syndrome Calculator: Ex: Consider a cyclic code with code dimension (7,4) and g(x)=𝑥 3 + 𝑥 + 1. If the received codeword is R=1001000. Determine the syndrome by using a syndrome calculator. g(x)=𝑥 3 + 𝑥 + 1 Before Shift 𝑔2 = 0 𝑆3 R + 𝑆3 1 𝑆1 + 𝑆2 𝑆3 Syndrome SW 2 Output R 1 0 0 1 0 0 0 𝑆1 0 1 0 0 0 0 1 𝑆2 0 0 1 0 1 0 1 S3 0 0 0 1 0 1 0 After Shift 𝑆1′ = R⊕S3 1 0 0 0 0 1 0 WB so, S=110 S2′ =𝑆1 ⊕S3 0 1 0 1 0 1 1 S3′ = 𝑆2 0 0 1 0 1 0 1 MSB Advantages of cyclic code They are easy to implement. Simple and easy error detection and correction methods. Easy implementation for encoding and decoding circuit for cyclic codes using shift registers. They can be easily implemented in both hardware or software. Small overhead. Disadvantages of cyclic code Low robustness during overloads. Error correction is slightly more complicated than error detection; due to the complexity of the combination logic circuit used for error correction. Some standard cyclic codes The hamming code: Single error-correcting codes can be used in cyclic form. The BCH code: Extension of hamming for n-errors correcting codes. CRC code: Cyclic redundancy check code which is a shortened cyclic error-detecting code used in automatic repeat request systems. Reed Solomon code: A non-binary cyclic code. Reed Solomon Codes Applications Reed-Solomon codes have been widely used in mass storage systems to correct the burst errors caused by media defects. Special types of Reed-Solomon codes have been used to overcome the unreliable nature of data transmission over erasure channels. Several bar-code systems use Reed-Solomon codes to allow correct reading even if a portion of a bar code is damaged. Reed-Solomon codes were used to encode pictures sent by the Voyager spacecraft. Other applications of cyclic code Satellite & wireless communication : The information sent digitally in satellite & wireless communication uses cyclic code in the encoding and decoding process. Compact discs(CD): Since CD errors are burst errors, cyclic codes can be used in CDs to correct these burst errors. Error correction: Used to correct double errors and burst errors. THANK YOU