commpy.channelcoding.Trellis¶
-
class
Trellis
(memory, g_matrix, feedback=0, code_type='default')¶ Class defining a Trellis corresponding to a k/n - rate convolutional code. :param memory: Number of memory elements per input of the convolutional encoder. :type memory: 1D ndarray of ints :param g_matrix: Generator matrix G(D) of the convolutional encoder. Each element of
G(D) represents a polynomial.Parameters: - feedback (int, optional) – Feedback polynomial of the convolutional encoder. Default value is 00.
- code_type ({'default', 'rsc'}, optional) – Use ‘rsc’ to generate a recursive systematic convolutional code. If ‘rsc’ is specified, then the first ‘k x k’ sub-matrix of G(D) must represent a identity matrix along with a non-zero feedback polynomial.
-
k
¶ Size of the smallest block of input bits that can be encoded using the convolutional code.
Type: int
-
n
¶ Size of the smallest block of output bits generated using the convolutional code.
Type: int
-
total_memory
¶ Total number of delay elements needed to implement the convolutional encoder.
Type: int
-
number_states
¶ Number of states in the convolutional code trellis.
Type: int
-
number_inputs
¶ Number of branches from each state in the convolutional code trellis.
Type: int
-
next_state_table
¶ Table representing the state transition matrix of the convolutional code trellis. Rows represent current states and columns represent current inputs in decimal. Elements represent the corresponding next states in decimal.
Type: 2D ndarray of ints
-
output_table
¶ Table representing the output matrix of the convolutional code trellis. Rows represent current states and columns represent current inputs in decimal. Elements represent corresponding outputs in decimal.
Type: 2D ndarray of ints
Examples
>>> from numpy import array >>> import commpy.channelcoding.convcode as cc >>> memory = array([2]) >>> g_matrix = array([[0o5, 0o7]]) # G(D) = [1+D^2, 1+D+D^2] >>> trellis = cc.Trellis(memory, g_matrix) >>> print trellis.k 1 >>> print trellis.n 2 >>> print trellis.total_memory 2 >>> print trellis.number_states 4 >>> print trellis.number_inputs 2 >>> print trellis.next_state_table [[0 2] [0 2] [1 3] [1 3]] >>>print trellis.output_table [[0 3] [3 0] [1 2] [2 1]]
-
__init__
(memory, g_matrix, feedback=0, code_type='default')¶
Methods
__init__
(memory, g_matrix[, feedback, code_type])visualize
([trellis_length, state_order, …])Plot the trellis diagram.