diff options
-rw-r--r-- | gr-blocks/lib/tag_debug_impl.cc | 4 | ||||
-rw-r--r-- | gr-digital/include/digital/constellation.h | 82 | ||||
-rw-r--r-- | gr-digital/lib/constellation.cc | 39 | ||||
-rw-r--r-- | gr-digital/python/__init__.py | 1 | ||||
-rw-r--r-- | gr-digital/python/qam.py | 4 | ||||
-rw-r--r-- | gr-digital/swig/constellation.i | 6 |
6 files changed, 118 insertions, 18 deletions
diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc index a216879637..c595d41db5 100644 --- a/gr-blocks/lib/tag_debug_impl.cc +++ b/gr-blocks/lib/tag_debug_impl.cc @@ -95,8 +95,8 @@ namespace gr { for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { sout << std::setw(10) << "Offset: " << d_tags_itr->offset << std::setw(10) << "Source: " - << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a") - << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key) + << (pmt::is_symbol(d_tags_itr->srcid) ? pmt::symbol_to_string(d_tags_itr->srcid) : "n/a") + << std::setw(10) << "Key: " << pmt::symbol_to_string(d_tags_itr->key) << std::setw(10) << "Value: "; sout << d_tags_itr->value << std::endl; } diff --git a/gr-digital/include/digital/constellation.h b/gr-digital/include/digital/constellation.h index 330ed03131..ee7a704eb6 100644 --- a/gr-digital/include/digital/constellation.h +++ b/gr-digital/include/digital/constellation.h @@ -164,7 +164,7 @@ namespace gr { // void calc_euclidean_metric(gr_complex *sample, float *metric); // void calc_hard_symbol_metric(gr_complex *sample, float *metric); - private: + protected: constellation_calcdist(std::vector<gr_complex> constell, std::vector<int> pre_diff_code, unsigned int rotational_symmetry, @@ -246,6 +246,15 @@ namespace gr { ~constellation_rect(); protected: + + constellation_rect(std::vector<gr_complex> constell, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors); + unsigned int get_sector(const gr_complex *sample); unsigned int calc_sector_value(unsigned int sector); @@ -255,18 +264,64 @@ namespace gr { unsigned int n_imag_sectors; float d_width_real_sectors; float d_width_imag_sectors; - - constellation_rect(std::vector<gr_complex> constell, - std::vector<int> pre_diff_code, - unsigned int rotational_symmetry, - unsigned int real_sectors, - unsigned int imag_sectors, - float width_real_sectors, - float width_imag_sectors); }; /************************************************************/ + /* constellation_expl_rect */ + /************************************************************/ + + /*! + * \brief Rectangular digital constellation + * \ingroup digital + * + * Only implemented for 1-(complex)dimensional constellation. + * + * Constellation space is divided into rectangular sectors. Each + * sector is associated with the nearest constellation point. + * + * This class is different from constellation_rect in that the + * mapping from sector to constellation point is explicitly passed + * into the constructor as sector_values. Usually we do not need + * this, since we want each sector to be automatically mapped to + * the closest constellation point, however sometimes it's nice to + * have the flexibility. + */ + class DIGITAL_API constellation_expl_rect + : public constellation_rect + { + public: + typedef boost::shared_ptr<constellation_expl_rect> sptr; + + static sptr make(std::vector<gr_complex> constellation, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values); + ~constellation_expl_rect(); + + protected: + constellation_expl_rect(std::vector<gr_complex> constellation, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values); + + unsigned int calc_sector_value (unsigned int sector) { + return d_sector_values[sector]; + } + + private: + std::vector<unsigned int> d_sector_values; + }; + + /************************************************************/ /* constellation_psk */ /************************************************************/ @@ -299,7 +354,6 @@ namespace gr { unsigned int calc_sector_value(unsigned int sector); - private: constellation_psk(std::vector<gr_complex> constell, std::vector<int> pre_diff_code, unsigned int n_sectors); @@ -329,7 +383,7 @@ namespace gr { unsigned int decision_maker(const gr_complex *sample); - private: + protected: constellation_bpsk(); }; @@ -357,7 +411,7 @@ namespace gr { unsigned int decision_maker(const gr_complex *sample); - private: + protected: constellation_qpsk(); }; @@ -385,7 +439,7 @@ namespace gr { unsigned int decision_maker(const gr_complex *sample); - private: + protected: constellation_dqpsk(); }; @@ -413,7 +467,7 @@ namespace gr { unsigned int decision_maker(const gr_complex *sample); - private: + protected: constellation_8psk(); }; diff --git a/gr-digital/lib/constellation.cc b/gr-digital/lib/constellation.cc index 9eee1cc501..d249c493ad 100644 --- a/gr-digital/lib/constellation.cc +++ b/gr-digital/lib/constellation.cc @@ -378,6 +378,45 @@ namespace gr { /********************************************************************/ + constellation_expl_rect::sptr + constellation_expl_rect::make(std::vector<gr_complex> constellation, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values) + { + return constellation_expl_rect::sptr + (new constellation_expl_rect(constellation, pre_diff_code, + rotational_symmetry, + real_sectors, imag_sectors, + width_real_sectors, width_imag_sectors, + sector_values)); + } + + constellation_expl_rect::constellation_expl_rect(std::vector<gr_complex> constellation, + std::vector<int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values) + : constellation_rect(constellation, pre_diff_code, rotational_symmetry, + real_sectors, imag_sectors, width_real_sectors, width_imag_sectors), + d_sector_values(sector_values) + { + } + + constellation_expl_rect::~constellation_expl_rect() + { + } + + /********************************************************************/ + + constellation_psk::sptr constellation_psk::make(std::vector<gr_complex> constell, std::vector<int> pre_diff_code, diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index 662bb2d8f8..962f210324 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -27,6 +27,7 @@ Blocks and utilities for digital modulation and demodulation. from digital_swig import * from psk import * from qam import * +from qamlike import * from bpsk import * from qpsk import * from gmsk import * diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index 5919839186..518be78941 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -176,11 +176,11 @@ def qam_constellation(constellation_points=_def_constellation_points, # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] if not large_ampls_to_corners: - constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + constellation = digital.constellation_rect(points, pre_diff_code, 4, side, side, width, width) else: sector_values = large_ampls_to_corners_mapping(side, points, width) - constellation = digital_swig.constellation_expl_rect( + constellation = digital.constellation_expl_rect( points, pre_diff_code, 4, side, side, width, width, sector_values) return constellation diff --git a/gr-digital/swig/constellation.i b/gr-digital/swig/constellation.i index 39eb7030fd..7ff2d63c30 100644 --- a/gr-digital/swig/constellation.i +++ b/gr-digital/swig/constellation.i @@ -34,6 +34,12 @@ constellation_rect_sptr.__repr__ = lambda self: "<constellation rect (m=%d)>" % constellation_rect = constellation_rect.make; %} +%template(constellation_expl_rect_sptr) boost::shared_ptr<gr::digital::constellation_expl_rect>; +%pythoncode %{ +constellation_expl_rect_sptr.__repr__ = lambda self: "<constellation expl rect (m=%d)>" % (len(self.points())) +constellation_expl_rect = constellation_expl_rect.make; +%} + %template(constellation_psk_sptr) boost::shared_ptr<gr::digital::constellation_psk>; %pythoncode %{ constellation_psk_sptr.__repr__ = lambda self: "<constellation PSK (m=%d)>" % (len(self.points())) |