|
20 | 20 | # ============================================================================= |
21 | 21 |
|
22 | 22 | # Number of delay elements in the convolutional encoder |
23 | | -memory1 = np.array(2, ndmin=1) |
| 23 | +memory = np.array(2, ndmin=1) |
24 | 24 |
|
25 | 25 | # Generator matrix |
26 | | -g_matrix1 = np.array((0o5, 0o7), ndmin=2) |
| 26 | +g_matrix = np.array((0o5, 0o7), ndmin=2) |
27 | 27 |
|
28 | 28 | # 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) |
30 | 44 |
|
31 | 45 | # ============================================================================= |
32 | 46 | # Convolutional Code 2: G(D) = [[1, 0, 0], [0, 1, 1+D]]; F(D) = [[D, D], [1+D, 1]] |
33 | 47 | # RSC with rate 2/3 |
34 | 48 | # ============================================================================= |
35 | 49 |
|
36 | 50 | # Number of delay elements in the convolutional encoder |
37 | | -memory2 = np.array((1, 1)) |
| 51 | +memory = np.array((1, 1)) |
38 | 52 |
|
39 | 53 | # 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))) |
41 | 55 | feedback = np.array(((2, 2), (3, 1))) |
42 | 56 |
|
43 | 57 | # Create trellis data structure |
44 | | -trellis2 = cc.Trellis(memory2, g_matrix2, feedback, 'rsc') |
| 58 | +trellis3 = cc.Trellis(memory, g_matrix, feedback, 'rsc') |
45 | 59 |
|
46 | 60 | # ============================================================================= |
47 | 61 | # Basic example using homemade counting and hard decoding |
|
50 | 64 | # Traceback depth of the decoder |
51 | 65 | tb_depth = None # Default value is 5 times the number or memories |
52 | 66 |
|
53 | | -for trellis in (trellis1, trellis2): |
| 67 | +for trellis in (trellis1, trellis2, trellis3): |
54 | 68 | for i in range(10): |
55 | 69 | # Generate random message bits to be encoded |
56 | 70 | message_bits = np.random.randint(0, 2, 1000) |
|
0 commit comments