ccsoft  0.0.0
Convolutional codes library with soft decision decoding
ccsoft::CC_Encoding_base< T_Register, T_IOSymbol > Class Template Reference

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>

Inheritance diagram for ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >:

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 &reg)

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_Registertype of the internal registers
T_IOSymboltype 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:
_constraintsVector of register lengths (constraint length + 1). The number of elements determines k.
_genpoly_representationsGenerator 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 >
virtual ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::~CC_Encoding_base ( ) [inline, virtual]

Destructor

    {}

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_symbolInput symbol
out_symbolOutput symbol
no_stepDo not step registers before insert (used for assumptions during decoding)
Returns:
true if successful
    {
        T_IOSymbol w_in = in_symbol;

        // load registers with new symbol bits
        for (unsigned int ki=0; ki<k; ki++)
        {
            if (no_step)
            {
                get_register(ki) >>= 1; // flush bit
            }
            get_register(ki) <<= 1; // make room for bit
            get_register(ki) += w_in & 1; // insert bit
            w_in >>= 1; // move to next input bit
        }

        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;
    }

Here is the call graph for this function:

template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::get_k ( ) const [inline]

Get the k parameter

    {
        return k;
    }
template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::get_m ( ) const [inline]

Get the maximum register size

    {
        return m;
    }
template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::get_n ( ) const [inline]

Get the n paramater

    {
        return n;
    }
template<typename T_Register , typename T_IOSymbol >
virtual T_Register& ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::get_register ( unsigned int  index) [pure virtual]

Get a R/W reference to a regiser

Parameters:
indexIndex of the register

Implemented in ccsoft::CC_Encoding< T_Register, T_IOSymbol >, and ccsoft::CC_Encoding_FA< T_Register, T_IOSymbol, N_k >.

template<typename T_Register , typename T_IOSymbol >
void ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::print ( std::ostream &  os) [inline]

Prints encoding characteristics to an output stream

Parameters:
osThe output stream
    {
        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;
        }
    }

Here is the call graph for this function:

template<typename T_Register , typename T_IOSymbol >
bool ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::xorbits ( const T_Register &  reg) [inline, protected]

XOR all bits in a register. Uses the bit counting method.

Template Parameters:
T_RegisterType of register
Parameters:
regRegister
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 >
std::vector<unsigned int> ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::constraints [protected]

As many constraints as there are inputs.

template<typename T_Register , typename T_IOSymbol >
std::vector<std::vector<T_Register> > ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::genpoly_representations [protected]

As many generator polynomials vectors (the size of the number of outputs) as there are inputs.

template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::k [protected]

Number of input bits or input symbol size in bits.

template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::m [protected]

Maximum register length.

template<typename T_Register , typename T_IOSymbol >
unsigned int ccsoft::CC_Encoding_base< T_Register, T_IOSymbol >::n [protected]

Number of output bits or output symbol size in bits.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines