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., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
23 #ifndef INCLUDED_ENCODER_TURBO_H
24 #define INCLUDED_ENCODER_TURBO_H
26 #include "encoder_convolutional.h"
28 typedef std::vector<size_t> interleaver_t;
30 class encoder_turbo : public encoder
34 * class encoder_turbo : public encoder
36 * Encode the incoming streams using a turbo encoder; This is a
37 * virtual class which defines the basics of a turbo encoder, but
38 * not how input and output bits are handled. These features are
39 * all defined by overriding methods appropriately.
42 * n_code_outputs: the total number of code inputs and outputs for the
43 * overall turbo encoder (not just the constituent codes).
45 * encoders: the constituent encoders to be used; all -should- be
46 * configured with the same "block_size" and "termination", though
47 * from this encoder's perspective it doesn't really matter.
49 * interleavers: the interleavers to use before each encoder,
50 * respectively, except the first encoder which will not use an
57 const std::vector<encoder_convolutional*>& encoders,
58 const std::vector<interleaver_t>& interleavers);
60 virtual ~encoder_turbo () {};
62 /* for remote access to internal info */
64 inline const bool do_termination () {return (d_do_termination);};
67 // dummy functions for now
68 virtual size_t compute_n_input_bits (size_t n_output_bits){return(0);};
69 virtual size_t compute_n_output_bits (size_t n_input_bits){return(0);};
74 * fsm_enc_turbo_t: finite state machine for the turbo encoder;
75 * output happens all the time, so that's built-in to each state.
77 * fsm_enc_turbo_init: initialize for a new frame / block; this is already
78 * done at instantiation, so do it only at the end of a block.
80 * fsm_enc_turbo_doing_input: doing encoding inside the trellis
82 * fsm_enc_turbo_doing_term: termination trellis, if requested
85 enum fsm_enc_turbo_t {
86 fsm_enc_turbo_init, fsm_enc_turbo_doing_input, fsm_enc_turbo_doing_term
89 // methods defined in this class
91 // temporary just to get full compilation
93 virtual void encode_private () {};
96 virtual void encode_private () = 0;
97 virtual void encode_loop (size_t* which_counter, size_t how_many) = 0;
98 virtual char get_next_bit (const char** in_buf, size_t code_input_n) = 0;
99 virtual char get_next_bit__term (size_t code_input_n) = 0;
101 // methods which are required by classes which inherit from this
102 // one; primarily just the parts which deal with getting input bits
103 // and writing output bits, changing the indices for those buffers.
105 virtual char get_next_bit__input (const char** in_buf,
106 size_t code_input_n) = 0;
111 fsm_enc_turbo_t d_fsm_state;
112 bool d_do_termination;
113 size_t d_max_memory, d_n_memories;
115 std::vector<encoder_convolutional*> d_encoders;
116 std::vector<size_t> d_interleavers;
119 #endif /* INCLUDED_ENCODER_TURBO_H */