Si4463/Stm8Src/GOLAY.C

403 wiersze
17 KiB
C

/*
Golay 23.12 code encoding and decoding (using lookup table)
Generator polynomial: x11+x10+x6+x5+x4+x2+1
Golay 23.12 is perfect code with Hamming distance of 7,
and can correct up to 3 errors per codeword.
More than 3 errors are NOT detected.
The parity extended Golay 24.12 code has D=8 and can
correct up to 3 and detect 4 errors.
(c)VLV
vlv@writeme.com
http://www.geocities.com/SiliconValley/4795
*/
#include <stdio.h>
/*
Generate Golay 23.12 codeword
(Generator polynomial: x11+x10+x6+x5+x4+x2+1)
input = 12-bit data
output = 23-bit codeword
*/
unsigned long int MakeGolayWord(unsigned int x)
{
unsigned char ci;
unsigned int s;
s=x;
for(ci=0;ci<12;ci++)
{
s<<=1;
if(s&0x1000) s^=0x08ea;
}
s=(s>>1)&0x7ff;
return (((unsigned long int)x)<<11)|s;
}
/*
Correct Golay 23.12 codeword using syndrome lookup table
(Generator polynomial: x11+x10+x6+x5+x4+x2+1)
Can correct up to 3 errors,don't detect more than 3 errors (perfect code)
input - pointer to codeword;
returns the number of errors corrected (0,1,2,3)
*/
unsigned char CorrectGolayCode(unsigned long int *golayword)
{
// The lookup table consists of 15-bit values
static unsigned int const correction_table[2048] =
{
0x7fff,0x7fe0,0x7fe1,0x7c01,0x7fe2,0x7c02,0x7c22,0x0022,
0x7fe3,0x7c03,0x7c23,0x0023,0x7c43,0x0043,0x0443,0x15d1,
0x7fe4,0x7c04,0x7c24,0x0024,0x7c44,0x0044,0x0444,0x3616,
0x7c64,0x0064,0x0464,0x2e74,0x0864,0x2135,0x19f2,0x1d4c,
0x7fe5,0x7c05,0x7c25,0x0025,0x7c45,0x0045,0x0445,0x0dd1,
0x7c65,0x0065,0x0465,0x09d1,0x0865,0x05d1,0x01d1,0x7dd1,
0x7c85,0x0085,0x0485,0x1d0f,0x0885,0x194b,0x3295,0x2653,
0x0c85,0x31b2,0x2556,0x1a15,0x1e13,0x3e96,0x216d,0x11d1,
0x7fe6,0x7c06,0x7c26,0x0026,0x7c46,0x0046,0x0446,0x1e75,
0x7c66,0x0066,0x0466,0x214d,0x0866,0x3214,0x11f2,0x2576,
0x7c86,0x0086,0x0486,0x2591,0x0886,0x154b,0x0df2,0x21d4,
0x0c86,0x1dd6,0x09f2,0x1615,0x05f2,0x3633,0x7df2,0x01f2,
0x7ca6,0x00a6,0x04a6,0x4a96,0x08a6,0x114b,0x2130,0x31af,
0x0ca6,0x25f3,0x1d6c,0x1215,0x36b6,0x1d12,0x2a74,0x19d1,
0x10a6,0x094b,0x35d3,0x0e15,0x014b,0x7d4b,0x1e36,0x054b,
0x2234,0x0615,0x0215,0x7e15,0x258e,0x0d4b,0x15f2,0x0a15,
0x7fe7,0x7c07,0x7c27,0x0027,0x7c47,0x0047,0x0447,0x1a75,
0x7c67,0x0067,0x0467,0x2612,0x0867,0x2daf,0x2296,0x114c,
0x7c87,0x0087,0x0487,0x150f,0x0887,0x4654,0x256e,0x0d4c,
0x0c87,0x19d6,0x3635,0x094c,0x1613,0x054c,0x014c,0x7d4c,
0x7ca7,0x00a7,0x04a7,0x110f,0x08a7,0x2596,0x29b2,0x2e14,
0x0ca7,0x2a95,0x196c,0x3676,0x1213,0x1912,0x25f5,0x1dd1,
0x10a7,0x050f,0x010f,0x7d0f,0x0e13,0x35d5,0x1a36,0x090f,
0x0a13,0x2571,0x3a54,0x0d0f,0x7e13,0x0213,0x0613,0x154c,
0x7cc7,0x00c7,0x04c7,0x0a75,0x08c7,0x0675,0x0275,0x7e75,
0x0cc7,0x11d6,0x156c,0x3e34,0x2551,0x1512,0x35d0,0x0e75,
0x10c7,0x0dd6,0x2a14,0x2db2,0x218d,0x25f0,0x1636,0x1275,
0x01d6,0x7dd6,0x2133,0x05d6,0x2e95,0x09d6,0x1df2,0x194c,
0x14c7,0x3611,0x0d6c,0x254e,0x39f4,0x0d12,0x1236,0x1675,
0x056c,0x0912,0x7d6c,0x016c,0x0112,0x7d12,0x096c,0x0512,
0x2655,0x3274,0x0a36,0x190f,0x0636,0x1d4b,0x7e36,0x0236,
0x29af,0x15d6,0x116c,0x1e15,0x1a13,0x1112,0x0e36,0x25b4,
0x7fe8,0x7c08,0x7c28,0x0028,0x7c48,0x0048,0x0448,0x2d92,
0x7c68,0x0068,0x0468,0x194d,0x0868,0x1135,0x1e96,0x3e13,
0x7c88,0x0088,0x0488,0x14ef,0x0888,0x0d35,0x2a33,0x19d4,
0x0c88,0x0935,0x31d0,0x4656,0x0135,0x7d35,0x156d,0x0535,
0x7ca8,0x00a8,0x04a8,0x10ef,0x08a8,0x3674,0x1930,0x2ab6,
0x0ca8,0x2e16,0x4a75,0x2594,0x298f,0x18f2,0x116d,0x21d1,
0x10a8,0x04ef,0x00ef,0x7cef,0x3a56,0x3211,0x0d6d,0x08ef,
0x1a34,0x29d3,0x096d,0x0cef,0x056d,0x1535,0x7d6d,0x016d,
0x7cc8,0x00c8,0x04c8,0x0d4d,0x08c8,0x3e36,0x1530,0x11d4,
0x0cc8,0x054d,0x014d,0x7d4d,0x2dd3,0x14f2,0x3235,0x094d,
0x10c8,0x4253,0x2eb6,0x09d4,0x1d8d,0x05d4,0x01d4,0x7dd4,
0x1634,0x2d8f,0x1d33,0x114d,0x2a16,0x1935,0x21f2,0x0dd4,
0x14c8,0x31d5,0x0930,0x2e33,0x0530,0x0cf2,0x7d30,0x0130,
0x1234,0x08f2,0x39f6,0x154d,0x00f2,0x7cf2,0x0d30,0x04f2,
0x0e34,0x25b6,0x2992,0x18ef,0x3e75,0x214b,0x1130,0x15d4,
0x7e34,0x0234,0x0634,0x2215,0x0a34,0x10f2,0x196d,0x3276,
0x7ce8,0x00e8,0x04e8,0x10af,0x08e8,0x29d0,0x0e96,0x25b1,
0x0ce8,0x3233,0x0a96,0x2dd5,0x0696,0x14d2,0x7e96,0x0296,
0x10e8,0x04af,0x00af,0x7caf,0x198d,0x2e76,0x4255,0x08af,
0x2972,0x3614,0x1933,0x0caf,0x39f1,0x1d35,0x1296,0x214c,
0x14e8,0x048f,0x008f,0x7c8f,0x2e35,0x0cd2,0x31d3,0x088f,
0x25ae,0x08d2,0x2a11,0x0c8f,0x00d2,0x7cd2,0x1696,0x04d2,
0x002f,0x7c2f,0x7c0f,0x7fef,0x2554,0x044f,0x004f,0x7c4f,
0x32b6,0x046f,0x006f,0x7c6f,0x2213,0x10d2,0x1d6d,0x086f,
0x18e8,0x2574,0x3a32,0x3216,0x118d,0x0cb2,0x296f,0x2275,
0x3e15,0x08b2,0x1133,0x1d4d,0x00b2,0x7cb2,0x1a96,0x04b2,
0x098d,0x2a35,0x0d33,0x14cf,0x7d8d,0x018d,0x058d,0x1dd4,
0x0533,0x21d6,0x7d33,0x0133,0x0d8d,0x10b2,0x0933,0x2e11,
0x2a76,0x0872,0x3695,0x10cf,0x0072,0x7c72,0x1d30,0x0472,
0x0052,0x7c52,0x216c,0x0452,0x7c12,0x7ff2,0x0032,0x7c32,
0x2dd0,0x04cf,0x00cf,0x7ccf,0x158d,0x0c92,0x2236,0x08cf,
0x1e34,0x0892,0x1533,0x0ccf,0x0092,0x7c92,0x29d5,0x0492,
0x7fe9,0x7c09,0x7c29,0x0029,0x7c49,0x0049,0x0449,0x29f4,
0x7c69,0x0069,0x0469,0x1e12,0x0869,0x1115,0x31b3,0x1976,
0x7c89,0x0089,0x0489,0x1991,0x0889,0x0d15,0x1d6e,0x1653,
0x0c89,0x0915,0x1556,0x35cf,0x0115,0x7d15,0x4234,0x0515,
0x7ca9,0x00a9,0x04a9,0x2db5,0x08a9,0x1d96,0x1910,0x1253,
0x0ca9,0x19f3,0x1156,0x2194,0x2e54,0x29b0,0x1df5,0x25d1,
0x10a9,0x3a14,0x0d56,0x0a53,0x35f1,0x0653,0x0253,0x7e53,
0x0556,0x1d71,0x7d56,0x0156,0x198e,0x1515,0x0956,0x0e53,
0x7cc9,0x00c9,0x04c9,0x1191,0x08c9,0x35d2,0x1510,0x0d76,
0x0cc9,0x15f3,0x3a95,0x0976,0x1d51,0x0576,0x0176,0x7d76,
0x10c9,0x0591,0x0191,0x7d91,0x4e96,0x1df0,0x29b5,0x0991,
0x2db0,0x2a54,0x1d13,0x0d91,0x158e,0x1915,0x25f2,0x1176,
0x14c9,0x0df3,0x0910,0x1d4e,0x0510,0x4695,0x7d10,0x0110,
0x01f3,0x7df3,0x3632,0x05f3,0x118e,0x09f3,0x0d10,0x1576,
0x1e55,0x21b6,0x2df4,0x1591,0x0d8e,0x254b,0x1110,0x1a53,
0x098e,0x11f3,0x1956,0x2615,0x7d8e,0x018e,0x058e,0x1db4,
0x7ce9,0x00e9,0x04e9,0x0e12,0x08e9,0x1596,0x116e,0x21b1,
0x0ce9,0x0612,0x0212,0x7e12,0x1951,0x3a74,0x15f5,0x0a12,
0x10e9,0x29b3,0x096e,0x52b6,0x056e,0x19f0,0x7d6e,0x016e,
0x31f4,0x1571,0x1913,0x1212,0x3656,0x1d15,0x0d6e,0x254c,
0x14e9,0x0996,0x4674,0x194e,0x0196,0x7d96,0x0df5,0x0596,
0x21ae,0x1171,0x09f5,0x1612,0x05f5,0x0d96,0x7df5,0x01f5,
0x1a55,0x0d71,0x31b0,0x212f,0x2154,0x1196,0x156e,0x1e53,
0x0171,0x7d71,0x1d56,0x0571,0x2613,0x0971,0x11f5,0x19b4,
0x18e9,0x2174,0x35f6,0x154e,0x0d51,0x11f0,0x3254,0x2675,
0x0951,0x31b5,0x1113,0x1a12,0x7d51,0x0151,0x0551,0x1d76,
0x1655,0x09f0,0x0d13,0x1d91,0x01f0,0x7df0,0x196e,0x05f0,
0x0513,0x25d6,0x7d13,0x0113,0x1151,0x0df0,0x0913,0x15b4,
0x1255,0x054e,0x014e,0x7d4e,0x2db3,0x1996,0x1d10,0x094e,
0x4296,0x1df3,0x256c,0x0d4e,0x1551,0x2132,0x19f5,0x11b4,
0x7e55,0x0255,0x0655,0x114e,0x0a55,0x15f0,0x2636,0x0db4,
0x0e55,0x1971,0x1513,0x09b4,0x1d8e,0x05b4,0x01b4,0x7db4,
0x7d09,0x0109,0x0509,0x3a76,0x0909,0x0c95,0x14d0,0x1db1,
0x0d09,0x0895,0x2df1,0x1594,0x0095,0x7c95,0x29d2,0x0495,
0x1109,0x0875,0x3654,0x2970,0x0075,0x7c75,0x31f6,0x0475,
0x0055,0x7c55,0x18f3,0x0455,0x7c15,0x7ff5,0x0035,0x7c35,
0x1509,0x2a32,0x08d0,0x0d94,0x04d0,0x2dcf,0x7cd0,0x00d0,
0x1dae,0x0594,0x0194,0x7d94,0x4676,0x10b5,0x0cd0,0x0994,
0x2d93,0x19b6,0x3a35,0x1d2f,0x1d54,0x0cb5,0x10d0,0x2253,
0x3e12,0x08b5,0x2156,0x1194,0x00b5,0x7cb5,0x256d,0x04b5,
0x1909,0x1d74,0x08b0,0x3e55,0x04b0,0x2993,0x7cb0,0x00b0,
0x3256,0x3a11,0x10f3,0x254d,0x35f4,0x10d5,0x0cb0,0x2176,
0x29cf,0x15b6,0x0cf3,0x2191,0x2e32,0x0cd5,0x10b0,0x25d4,
0x04f3,0x08d5,0x7cf3,0x00f3,0x00d5,0x7cd5,0x08f3,0x04d5,
0x0450,0x11b6,0x7c50,0x0050,0x7c30,0x0030,0x7ff0,0x7c10,
0x2975,0x21f3,0x0870,0x1994,0x0470,0x1d32,0x7c70,0x0070,
0x01b6,0x7db6,0x0890,0x05b6,0x0490,0x09b6,0x7c90,0x0090,
0x2634,0x0db6,0x14f3,0x2dd2,0x218e,0x14d5,0x0c90,0x29f1,
0x1d09,0x1974,0x2995,0x09b1,0x3e53,0x05b1,0x01b1,0x7db1,
0x15ae,0x29f6,0x10d3,0x2212,0x2d90,0x10f5,0x2696,0x0db1,
0x4236,0x31d2,0x0cd3,0x152f,0x1554,0x0cf5,0x216e,0x11b1,
0x04d3,0x08f5,0x7cd3,0x00d3,0x00f5,0x7cf5,0x08d3,0x04f5,
0x0dae,0x4275,0x2e56,0x112f,0x1154,0x2196,0x18f0,0x15b1,
0x7dae,0x01ae,0x05ae,0x1d94,0x09ae,0x1932,0x21f5,0x2973,
0x0954,0x052f,0x012f,0x7d2f,0x7d54,0x0154,0x0554,0x092f,
0x11ae,0x2171,0x14d3,0x0d2f,0x0d54,0x14f5,0x3232,0x3a16,
0x0174,0x7d74,0x0c93,0x0574,0x3ab6,0x0974,0x14f0,0x19b1,
0x0493,0x0d74,0x7c93,0x0093,0x2151,0x1532,0x0893,0x31cf,
0x0473,0x1174,0x7c73,0x0073,0x258d,0x21f0,0x0873,0x2a56,
0x7c33,0x0033,0x7ff3,0x7c13,0x0453,0x18f5,0x7c53,0x0053,
0x31f1,0x1574,0x08f0,0x214e,0x04f0,0x0d32,0x7cf0,0x00f0,
0x19ae,0x0932,0x10b3,0x46b6,0x0132,0x7d32,0x0cf0,0x0532,
0x2255,0x1db6,0x0cb3,0x192f,0x1954,0x3a33,0x10f0,0x2d95,
0x04b3,0x2990,0x7cb3,0x00b3,0x2df6,0x1132,0x08b3,0x21b4,
0x7fea,0x7c0a,0x7c2a,0x002a,0x7c4a,0x004a,0x044a,0x25f4,
0x7c6a,0x006a,0x046a,0x190d,0x086a,0x4a76,0x2e15,0x10ec,
0x7c8a,0x008a,0x048a,0x3a55,0x088a,0x14cb,0x2233,0x0cec,
0x0c8a,0x3e11,0x1536,0x08ec,0x35d4,0x04ec,0x00ec,0x7cec,
0x7caa,0x00aa,0x04aa,0x3213,0x08aa,0x10cb,0x1db2,0x22b6,
0x0caa,0x1e95,0x1136,0x2df2,0x218f,0x25b0,0x1a74,0x29d1,
0x10aa,0x08cb,0x0d36,0x3634,0x00cb,0x7ccb,0x39f0,0x04cb,
0x0536,0x21d3,0x7d36,0x0136,0x4655,0x0ccb,0x0936,0x14ec,
0x7cca,0x00ca,0x04ca,0x0d0d,0x08ca,0x10ab,0x31d6,0x4232,
0x0cca,0x050d,0x010d,0x7d0d,0x1d31,0x39f5,0x1674,0x090d,
0x10ca,0x08ab,0x1e14,0x3e76,0x00ab,0x7cab,0x25b5,0x04ab,
0x3275,0x2654,0x2dd1,0x110d,0x2216,0x0cab,0x29f2,0x18ec,
0x14ca,0x088b,0x3e35,0x1d2e,0x008b,0x7c8b,0x0e74,0x048b,
0x3a12,0x3236,0x0a74,0x150d,0x0674,0x0c8b,0x7e74,0x0274,
0x004b,0x7c4b,0x2192,0x044b,0x7c0b,0x7feb,0x002b,0x7c2b,
0x1daf,0x086b,0x1936,0x2a15,0x006b,0x7c6b,0x1274,0x046b,
0x7cea,0x00ea,0x04ea,0x2e36,0x08ea,0x21d0,0x15b2,0x0c8c,
0x0cea,0x1695,0x39f3,0x088c,0x1931,0x048c,0x008c,0x7c8c,
0x10ea,0x25b3,0x1a14,0x086c,0x3eb6,0x046c,0x006c,0x7c6c,
0x2172,0x044c,0x004c,0x7c4c,0x002c,0x7c2c,0x7c0c,0x7fec,
0x14ea,0x0e95,0x09b2,0x192e,0x05b2,0x3e33,0x7db2,0x01b2,
0x0295,0x7e95,0x2211,0x0695,0x2dd6,0x0a95,0x0db2,0x10ac,
0x31d1,0x4256,0x2e75,0x214f,0x2134,0x18eb,0x11b2,0x0cac,
0x19af,0x1295,0x1d36,0x08ac,0x2a13,0x04ac,0x00ac,0x7cac,
0x18ea,0x31f2,0x1214,0x152e,0x0d31,0x3696,0x216f,0x2a75,
0x0931,0x2e13,0x4ab6,0x1d0d,0x7d31,0x0131,0x0531,0x10cc,
0x0614,0x2235,0x7e14,0x0214,0x3a53,0x14eb,0x0a14,0x0ccc,
0x15af,0x29d6,0x0e14,0x08cc,0x1131,0x04cc,0x00cc,0x7ccc,
0x2276,0x052e,0x012e,0x7d2e,0x3215,0x10eb,0x19b2,0x092e,
0x11af,0x1a95,0x296c,0x0d2e,0x1531,0x2152,0x1e74,0x3e16,
0x0daf,0x08eb,0x1614,0x112e,0x00eb,0x7ceb,0x2a36,0x04eb,
0x7daf,0x01af,0x05af,0x4653,0x09af,0x0ceb,0x21d5,0x14cc,
0x7d0a,0x010a,0x050a,0x0ccd,0x090a,0x1dd0,0x1233,0x16b6,
0x0d0a,0x04cd,0x00cd,0x7ccd,0x158f,0x2e34,0x25d2,0x08cd,
0x110a,0x3296,0x0a33,0x2570,0x0633,0x35f2,0x7e33,0x0233,
0x1d72,0x15d3,0x3e95,0x10cd,0x1a16,0x2555,0x0e33,0x1d0c,
0x150a,0x2632,0x2dd4,0x0ab6,0x0d8f,0x06b6,0x02b6,0x7eb6,
0x098f,0x11d3,0x1e11,0x14cd,0x7d8f,0x018f,0x058f,0x0eb6,
0x3615,0x0dd3,0x1992,0x1d4f,0x1d34,0x190b,0x1633,0x12b6,
0x01d3,0x7dd3,0x2136,0x05d3,0x118f,0x09d3,0x296d,0x4254,
0x190a,0x046d,0x006d,0x7c6d,0x4a95,0x2593,0x1d6f,0x086d,
0x002d,0x7c2d,0x7c0d,0x7fed,0x1216,0x044d,0x004d,0x7c4d,
0x25cf,0x1e35,0x1592,0x0c8d,0x0e16,0x150b,0x1a33,0x29d4,
0x0a16,0x048d,0x008d,0x7c8d,0x7e16,0x0216,0x0616,0x088d,
0x1e76,0x3e14,0x1192,0x0cad,0x35d1,0x110b,0x2550,0x1ab6,
0x2575,0x04ad,0x00ad,0x7cad,0x198f,0x1d52,0x2274,0x08ad,
0x0592,0x090b,0x7d92,0x0192,0x010b,0x7d0b,0x0992,0x050b,
0x2a34,0x19d3,0x0d92,0x10ad,0x1616,0x0d0b,0x1dd5,0x25f1,
0x1d0a,0x09d0,0x2595,0x4a74,0x01d0,0x7dd0,0x196f,0x05d0,
0x1172,0x25f6,0x1611,0x18ed,0x3675,0x0dd0,0x2a96,0x110c,
0x0d72,0x1a35,0x35d6,0x154f,0x1534,0x11d0,0x1e33,0x0d0c,
0x7d72,0x0172,0x0572,0x090c,0x0972,0x050c,0x010c,0x7d0c,
0x1a76,0x2d8d,0x0e11,0x114f,0x1134,0x15d0,0x21b2,0x1eb6,
0x0611,0x2295,0x7e11,0x0211,0x1d8f,0x1952,0x0a11,0x2573,
0x0934,0x054f,0x014f,0x7d4f,0x7d34,0x0134,0x0534,0x094f,
0x1572,0x1dd3,0x1211,0x0d4f,0x0d34,0x3636,0x19d5,0x150c,
0x1676,0x1235,0x096f,0x0ced,0x056f,0x19d0,0x7d6f,0x016f,
0x31d4,0x04ed,0x00ed,0x7ced,0x2131,0x1552,0x0d6f,0x08ed,
0x0235,0x7e35,0x2214,0x0635,0x298d,0x0a35,0x116f,0x2656,
0x1972,0x0e35,0x2553,0x10ed,0x1e16,0x3e74,0x15d5,0x190c,
0x7e76,0x0276,0x0676,0x212e,0x0a76,0x0d52,0x156f,0x3234,
0x0e76,0x0952,0x1a11,0x14ed,0x0152,0x7d52,0x11d5,0x0552,
0x1276,0x1635,0x1d92,0x194f,0x1934,0x1d0b,0x0dd5,0x3613,
0x21af,0x2590,0x09d5,0x2e96,0x05d5,0x1152,0x7dd5,0x01d5,
0x7d2a,0x012a,0x052a,0x09f4,0x092a,0x05f4,0x01f4,0x7df4,
0x0d2a,0x2d8e,0x10b6,0x4675,0x18f1,0x15b0,0x21d2,0x0df4,
0x112a,0x1db3,0x0cb6,0x2170,0x3212,0x3a36,0x19b5,0x11f4,
0x04b6,0x1a54,0x7cb6,0x00b6,0x2df3,0x2155,0x08b6,0x1d2c,
0x152a,0x2232,0x0c96,0x18ee,0x3a75,0x0db0,0x2d91,0x15f4,
0x0496,0x09b0,0x7c96,0x0096,0x01b0,0x7db0,0x0896,0x05b0,
0x0476,0x31f5,0x7c76,0x0076,0x1d14,0x192b,0x0876,0x2a53,
0x7c36,0x0036,0x7ff6,0x7c16,0x0456,0x11b0,0x7c56,0x0056,
0x192a,0x42b6,0x2e53,0x14ee,0x0cf1,0x2193,0x11b5,0x19f4,
0x08f1,0x1254,0x31f0,0x212d,0x7cf1,0x00f1,0x04f1,0x2976,
0x21cf,0x0e54,0x09b5,0x2991,0x05b5,0x152b,0x7db5,0x01b5,
0x0254,0x7e54,0x14d6,0x0654,0x10f1,0x0a54,0x0db5,0x3a13,
0x31b4,0x04ee,0x00ee,0x7cee,0x3e56,0x112b,0x2150,0x08ee,
0x2175,0x29f3,0x10d6,0x0cee,0x14f1,0x19b0,0x2674,0x3255,
0x4233,0x092b,0x0cd6,0x10ee,0x012b,0x7d2b,0x15b5,0x052b,
0x04d6,0x1654,0x7cd6,0x00d6,0x298e,0x0d2b,0x08d6,0x21f1,
0x1d2a,0x11b3,0x2195,0x14ce,0x0cd1,0x2e55,0x4276,0x1df4,
0x08d1,0x21f6,0x2db4,0x2a12,0x7cd1,0x00d1,0x04d1,0x112c,
0x01b3,0x7db3,0x3e32,0x05b3,0x1514,0x09b3,0x296e,0x0d2c,
0x3a15,0x0db3,0x14f6,0x092c,0x10d1,0x052c,0x012c,0x7d2c,
0x2df0,0x04ce,0x00ce,0x7cce,0x1114,0x2996,0x25b2,0x08ce,
0x3253,0x2695,0x10f6,0x0cce,0x14d1,0x1db0,0x29f5,0x2173,
0x0914,0x15b3,0x0cf6,0x10ce,0x7d14,0x0114,0x0514,0x4235,
0x04f6,0x2971,0x7cf6,0x00f6,0x0d14,0x39f2,0x08f6,0x152c,
0x0871,0x04ae,0x00ae,0x7cae,0x7c71,0x0071,0x0471,0x08ae,
0x7c51,0x0051,0x0451,0x0cae,0x7ff1,0x7c11,0x7c31,0x0031,
0x2d96,0x19b3,0x2614,0x10ae,0x0c91,0x29f0,0x1db5,0x2256,
0x0891,0x1e54,0x2153,0x2df5,0x7c91,0x0091,0x0491,0x192c,
0x002e,0x7c2e,0x7c0e,0x7fee,0x0cb1,0x044e,0x004e,0x7c4e,
0x08b1,0x046e,0x006e,0x7c6e,0x7cb1,0x00b1,0x04b1,0x086e,
0x2a55,0x048e,0x008e,0x7c8e,0x1914,0x1d2b,0x31f3,0x088e,
0x25af,0x2190,0x18f6,0x0c8e,0x10b1,0x4eb6,0x2e12,0x29b4,
0x212a,0x1632,0x1d95,0x1170,0x2db6,0x1993,0x0dd2,0x21f4,
0x4274,0x1df6,0x09d2,0x192d,0x05d2,0x1155,0x7dd2,0x01d2,
0x19cf,0x0570,0x0170,0x7d70,0x14f4,0x0d55,0x2633,0x0970,
0x31b1,0x0955,0x1516,0x0d70,0x0155,0x7d55,0x11d2,0x0555,
0x0232,0x7e32,0x35f3,0x0632,0x10f4,0x0a32,0x1950,0x26b6,
0x1975,0x0e32,0x1116,0x2994,0x258f,0x21b0,0x15d2,0x1d73,
0x08f4,0x1232,0x0d16,0x1570,0x7cf4,0x00f4,0x04f4,0x31ae,
0x0516,0x25d3,0x7d16,0x0116,0x0cf4,0x1555,0x0916,0x19f1,
0x11cf,0x0993,0x4696,0x0d2d,0x0193,0x7d93,0x1550,0x0593,
0x1575,0x052d,0x012d,0x7d2d,0x1d11,0x0d93,0x19d2,0x092d,
0x7dcf,0x01cf,0x05cf,0x1970,0x09cf,0x1193,0x21b5,0x1e56,
0x0dcf,0x2254,0x1d53,0x112d,0x2616,0x1955,0x2d94,0x15f1,
0x0d75,0x1a32,0x0950,0x1d0e,0x0550,0x1593,0x7d50,0x0150,
0x7d75,0x0175,0x0575,0x152d,0x0975,0x3a96,0x0d50,0x11f1,
0x15cf,0x29b6,0x2592,0x4e95,0x18f4,0x212b,0x1150,0x0df1,
0x1175,0x1d90,0x1916,0x09f1,0x3653,0x05f1,0x01f1,0x7df1,
0x0595,0x0df6,0x7d95,0x0195,0x10b4,0x25d0,0x0995,0x29b1,
0x01f6,0x7df6,0x0d95,0x05f6,0x1911,0x09f6,0x1dd2,0x1573,
0x08b4,0x21b3,0x1195,0x1d70,0x7cb4,0x00b4,0x04b4,0x1a56,
0x2572,0x11f6,0x1953,0x3a34,0x0cb4,0x1d55,0x35f0,0x212c,
0x0894,0x1e32,0x1595,0x190e,0x7c94,0x0094,0x0494,0x0d73,
0x29ae,0x15f6,0x2611,0x0973,0x0c94,0x0573,0x0173,0x7d73,
0x7c54,0x0054,0x0454,0x254f,0x7ff4,0x7c14,0x7c34,0x0034,
0x0874,0x1990,0x1d16,0x3655,0x7c74,0x0074,0x0474,0x1173,
0x3612,0x2974,0x1995,0x150e,0x0d11,0x1d93,0x256f,0x1256,
0x0911,0x19f6,0x1153,0x1d2d,0x7d11,0x0111,0x0511,0x4295,
0x1dcf,0x2635,0x0d53,0x0a56,0x14d4,0x0656,0x0256,0x7e56,
0x0553,0x1590,0x7d53,0x0153,0x1111,0x2dae,0x0953,0x0e56,
0x2676,0x050e,0x010e,0x7d0e,0x10d4,0x35f5,0x1d50,0x090e,
0x1d75,0x1190,0x3e54,0x0d0e,0x1511,0x2552,0x31b6,0x1973,
0x08d4,0x0d90,0x2db1,0x110e,0x7cd4,0x00d4,0x04d4,0x1656,
0x0190,0x7d90,0x1553,0x0590,0x0cd4,0x0990,0x25d5,0x1df1
};
unsigned char ci,e;
unsigned int s;
unsigned long int tmpword;
tmpword=*golayword;
s=0x7ff&(tmpword^MakeGolayWord(tmpword>>11));
s=correction_table[s];
for(ci=0;ci<3;ci++)
{
e=s&0x1f;
if(e==0x1f) break;
tmpword^=1lu<<e;
s>>=5;
}
*golayword=tmpword;
return ci;
}
//============All foregoing only for demo purposes ====================
#if 0
void InvertBit(unsigned long int *dd,unsigned int bit)
{
*dd^=1lu<<bit;
}
void main(void)
{
int i,j,k,e;
unsigned long int gword,ini_gword;
ini_gword=MakeGolayWord(1234);
ini_gword=0;
printf("\n Single errors");
for(j=0;j<23;j++)
{
gword=ini_gword;
InvertBit(&gword,j);
e=CorrectGolayCode(&gword);
if((e!=1)||(gword!=ini_gword)) printf("\nError!");
}
printf("\n Double errors");
for(i=0;i<23;i++)
{
for(j=i+1;j<23;j++)
{
gword=ini_gword;
InvertBit(&gword,i);
InvertBit(&gword,j);
e=CorrectGolayCode(&gword);
if((e!=2)||(gword!=ini_gword)) printf("\nError!");
}
}
printf("\n Triple errors");
for(k=0;k<23;k++)
{
for(i=k+1;i<23;i++)
{
for(j=i+1;j<23;j++)
{
gword=ini_gword;
InvertBit(&gword,k);
InvertBit(&gword,i);
InvertBit(&gword,j);
e=CorrectGolayCode(&gword);
if((e!=3)||(gword!=ini_gword)) printf("\nError!");
}
}
}
}
#endif