GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
viterbi_decoder_sbas.h
Go to the documentation of this file.
1 /*!
2  * \file viterbi_decoder_sbas.h
3  * \brief Interface of a Viterbi decoder class based on the Iterative Solutions
4  * Coded Modulation Library by Matthew C. Valenti
5  * \author Daniel Fehr 2013. daniel.co(at)bluewin.ch
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 #ifndef GNSS_SDR_VITERBI_DECODER_SBAS_H
19 #define GNSS_SDR_VITERBI_DECODER_SBAS_H
20 
21 #include <cstddef> // for size_t
22 #include <deque>
23 #include <vector>
24 
25 /** \addtogroup Telemetry_Decoder
26  * \{ */
27 /** \addtogroup Telemetry_Decoder_libs telemetry_decoder_libs
28  * \{ */
29 
30 
31 /*!
32  * \brief Class that implements a Viterbi decoder
33  */
35 {
36 public:
37  Viterbi_Decoder_Sbas(const int g_encoder[], int KK, int nn);
38 
39  void reset();
40 
41  /*!
42  * \brief Uses the Viterbi algorithm to perform hard-decision decoding of a convolutional code.
43  *
44  * \param[in] input_c[] The received signal in LLR-form. For BPSK, must be in form r = 2*a*y/(sigma^2).
45  * \param[in] LL The number of data bits to be decoded (does not include the mm zero-tail-bits)
46  *
47  * \return output_u_int[] Hard decisions on the data bits (without the mm zero-tail-bits)
48  */
49  float decode_block(const double input_c[], int* output_u_int, int LL);
50 
51  float decode_continuous(const double sym[], int traceback_depth, int bits[],
52  int nbits_requested, int& nbits_decoded);
53 
54 private:
55  class Prev
56  {
57  public:
58  int num_states;
59  Prev(int states, int tt);
60  Prev(const Prev& prev);
61  Prev& operator=(const Prev& other);
62  ~Prev();
63 
64  int get_anchestor_state_of_current_state(int current_state) const;
65  int get_bit_of_current_state(int current_state) const;
66  float get_metric_of_current_state(int current_state) const;
67  int get_t() const;
68  void set_current_state_as_ancestor_of_next_state(int next_state, int current_state);
69  void set_decoded_bit_for_next_state(int next_state, int bit);
70  void set_survivor_branch_metric_of_next_state(int next_state, float metric);
71 
72  private:
73  std::vector<float> v_metric;
74  std::vector<int> state;
75  std::vector<int> v_bit;
76  int t;
77  int refcount;
78  };
79 
80  // operations on the trellis (change decoder state)
81  void init_trellis_state();
82  int do_acs(const double sym[], int nbits);
83  int do_traceback(std::size_t traceback_length);
84  int do_tb_and_decode(int traceback_length, int requested_decoding_length, int state, int output_u_int[], float& indicator_metric);
85 
86  // branch metric function
87  float gamma(const float rec_array[], int symbol, int nn);
88 
89  // trellis generation
90  void nsc_transit(int output_p[], int trans_p[], int input, const int g[], int KK, int nn);
91  int nsc_enc_bit(int state_out_p[], int input, int state_in, const int g[], int KK, int nn);
92  int parity_counter(int symbol, int length);
93 
94  // trellis state
95  std::deque<Prev> d_trellis_paths;
96  std::vector<float> d_pm_t;
97  std::vector<float> d_metric_c; /* Set of all possible branch metrics */
98  std::vector<float> d_rec_array; /* Received values for one trellis section */
99 
100  // trellis definition
101  std::vector<int> d_out0;
102  std::vector<int> d_state0;
103  std::vector<int> d_out1;
104  std::vector<int> d_state1;
105 
106  // measures
107  float d_indicator_metric;
108 
109  // code properties
110  int d_KK;
111  int d_nn;
112 
113  // derived code properties
114  int d_mm;
115  int d_states;
116  int d_number_symbols;
117  bool d_trellis_state_is_initialised;
118 };
119 
120 
121 /** \} */
122 /** \} */
123 #endif // GNSS_SDR_VITERBI_DECODER_SBAS_H
Class that implements a Viterbi decoder.
float decode_block(const double input_c[], int *output_u_int, int LL)
Uses the Viterbi algorithm to perform hard-decision decoding of a convolutional code.