Skip to content

Commit f2bd540

Browse files
committed
Specifies in the doc the bit ordering when building triellis
1 parent f4c68b9 commit f2bd540

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

commpy/channelcoding/convcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Trellis:
3333
Number of memory elements per input of the convolutional encoder.
3434
g_matrix : 2D ndarray of ints (decimal representation)
3535
Generator matrix G(D) of the convolutional encoder. Each element of
36-
G(D) represents a polynomial.
36+
G(D) represents a polynomial with a MSB first convention (ie, 1+D^2+D^3 <-> 1101 <-> 13 or 0o15).
3737
Coef [i,j] is the influence of input i on output j.
3838
feedback : 2D ndarray of ints (decimal representation), optional
3939
Feedback matrix F(D) of the convolutional encoder. Each element of

commpy/examples/conv_encode_decode.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,42 @@
2020
# =============================================================================
2121

2222
# Number of delay elements in the convolutional encoder
23-
memory1 = np.array(2, ndmin=1)
23+
memory = np.array(2, ndmin=1)
2424

2525
# Generator matrix
26-
g_matrix1 = np.array((0o5, 0o7), ndmin=2)
26+
g_matrix = np.array((0o5, 0o7), ndmin=2)
2727

2828
# Create trellis data structure
29-
trellis1 = cc.Trellis(memory1, g_matrix1)
29+
trellis1 = cc.Trellis(memory, g_matrix)
30+
31+
# =============================================================================
32+
# Convolutional Code 1: G(D) = [1+D^2, 1+D^2+D^3]
33+
# Standard code with rate 1/2
34+
# =============================================================================
35+
36+
# Number of delay elements in the convolutional encoder
37+
memory = np.array(3, ndmin=1)
38+
39+
# Generator matrix (1+D^2+D^3 <-> 13 or 0o15)
40+
g_matrix = np.array((0o5, 0o15), ndmin=2)
41+
42+
# Create trellis data structure
43+
trellis2 = cc.Trellis(memory, g_matrix)
3044

3145
# =============================================================================
3246
# Convolutional Code 2: G(D) = [[1, 0, 0], [0, 1, 1+D]]; F(D) = [[D, D], [1+D, 1]]
3347
# RSC with rate 2/3
3448
# =============================================================================
3549

3650
# Number of delay elements in the convolutional encoder
37-
memory2 = np.array((1, 1))
51+
memory = np.array((1, 1))
3852

3953
# Generator matrix & feedback matrix
40-
g_matrix2 = np.array(((1, 0, 0), (0, 1, 3)))
54+
g_matrix = np.array(((1, 0, 0), (0, 1, 3)))
4155
feedback = np.array(((2, 2), (3, 1)))
4256

4357
# Create trellis data structure
44-
trellis2 = cc.Trellis(memory2, g_matrix2, feedback, 'rsc')
58+
trellis3 = cc.Trellis(memory, g_matrix, feedback, 'rsc')
4559

4660
# =============================================================================
4761
# Basic example using homemade counting and hard decoding
@@ -50,7 +64,7 @@
5064
# Traceback depth of the decoder
5165
tb_depth = None # Default value is 5 times the number or memories
5266

53-
for trellis in (trellis1, trellis2):
67+
for trellis in (trellis1, trellis2, trellis3):
5468
for i in range(10):
5569
# Generate random message bits to be encoded
5670
message_bits = np.random.randint(0, 2, 1000)

0 commit comments

Comments
 (0)