3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef INCLUDED_ENCODER_TURBO_H
24 #define INCLUDED_ENCODER_TURBO_H
26 #include "encoder_convolutional.h"
29 class encoder_turbo : public encoder
33 * class encoder_turbo : public encoder
35 * Encode the incoming streams using a turbo encoder; This is a
36 * virtual class which defines the basics of a turbo encoder, but
37 * not how input and output bits are handled. These features are
38 * all defined by overriding methods appropriately.
41 * n_code_outputs: the total number of code inputs and outputs for the
42 * overall turbo encoder (not just the constituent codes).
44 * encoders: the constituent encoders to be used; all -should- be
45 * configured with the same "block_size" and "termination", though
46 * from this encoder's perspective it doesn't really matter.
48 * interleavers: the interleavers to use before each encoder,
49 * respectively, except the first encoder which will not use an
56 const std::vector<encoder_convolutional*> &encoders,
57 const std::vector<size_t> &interleavers);
59 virtual ~encoder_turbo () {};
61 /* for remote access to internal info */
63 inline bool do_termination () {return (d_do_termination);};
66 virtual size_t compute_n_input_bits (size_t n_output_bits);
67 virtual size_t compute_n_output_bits (size_t n_input_bits);
72 * fsm_enc_turbo_t: finite state machine for the turbo encoder;
73 * output happens all the time, so that's built-in to each state.
75 * fsm_enc_turbo_init: initialize for a new frame / block; this is already
76 * done at instantiation, so do it only at the end of a block.
78 * fsm_enc_turbo_doing_input: doing encoding inside the trellis
80 * fsm_enc_turbo_doing_term: termination trellis, if requested
83 enum fsm_enc_turbo_t {
84 fsm_enc_turbo_init, fsm_enc_turbo_doing_input, fsm_enc_turbo_doing_term
88 * maio(i,o): matrix access into a vector, knowing the # of code
89 * outputs (from inside the class). References into a vector with
90 * code inputs ordered by code output.
92 * 'i' is the first dimension - immediate memory order first - the code input
93 * 'o' is the second dimension - slower memory order second - the code output
95 * returns ((o*n_code_outputs) + i)
98 inline size_t maio(size_t i, size_t o) {return ((o*d_n_code_outputs) + i);};
101 * maoi(i,o): matrix access into a vector, knowing the # of code
102 * inputs (from inside the class). References into a vector with
103 * code outputs ordered by code input.
105 * 'o' is the first dimension - immediate memory order first - the code output
106 * 'i' is the second dimension - slower memory order second - the code input
108 * returns ((i*n_code_inputs) + o)
111 inline size_t maoi(size_t i, size_t o) {return ((i*d_n_code_inputs) + o);};
113 // methods defined in this class
115 // temporary just to get full compilation
117 virtual void encode_private (const char** in_buf, char** out_buf);
118 virtual char get_next_bit (const char** in_buf, size_t code_input_n);
119 virtual void output_bit (char t_out_bit, char** out_buf,
120 size_t t_output_stream);
122 virtual void encode_private (const char** in_buf, char** out_buf) = 0;
123 virtual void encode_loop (const char** in_buf, char** out_buf,
124 size_t* which_counter, size_t how_many) = 0;
125 virtual char get_next_bit (const char** in_buf, size_t code_input_n) = 0;
126 virtual char get_next_bit__term (size_t code_input_n) = 0;
128 // methods which are required by classes which inherit from this
129 // one; primarily just the parts which deal with getting input bits
130 // and writing output bits, changing the indices for those buffers.
132 virtual char get_next_bit__input (const char** in_buf,
133 size_t code_input_n) = 0;
134 virtual void increment_io_indices (bool while_encoding) = 0;
139 fsm_enc_turbo_t d_fsm_state;
140 bool d_do_termination;
141 size_t d_max_memory, d_n_memories;
143 std::vector<encoder_convolutional*> d_encoders;
144 std::vector<size_t> d_interleavers;
147 #endif /* INCLUDED_ENCODER_TURBO_H */