diff options
Diffstat (limited to 'gr-digital/include/gnuradio/digital/constellation.h')
-rw-r--r-- | gr-digital/include/gnuradio/digital/constellation.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/gr-digital/include/gnuradio/digital/constellation.h b/gr-digital/include/gnuradio/digital/constellation.h index 6ee274dd04..b2464aa856 100644 --- a/gr-digital/include/gnuradio/digital/constellation.h +++ b/gr-digital/include/gnuradio/digital/constellation.h @@ -120,6 +120,76 @@ namespace gr { return shared_from_this(); } + /*! \brief Generates the soft decision LUT based on + * constellation and symbol map. + * + * \details Generates the soft decision LUT based on + * constellation and symbol map. It can be given a estimate of + * the noise power in the channel as \p npwr. + * + * \param precision Number of bits of precision on each axis. + * \param npwr Estimate of the noise power (if known). + * + * This is expensive to compute. + */ + void gen_soft_dec_lut(int precision, float npwr=1.0); + + /*! \brief Calculate soft decisions for the given \p sample. + * + * \details Calculate the soft decisions from the given \p sample + * at the given noise power \p npwr. + * + * This is a very costly algorithm (especially for higher order + * modulations) and should be used sparingly. It uses the + * gen_soft_dec_lut function to generate the LUT, which + * should be done once or if a large change in the noise floor + * is detected. + * + * Instead of using this function, generate the LUT using the + * gen_soft_dec_lut after creating the constellation object + * and then use the soft_decision_maker function to return the + * answer from the LUT. + * + * \param sample The complex sample to get the soft decisions. + * \param npwr Estimate of the noise power (if known). + */ + virtual std::vector<float> calc_soft_dec(gr_complex sample, float npwr=1.0); + + /*! \brief Define a soft decision look-up table. + * + * \details Define a soft decision look-up table (LUT). Because + * soft decisions can be calculated in various ways with various + * levels of accuracy and complexity, this function allows + * users to create a LUT in their own way. + * + * Setting the LUT here means that has_soft_dec_lut will return + * true. Decision vectors returned by soft_decision_maker will + * be calculated using this LUT. + * + * \param soft_dec_lut The soft decision LUT as a vector of + * tuples (vectors in C++) of soft decisions. Each + * element of the LUT is a vector of k-bit floats (where + * there are k bits/sample in the constellation). + * \param precision The number of bits of precision used when + * generating the LUT. + */ + void set_soft_dec_lut(const std::vector< std::vector<float> > &soft_dec_lut, + int precision); + + //! Returns True if the soft decision LUT has been defined, False otherwise. + bool has_soft_dec_lut(); + + /*! \brief Returns the soft decisions for the given \p sample. + * + * \details Returns the soft decisions for the given \p + * sample. If a LUT is defined for the object, the decisions + * will be calculated from there. Otherwise, this function will + * call calc_soft_dec directly to calculate the soft decisions. + * + * \param sample The complex sample to get the soft decisions. + */ + std::vector<float> soft_decision_maker(gr_complex sample); + protected: std::vector<gr_complex> d_constellation; std::vector<int> d_pre_diff_code; @@ -130,10 +200,17 @@ namespace gr { //! The factor by which the user given constellation points were //! scaled by to achieve an average amplitude of 1. float d_scalefactor; + float d_re_min, d_re_max, d_im_min, d_im_max; + + std::vector< std::vector<float> > d_soft_dec_lut; + int d_lut_precision; + float d_lut_scale; float get_distance(unsigned int index, const gr_complex *sample); unsigned int get_closest_point(const gr_complex *sample); void calc_arity(); + + void max_min_axes(); }; /************************************************************/ @@ -418,6 +495,10 @@ namespace gr { /*! * \brief Digital constellation for QPSK * \ingroup digital + * + * 01 | 11 + * ------- + * 00 | 10 */ class DIGITAL_API constellation_qpsk : public constellation { @@ -446,6 +527,10 @@ namespace gr { /*! * \brief Digital constellation for DQPSK * \ingroup digital + * + * 01 | 00 + * ------- + * 11 | 10 */ class DIGITAL_API constellation_dqpsk : public constellation { @@ -474,6 +559,12 @@ namespace gr { /*! * \brief Digital constellation for 8PSK * \ingroup digital + * + * 101 | 100 + * 001 | 000 + * ----------------- + * 011 | 010 + * 111 | 110 */ class DIGITAL_API constellation_8psk : public constellation { |