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_GR_STREAMS_ENCODE_CONVOLUTIONAL_H
24 #define INCLUDED_GR_STREAMS_ENCODE_CONVOLUTIONAL_H
27 #include <libecc/encoder_convolutional_ic1_ic1.h>
30 * \brief Encode the incoming streams using a convolutional encoder
32 * input: streams of char, one stream per input as defined by the
33 * instantiated code, using only the right-most justified bit as
34 * the single input bit per input item.
36 * output: streams of char, one stream per output as defined by the
37 * instantiated code, using only the right-most justified bit as
38 * the single output bit per output item.
40 * frame_size_bits: if == 0, then do streaming encoding ("infinite"
41 * trellis); otherwise this is the frame size in bits to encode
42 * before terminating the trellis. This value -does not- include
43 * any termination bits.
47 * code_generator: vector of integers (32 bit) representing the code
48 * to be implemented. E.g. "4" in binary is "100", which would be
49 * "D^2" for code generation. "6" == 110b == "D^2 + D"
50 * ==> The vector is listed in order for each output stream, so if there
51 * are 2 input streams (I1, I2) [specified in "n_code_inputs"]
52 * and 2 output streams (O1, O2) [specified in "n_code_outputs"],
53 * then the vector would be the code generator for:
54 * [I1->O1, I2->O1, I1->O2, I2->O2]
55 * with each element being an integer representation of the code.
57 * do_termination: valid only if frame_size_bits != 0, and defines
58 * whether or not to use trellis termination. Default is to use
59 * termination when doing block coding.
61 * start_memory_state: when starting a new block, the starting memory
62 * state to begin encoding; there will be a helper function to
63 * assist in creating this value for a given set of inputs;
64 * default is the "all zero" state.
66 * end_memory_state: when terminating a block, the ending memory
67 * state to stop encoding; there will be a helper function to
68 * assist in creating this value for a given set of inputs;
69 * default is the "all zero" state.
72 class gr_streams_encode_convolutional;
73 typedef boost::shared_ptr<gr_streams_encode_convolutional>
74 gr_streams_encode_convolutional_sptr;
76 gr_streams_encode_convolutional_sptr
77 gr_make_streams_encode_convolutional
81 const std::vector<int> &code_generator,
82 bool do_termination = true,
83 int start_memory_state = 0,
84 int end_memory_state = 0);
86 gr_streams_encode_convolutional_sptr
87 gr_make_streams_encode_convolutional_feedback
91 const std::vector<int> &code_generator,
92 const std::vector<int> &code_feedback,
93 bool do_termination = true,
94 int start_memory_state = 0,
95 int end_memory_state = 0);
97 class gr_streams_encode_convolutional : public gr_block
99 friend gr_streams_encode_convolutional_sptr
100 gr_make_streams_encode_convolutional
101 (int frame_size_bits,
104 const std::vector<int> &code_generator,
106 int start_memory_state,
107 int end_memory_state);
109 friend gr_streams_encode_convolutional_sptr
110 gr_make_streams_encode_convolutional_feedback
111 (int frame_size_bits,
114 const std::vector<int> &code_generator,
115 const std::vector<int> &code_feedback,
117 int start_memory_state,
118 int end_memory_state);
120 gr_streams_encode_convolutional (int frame_size_bits,
123 const std::vector<int> &code_generator,
125 int start_memory_state,
126 int end_memory_state);
128 gr_streams_encode_convolutional (int frame_size_bits,
131 const std::vector<int> &code_generator,
132 const std::vector<int> &code_feedback,
134 int start_memory_state,
135 int end_memory_state);
137 void setup_io_signatures (int n_code_inputs, int n_code_outputs);
139 encoder_convolutional_ic1_ic1* d_encoder;
142 ~gr_streams_encode_convolutional ();
144 inline encoder_convolutional_ic1_ic1* encoder () {return (d_encoder);};
146 virtual void forecast (int noutput_items,
147 gr_vector_int &ninput_items_required);
149 virtual int general_work (int noutput_items,
150 gr_vector_int &ninput_items,
151 gr_vector_const_void_star &input_items,
152 gr_vector_void_star &output_items);
155 #endif /* INCLUDED_GR_STREAMS_ENCODE_CONVOLUTIONAL_H */