Convolution Encoder MATLAB Source Code

This section provides the MATLAB source code for a Convolution Encoder. The code is validated against MATLAB’s built-in functions.

convolution encoder convolution encoder

Specifications

The implemented Convolution Encoder has the following specifications:

  • Coding rate: 1/3
  • Constraint length: 5
  • Output bit length: 3
  • Message bit length: 1
  • Maximal memory order / No. of memory elements = 4
  • Generator Polynomials: 25 (8), 33 (8), 37 (8)

MATLAB Code

%function [Conv_out] = conv_encoder(Conv_In)
Conv_In= [1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1 0];
% x=[1 0 1 1 0 0 0];
m1=0;
m2=0;
m3=0;
m4=0;

%% m_in m1 m2 m3 m4
%%[1   0   1  0  1] =x0
%%[1   1   0  1  1] =x1
%%[1   1   1  1  1] =x2;

for k = 1:length(Conv_In)

    %%1st polynomial
    %%x0= [1 0 1 0 1]
    m_in   =   Conv_In(k); %first polynomial
    temp1  =   bitxor(m_in,m2);
    x0     =   bitxor(temp1,m4);

    %2nd polynomial
    temp1  =   bitxor(m_in,m1);
    temp2  =   bitxor(temp1,m3);
    x1     =   bitxor(temp2,m4);

    %3rd polynomial
    temp1  =   bitxor(m_in,m1);
    temp2  =   bitxor(temp1,m2);
    temp3  =   bitxor(temp2,m3);
    x2     =   bitxor(temp3,m4);

    Conv_out((3*k)-2)    = x0;
    Conv_out((3*k)-1)    = x1;
    Conv_out(3*k)        = x2;

    %%%Shifiting
    m4=m3;
    m3=m2;
    m2=m1;
    m1=m_in;

end