Go to the source code of this file.
Functions | |
| long | arr2int (int *, int) |
| void | nextcomb (int, int, int *) |
| long | get_syndrome (long) |
| void | gen_enc_table (void) |
| void | gen_dec_table (void) |
| long | encode_golay (long data) |
|
||||||||||||
|
Definition at line 84 of file golay.c. References a. Referenced by gen_dec_table(). 00087 {i=1}^r 2^{a[i]-1}.
00088 */
00089 {
00090 int i;
00091 long mul, result = 0, temp;
00092
00093 for (i=1; i<=r; i++) {
00094 mul = 1;
00095 temp = a[i]-1;
00096 while (temp--)
00097 mul = mul << 1;
00098 result += mul;
00099 }
00100 return(result);
00101 }
|
|
|
Definition at line 213 of file golay.c. References codeword, encoding_table, and gen_enc_table(). Referenced by construct_header_level2(). 00214 {
00215 /*
00216 * encodes data and returns the codeword.
00217 * data is assumed to contain 12 bits in the least significant bit positions
00218 * codeword contains the 23 bits in the LSB positions
00219 *
00220 */
00221 static int initialized=0;
00222
00223 if (!initialized) {
00224 gen_enc_table();
00225 initialized=1;
00226 }
00227 codeword = encoding_table[data];
00228 if (debug) printf("encode_golay() - codeword = %#012x\n", codeword);
00229 return codeword;
00230 }
|
|
|
Definition at line 164 of file golay.c. References a, arr2int(), decoding_table, get_syndrome(), and nextcomb(). Referenced by decode_golay(). 00165 {
00166 /*
00167 * ---------------------------------------------------------------------
00168 * Generate DECODING TABLE
00169 *
00170 * An entry to the decoding table is a syndrome and the resulting value
00171 * is the most likely error pattern. First an error pattern is generated.
00172 * Then its syndrome is calculated and used as a pointer to the table
00173 * where the error pattern value is stored.
00174 * ---------------------------------------------------------------------
00175 *
00176 * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS)
00177 */
00178 long temp;
00179 int i;
00180
00181 decoding_table[0] = 0;
00182 decoding_table[1] = 1;
00183 temp = 1;
00184 for (i=2; i<= 23; i++) {
00185 temp *= 2;
00186 decoding_table[get_syndrome(temp)] = temp;
00187 }
00188 /*
00189 * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS)
00190 */
00191 a[1] = 1; a[2] = 2;
00192 temp = arr2int(a,2);
00193 decoding_table[get_syndrome(temp)] = temp;
00194 for (i=1; i<253; i++) {
00195 nextcomb(23,2,a);
00196 temp = arr2int(a,2);
00197 decoding_table[get_syndrome(temp)] = temp;
00198 }
00199 /*
00200 * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS)
00201 */
00202 a[1] = 1; a[2] = 2; a[3] = 3;
00203 temp = arr2int(a,3);
00204 decoding_table[get_syndrome(temp)] = temp;
00205 for (i=1; i<1771; i++) {
00206 nextcomb(23,3,a);
00207 temp = arr2int(a,3);
00208 decoding_table[get_syndrome(temp)] = temp;
00209 }
00210 }
|
|
|
Definition at line 143 of file golay.c. References encoding_table, get_syndrome(), and pattern. Referenced by encode_golay(). 00144 {
00145 /*
00146 * ---------------------------------------------------------------------
00147 * Generate ENCODING TABLE
00148 *
00149 * An entry to the table is an information vector, a 32-bit integer,
00150 * whose 12 least significant positions are the information bits. The
00151 * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit
00152 * integer whose 23 least significant bits are coded bits: Of these, the
00153 * 12 most significant bits are information bits and the 11 least
00154 * significant bits are redundant bits (systematic encoding).
00155 * ---------------------------------------------------------------------
00156 */
00157 long temp;
00158 for (pattern = 0; pattern < 4096; pattern++) {
00159 temp = pattern << 11; /* multiply information by X^{11} */
00160 encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */
00161 }
00162 }
|
|
|
Definition at line 121 of file golay.c. References pattern. Referenced by decode_golay(), gen_dec_table(), and gen_enc_table(). 00126 : (1) pattern = infomation 00127 * bits, when constructing the encoding table; (2) pattern = error pattern, 00128 * when constructing the decoding table; and (3) pattern = received vector, to 00129 * obtain its syndrome in decoding. 00130 */ 00131 { 00132 long aux = X22; 00133 00134 if (pattern >= X11) 00135 while (pattern & MASK12) { 00136 while (!(aux & pattern)) 00137 aux = aux >> 1; 00138 pattern ^= (aux/X11) * GENPOL; 00139 } 00140 return(pattern); 00141 }
|
|
||||||||||||||||
|
Definition at line 103 of file golay.c. References a. Referenced by gen_dec_table(). 00107 {
00108 int i, j;
00109
00110 a[r]++;
00111 if (a[r] <= n)
00112 return;
00113 j = r - 1;
00114 while (a[j] == n - r + j)
00115 j--;
00116 for (i = r; i >= j; i--)
00117 a[i] = a[j] + i - j + 1;
00118 return;
00119 }
|
1.3.9.1