Convolutional encoding class. Supports any k,n with k<n. The input bits of a symbol are clocked simultaneously into the right hand side, or least significant position of the internal registers. Therefore the given polynomial representation of generators should follow the same convention.
More...
#include <CC_Encoding_base.h>
List of all members.
Public Member Functions |
| CC_Encoding_base (const std::vector< unsigned int > &_constraints, const std::vector< std::vector< T_Register > > &_genpoly_representations) |
virtual | ~CC_Encoding_base () |
virtual T_Register & | get_register (unsigned int index)=0 |
bool | encode (const T_IOSymbol &in_symbol, T_IOSymbol &out_symbol, bool no_step=false) |
void | print (std::ostream &os) |
unsigned int | get_k () const |
unsigned int | get_n () const |
unsigned int | get_m () const |
Protected Member Functions |
bool | xorbits (const T_Register ®) |
Protected Attributes |
unsigned int | k |
| Number of input bits or input symbol size in bits.
|
unsigned int | n |
| Number of output bits or output symbol size in bits.
|
unsigned int | m |
| Maximum register length.
|
std::vector< unsigned int > | constraints |
| As many constraints as there are inputs.
|
std::vector< std::vector
< T_Register > > | genpoly_representations |
| As many generator polynomials vectors (the size of the number of outputs) as there are inputs.
|
Detailed Description
template<typename T_Register, typename T_IOSymbol>
class ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >
Convolutional encoding class. Supports any k,n with k<n. The input bits of a symbol are clocked simultaneously into the right hand side, or least significant position of the internal registers. Therefore the given polynomial representation of generators should follow the same convention.
- Template Parameters:
-
T_Register | type of the internal registers |
T_IOSymbol | type used to pass input and output symbols |
Constructor & Destructor Documentation
template<typename T_Register , typename T_IOSymbol >
ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::CC_Encoding_base |
( |
const std::vector< unsigned int > & |
_constraints, |
|
|
const std::vector< std::vector< T_Register > > & |
_genpoly_representations |
|
) |
| [inline] |
Constructor.
- Parameters:
-
_constraints | Vector of register lengths (constraint length + 1). The number of elements determines k. |
_genpoly_representations | Generator polynomial numeric representations. There are as many elements as there are input bits (k). Each element is itself a vector with one polynomial value per output bit. The smallest size of these vectors is retained as the number of output bits n. The input bits of a symbol are clocked simultaneously into the right hand side, or least significant position of the internal registers. Therefore the given polynomial representation of generators should follow the same convention. |
:
k(_constraints.size()),
constraints(_constraints),
genpoly_representations(_genpoly_representations),
m(0)
{
if (k < 1)
{
throw CCSoft_Exception("There must be at least one constraint size");
}
if (k > sizeof(T_IOSymbol)*8)
{
throw CCSoft_Exception("Number of input bits not supported by I/O symbol type");
}
if (genpoly_representations.size() != k)
{
throw CCSoft_Exception("Generator polynomial representations size error");
}
unsigned int min_nb_outputs = genpoly_representations[0].size();
for (unsigned int ci=0; ci < constraints.size(); ci++)
{
if (constraints[ci] > sizeof(T_Register)*8)
{
throw CCSoft_Exception("One constraint size is too large for the size of the registers");
}
if (genpoly_representations[ci].size() < min_nb_outputs)
{
min_nb_outputs = genpoly_representations[ci].size();
}
if (constraints[ci] > m)
{
m = constraints[ci];
}
}
n = min_nb_outputs;
if (n <= k)
{
throw CCSoft_Exception("The number of outputs must be larger than the number of inputs");
}
if (n > sizeof(T_IOSymbol)*8)
{
throw CCSoft_Exception("Number of output bits not supported by I/O symbol type");
}
}
template<typename T_Register , typename T_IOSymbol >
Member Function Documentation
template<typename T_Register , typename T_IOSymbol >
bool ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::encode |
( |
const T_IOSymbol & |
in_symbol, |
|
|
T_IOSymbol & |
out_symbol, |
|
|
bool |
no_step = false |
|
) |
| [inline] |
Encode a new symbol of k bits into a symbol of n bits
- Parameters:
-
in_symbol | Input symbol |
out_symbol | Output symbol |
no_step | Do not step registers before insert (used for assumptions during decoding) |
- Returns:
- true if successful
{
T_IOSymbol w_in = in_symbol;
for (unsigned int ki=0; ki<k; ki++)
{
if (no_step)
{
get_register(ki) >>= 1;
}
get_register(ki) <<= 1;
get_register(ki) += w_in & 1;
w_in >>= 1;
}
out_symbol = 0;
T_IOSymbol symbol_bit;
for (unsigned int ni=0; ni<n; ni++)
{
symbol_bit = 0;
for (unsigned int ki=0; ki<k; ki++)
{
symbol_bit ^= (xorbits(get_register(ki)&genpoly_representations[ki][ni]) ? 1 : 0);
}
out_symbol += symbol_bit << ni;
}
return true;
}
template<typename T_Register , typename T_IOSymbol >
template<typename T_Register , typename T_IOSymbol >
Get the maximum register size
template<typename T_Register , typename T_IOSymbol >
template<typename T_Register , typename T_IOSymbol >
template<typename T_Register , typename T_IOSymbol >
Prints encoding characteristics to an output stream
- Parameters:
-
{
std::cout << "k=" << k << ", n=" << n << ", m=" << m << std::endl;
for (unsigned int ci=0; ci<k; ci++)
{
os << ci << " (" << constraints[ci] << ") : ";
for (unsigned int gi=0; gi<n; gi++)
{
print_register(genpoly_representations[ci][gi], os);
os << " ";
}
os << std::endl;
}
}
template<typename T_Register , typename T_IOSymbol >
XOR all bits in a register. Uses the bit counting method.
- Template Parameters:
-
T_Register | Type of register |
- Parameters:
-
- Returns:
- true=1 or false=0
{
T_Register w_reg = reg;
unsigned int nb_ones = 0;
while(w_reg != 0)
{
nb_ones += w_reg % 2;
w_reg /= 2;
}
return (nb_ones % 2) == 1;
}
Member Data Documentation
template<typename T_Register , typename T_IOSymbol >
As many constraints as there are inputs.
template<typename T_Register , typename T_IOSymbol >
As many generator polynomials vectors (the size of the number of outputs) as there are inputs.
template<typename T_Register , typename T_IOSymbol >
Number of input bits or input symbol size in bits.
template<typename T_Register , typename T_IOSymbol >
template<typename T_Register , typename T_IOSymbol >
Number of output bits or output symbol size in bits.
The documentation for this class was generated from the following file: