40 it_assert(
poly(0) == 1,
"CRC_Code::set_polynomial: not a valid polynomial");
42 no_parity = polynomial.size() - 1;
48 {
"CRC-4",
"1 1 1 1 1"},
49 {
"CRC-7",
"1 1 0 1 0 0 0 1"},
50 {
"CRC-8",
"1 1 1 0 1 0 1 0 1"},
51 {
"CRC-12",
"1 1 0 0 0 0 0 0 0 1 1 1 1"},
52 {
"CRC-24",
"1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1"},
53 {
"CRC-32",
"1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0"},
54 {
"CCITT-4",
"1 0 0 1 1"},
55 {
"CCITT-5",
"1 1 0 1 0 1"},
56 {
"CCITT-6",
"1 0 0 0 0 1 1"},
57 {
"CCITT-16",
"1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1"},
58 {
"CCITT-32",
"1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 1 0 1 1 0 1 1 1"},
59 {
"WCDMA-8",
"1 1 0 0 1 1 0 1 1"},
60 {
"WCDMA-12",
"1 1 0 0 0 0 0 0 0 1 1 1 1"},
61 {
"WCDMA-16",
"1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1"},
62 {
"WCDMA-24",
"1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1"},
63 {
"ATM-8",
"1 0 0 0 0 0 1 1 1"},
64 {
"ANSI-16",
"1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1"},
65 {
"SDLC-16",
"1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 1 1"},
73 for (
int i = 0;
i < 18;
i++) {
78 if ((code ==
"WCDMA-8") || (code ==
"WCDMA-12") || (code ==
"WCDMA-16") || (code ==
"WCDMA-24")) {
79 reverse_parity =
true;
91 for (
int i = 0;
i <
temp.
size() - polynomial.size() + 1;
i++) {
93 temp.set_subvector(
i,
temp(
i,
i + no_parity) + polynomial);
111 if (reverse_parity) {
118 for (
int i = 0;
i <
temp.
size() - polynomial.size() + 1;
i++) {
120 temp.set_subvector(
i,
temp(
i,
i + no_parity) + polynomial);
int size() const
Returns the number of data elements in the array object.
Array< T > left(int n) const
Get n left elements of the array.
Array< T > right(int n) const
Get n right elements of the array.
void set_generator(const bvec &poly)
Set an arbitary polynomial in bvec form. Start with highest order terms.
void set_code(const std::string &code)
Set CRC code to one of the standardpolynomials using the string value.
void encode(const bvec &in_bits, bvec &out) const
Calculate and add parity to the in_bits.
bool check_parity(const bvec &coded_bits) const
Return true if parity checks OK otherwise flase.
void parity(const bvec &in_bits, bvec &out) const
Calulate the parity bits.
bool decode(const bvec &coded_bits, bvec &out) const
Return true if parity checks OK otherwise flase. Also returns the message part in out.
Definition of a CRC code class.
#define it_assert(t, s)
Abort if t is not true.
void poly(const vec &r, vec &p)
Create a polynomial of the given roots.
Vec< T > reverse(const Vec< T > &in)
Reverse the input vector.
ITPP_EXPORT bvec zeros_b(int size)
A Binary vector of zeros.
Various functions on vectors and matrices - header file.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
Definitions of special vectors and matrices.