Skip to content

Convolutional Encoder

__init__(G=np.array([[121, 91]]))

Inicialize the Convolutional Encoder with the given polynomials \(G\). The default polynomials are \(G_0 = 121_{10}\) and \(G_1 = 91_{10}\).

\[ \begin{equation} \begin{split} G_0 &= 121_{10} \quad \mapsto \quad G_0 = [1, 1, 1, 1, 0, 0, 1] \\ G_1 &= 91_{10} \quad \mapsto \quad G_1 = [1, 0, 1, 1, 0, 1, 1] \end{split} \end{equation} \]

The Convolutional Encoder can be represented by the block diagram below that corresponds to the shift register organization.

pageplot

Parameters:

Name Type Description Default
G ndarray

Tuple of generator polynomials \(G\).

array([[121, 91]])

Examples:

>>> import argos3
>>> import numpy as np
>>>
>>> ut = np.random.randint(0, 2, 30)
>>> encoder = argos3.EncoderConvolutional(G=np.array([[121, 91]]))
>>> vt0, vt1 = encoder.encode(ut)
>>>
>>> print(ut)
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>>
>>> decoder = argos3.DecoderViterbi(G=np.array([[121, 91]]))
>>> ut_prime = decoder.decode(vt0, vt1)
>>>
>>> print(ut_prime)
>>>
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>> print("ut = ut': ", np.array_equal(ut, ut_prime))
ut = ut':  True
  • Bitstream Plot Example: pageplot
Reference:

AS3-SP-516-274-CNES (seção 3.1.4.4)

CCSDS 131.1-G-2

calc_taps(poly)

Generate the taps for each generator polynomial.

Parameters:

Name Type Description Default
poly int

Generator polynomial \(G_n\) in binary format.

required

Returns:

Name Type Description
taps int

List of active tap indices.

calc_free_distance()

Calculate the free distance \(d_{free}\) of the convolutional code, defined as the minimum Hamming distance between any two distinct output sequences.

Returns:

Name Type Description
dist int

Free distance \(d_{free}\) of the convolutional encoder organized with \(G\).

encode(ut)

Encode a binary input sequence \(u_t\), returning the output sequences \(v_t^{(0)}\) and \(v_t^{(1)}\). The encoding process can be represented by the expression below.

\[ \begin{equation} \begin{bmatrix} v_t^{(0)} & v_t^{(1)} \end{bmatrix} = \begin{bmatrix} u_{(t)} & u_{(t-1)} & u_{(t-2)} & u_{(t-3)} & u_{(t-4)} & u_{(t-5)} & u_{(t-6)} \end{bmatrix} \cdot \begin{bmatrix} G_{0} & G_{1} \end{bmatrix}^{T} \end{equation} \]
Where
  • \(v_t^{(0)}\) and \(v_t^{(1)}\): Output channels of the encoder.
  • \(u_t\): Input bit vector.
  • \(G_{0}\) and \(G_{1}\): Generator polynomials of the encoder.

Parameters:

Name Type Description Default
ut ndarray

Input bit vector \(u_t\) to be encoded.

required

Returns:

Name Type Description
tuple (ndarray, ndarray)

Tuple with the two output channels \(v_t^{(0)}\) and \(v_t^{(1)}\).

__init__(G=np.array([[121, 91]]), decision='hard')

Initialize the Viterbi decoder, based on a tuple of generator polynomials \(G\) that determine the structure of the decoder.

\[ \begin{equation} \begin{split} G_0 &= 121_{10} \quad \mapsto \quad G_0 = [1, 1, 1, 1, 0, 0, 1] \\ G_1 &= 91_{10} \quad \mapsto \quad G_1 = [1, 0, 1, 1, 0, 1, 1] \end{split} \end{equation} \]

Parameters:

Name Type Description Default
G ndarray

Tuple of generator polynomials \(G\).

array([[121, 91]])
decision str

Decision type, either "hard" or "soft".

'hard'

Raises:

Type Description
ValueError

If decision is not "hard" or "soft".

Examples:

>>> import argos3
>>> import numpy as np
>>>
>>> ut = np.random.randint(0, 2, 30)
>>> encoder = argos3.EncoderConvolutional(G=np.array([[121, 91]]))
>>> vt0, vt1 = encoder.encode(ut)
>>>
>>> print(ut)
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>>
>>> decoder = argos3.DecoderViterbi(G=np.array([[121, 91]]))
>>> ut_prime = decoder.decode(vt0, vt1)
>>>
>>> print(ut_prime)
>>>
[1 0 0 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1]
>>> print("ut = ut': ", np.array_equal(ut, ut_prime))
ut = ut':  True
  • Bitstream Plot Example: pageplot
References:

https://rwnobrega.page/apontamentos/codigos-convolucionais/

AS3-SP-516-274-CNES (seção 3.1.4.4)

https://dsplog.com/2009/01/14/soft-viterbi/

build_trellis()

Build the trellis for the Viterbi decoder based on the generator polynomials \(G\).

Returns:

Name Type Description
trellis dict

Trellis for the Viterbi decoder.

branch_metric(trellis_symbol, received_symbol)

Calculate the branch metric depending on the decision type for the Viterbi decoder.

For Hard Decision uses Hamming distance, given by the expression below.

\[ \begin{equation} \begin{split} d_{hamming} &= \sum_{i=0}^{N-1} |r_i - s_i| \end{split} \end{equation} \]
Where
  • \(d_{hamming}\): Hamming distance.
  • \(r_i\): Received bit.
  • \(s_i\): Expected trellis output bit.

Examples:

  • Bitstream Plot Example: pageplot

For Soft Decision uses Euclidean distance, given by the expression below.

\[{ \begin{equation} \begin{split} d_{euclidean} &= \sum_{i=0}^{N-1} (r_i - s_i)^2 \end{split} \end{equation} }\]
Where
  • \(d_{euclidean}\): Euclidean distance.
  • \(r_i\): Received symbol.
  • \(s_i\): Expected trellis output symbol.

Examples:

Soft Decision Example:

  • Stream: pageplot
  • Sampling: pageplot
  • Decoding: pageplot

Parameters:

Name Type Description Default
trellis_symbol ndarray

Expected trellis output symbol, based on the trellis state.

required
received_symbol ndarray

Received symbol.

required

Returns:

Name Type Description
metric float

Branch metric.

decode(vt0, vt1)

Decode the bits of the input \(v_t^{(0)}\) and \(v_t^{(1)}\), returning the decoded bits \(u_t\).

Parameters:

Name Type Description Default
vt0 ndarray

Bits of the input channel I.

required
vt1 ndarray

Bits of the input channel Q.

required

Returns:

Name Type Description
ut_hat ndarray

Decoded bits.