00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00026 #ifndef __crc_h
00027 #define __crc_h
00028
00029 #include <vector.h>
00030 #include <matrix.h>
00031 #include <string>
00032 namespace SPUC {
00056
00057 class CRC_Code {
00058 public:
00059
00061 CRC_Code() { reverse_parity = false; }
00062
00068 CRC_Code(const string &code) { reverse_parity = false; set_code(code); }
00069
00071 void set_generator(const bvec &poly);
00072
00074 void set_code(const string &code);
00075
00077 void parity(const bvec &in_bits, bvec &out);
00078
00080 bool check_parity(const bvec &coded_bits);
00081
00083 void encode(const bvec &in_bits, bvec &out);
00084
00086 bvec encode(const bvec &in_bits);
00087
00089 bool decode(const bvec &coded_bits, bvec &out);
00090
00092 bool decode(bvec &bits);
00093
00094 private:
00095 bool reverse_parity;
00096 bvec polynomial;
00097 int no_parity;
00098 };
00099 }
00100 #endif // __crc_h