Main Page | Class List | File List | Class Members | File Members

bch.h

Go to the documentation of this file.
00001 /* BCH.H */
00002 
00003 #ifndef _BCH_H_
00004 #define _BCH_H_
00005 
00006 typedef enum { BCHNONE, BCH15_5, BCH15_7, BCH15_11, BCH31_6, BCH31_11, BCH63_7, BCH63_10, GOLAY23_12,} bch_type;
00007 
00008 /* bch.h
00009  *
00010  * Brendan Dowling 9/20/95
00011  * Max Luttrell 9/96
00012  */
00013 
00014 
00015 static void generate_gf();
00016 /*
00017  * Generate field GF(2**m) from the irreducible polynomial p(X) with
00018  * coefficients in p[0]..p[m].
00019  *
00020  * Lookup tables:
00021  *   index->polynomial form: alpha_to[] contains j=alpha^i;
00022  *   polynomial form -> index form:     index_of[j=alpha^i] = i
00023  *
00024  * alpha=2 is the primitive element of GF(2**m)
00025  */
00026 
00027 
00028 static void gen_poly();
00029 /*
00030  * Compute the generator polynomial of a binary BCH code. Fist generate the
00031  *   cycle sets modulo 2**m - 1, cycle[][] =  (i, 2*i, 4*i, ..., 2^l*i). Then
00032  *   determine those cycle sets that contain integers in the set of (d-1)
00033  *   consecutive integers {1..(d-1)}. The generator polynomial is calculated
00034  *   as the product of linear factors of the form (x+alpha^i), for every i in
00035  *   the above cycle sets.
00036  */
00037 
00038 void encode_bch(unsigned long bits, byte *block, bch_type type);
00039 /*
00040  * This function takes the bits and inserts the bch bits into
00041  *   the (header) block 
00042  */
00043 
00044 int decode_bch(unsigned long *bits, byte *block, bch_type type, int t0);
00045 /*
00046  * This function takes a header & decodes the bch putting result in bits
00047  *
00048  * For detection mode:
00049  *   Returns 1 if decoding ok.
00050  *   Returns 0 if decoding not ok.
00051  *
00052  * For correction mode,
00053  *   always returns 1
00054  *
00055  * correction is 0 if bch codec used for detection, 1 if for correction
00056  *   at this point, only correction mode works properly
00057  */
00058 
00059 bch_type strtobch_type(char *str);
00060 /*
00061  * This function takes a string (such as "BCH15_5") and
00062  *   returns a bch_type (which looks almost identical, i.e. BCH15_5)
00063  */
00064 
00065 int code_length(bch_type b);
00066 /*
00067  * This function takes a bch_type (such as the one returned above)
00068  *   and returns the number of bits total that the bch code will be
00069  *   i.e. BCH15_5 will return 15
00070  */
00071 
00072 int info_length(bch_type b);
00073 /*
00074  * This function does the same as code_length() but it returns the
00075  *   info part instead. i.e. BCH15_5 will return 5
00076  */
00077 
00078 char *bch_type_str(bch_type type);
00079 /*
00080  * This function take and type and returns the string equivalent,
00081  *   kind of like a reverse strtobch_type()
00082  */
00083 
00084 #endif

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1