00001
00029 #ifndef TURBO_H
00030 #define TURBO_H
00031
00032 #include <itpp/comm/rec_syst_conv_code.h>
00033 #include <itpp/comm/interleave.h>
00034 #include <itpp/comm/llr.h>
00035
00036
00037 namespace itpp
00038 {
00039
00054 class Turbo_Codec
00055 {
00056 public:
00057
00059 Turbo_Codec(void) {}
00060
00062 virtual ~Turbo_Codec(void) {}
00063
00084 void set_parameters(ivec gen1, ivec gen2, int constraint_length,
00085 const ivec &interleaver_sequence, int in_iterations = 8,
00086 std::string in_metric = "LOGMAX", double in_logmax_scale_factor = 1.0,
00087 bool in_adaptive_stop = false, LLR_calc_unit lcalc = LLR_calc_unit());
00088
00095 void set_interleaver(const ivec &interleaver_sequence);
00096
00109 void set_metric(std::string in_metric = "LOGMAX", double in_logmax_scale_factor = 1.0,
00110 LLR_calc_unit lcalc = LLR_calc_unit());
00111
00115 void set_iterations(int in_iterations = 8);
00116
00123 void set_adaptive_stop(bool in_adaptive_stop = true);
00124
00131 void set_awgn_channel_parameters(double in_Ec, double in_N0);
00132
00155 void set_scaling_factor(double in_Lc);
00156
00176 void encode(const bvec &input, bvec &output);
00177
00189 virtual void decode(const vec &received_signal, bvec &decoded_bits, const bvec &true_bits = "0");
00190
00203 virtual void decode(const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations,
00204 const bvec &true_bits = "0");
00205
00222 void encode_block(const bvec &input, bvec &in1, bvec &in2, bmat &parity1, bmat &parity2);
00223
00253 virtual void decode_block(const vec &rec_syst1, const vec &rec_syst2, const mat &rec_parity1, const mat &rec_parity2,
00254 bmat &decoded_bits_i, int &nrof_used_iterations_i, const bvec &true_bits = "0");
00255
00257 int get_Ncoded() const { return Ncoded; }
00258
00260 int get_Nuncoded() const { return Nuncoded; }
00261
00262 private:
00263
00267 void decode_n3(const vec &received_signal, bvec &decoded_bits, ivec &nrof_used_iterations,
00268 const bvec &true_bits = "0");
00269
00270
00271 int interleaver_size;
00272 int Ncoded, Nuncoded;
00273 int m_tail, n1, n2, n_tot, iterations;
00274 double Ec, N0, Lc, R, logmax_scale_factor;
00275 bool adaptive_stop;
00276 std::string metric;
00277
00278
00279 bvec decoded_bits_previous_iteration;
00280
00281
00282 Rec_Syst_Conv_Code rscc1, rscc2;
00283 Sequence_Interleaver<bin> bit_interleaver;
00284 Sequence_Interleaver<double> float_interleaver;
00285 };
00286
00291 ivec wcdma_turbo_interleaver_sequence(int interleaver_size);
00292
00293 }
00294
00295 #endif // #ifndef TURBO_H