diff options
-rw-r--r-- | gnuradio-core/src/lib/general/gr_constellation.cc | 32 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_constellation.h | 15 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_constellation.i | 9 |
3 files changed, 41 insertions, 15 deletions
diff --git a/gnuradio-core/src/lib/general/gr_constellation.cc b/gnuradio-core/src/lib/general/gr_constellation.cc index e3b4c14e7..27590bf82 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.cc +++ b/gnuradio-core/src/lib/general/gr_constellation.cc @@ -35,16 +35,19 @@ #define SQRT_TWO 0.707107 gr_constellation_sptr -gr_make_constellation(std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code) +gr_make_constellation(std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry) { - return gr_constellation_sptr(new gr_constellation (constellation, pre_diff_code)); + return gr_constellation_sptr(new gr_constellation (constellation, pre_diff_code, rotational_symmetry)); } // Base Constellation Class -gr_constellation::gr_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code) : +gr_constellation::gr_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry) : d_constellation(constellation), - d_pre_diff_code(pre_diff_code) + d_pre_diff_code(pre_diff_code), + d_rotational_symmetry(rotational_symmetry) { if (pre_diff_code.size() == 0) d_apply_pre_diff_code = false; @@ -55,7 +58,8 @@ gr_constellation::gr_constellation (std::vector<gr_complex> constellation, std:: } gr_constellation::gr_constellation () : - d_apply_pre_diff_code(false) + d_apply_pre_diff_code(false), + d_rotational_symmetry(0) { } @@ -128,8 +132,9 @@ void gr_constellation::calc_hard_symbol_metric(gr_complex sample, float *metric) gr_constellation_sector::gr_constellation_sector (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int n_sectors) : - gr_constellation(constellation, pre_diff_code), + gr_constellation(constellation, pre_diff_code, rotational_symmetry), n_sectors(n_sectors) { } @@ -151,17 +156,21 @@ void gr_constellation_sector::find_sector_values () { gr_constellation_rect_sptr gr_make_constellation_rect(std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors) { - return gr_constellation_rect_sptr(new gr_constellation_rect (constellation, pre_diff_code, real_sectors, imag_sectors, width_real_sectors, width_imag_sectors)); + return gr_constellation_rect_sptr(new gr_constellation_rect (constellation, pre_diff_code, rotational_symmetry, + real_sectors, imag_sectors, width_real_sectors, + width_imag_sectors)); } gr_constellation_rect::gr_constellation_rect (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors) : - gr_constellation_sector(constellation, pre_diff_code, real_sectors * imag_sectors), + gr_constellation_sector(constellation, pre_diff_code, rotational_symmetry, real_sectors * imag_sectors), n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) { @@ -199,13 +208,14 @@ gr_make_constellation_psk(std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, unsigned int n_sectors) { - return gr_constellation_psk_sptr(new gr_constellation_psk (constellation, pre_diff_code, n_sectors)); + return gr_constellation_psk_sptr(new gr_constellation_psk (constellation, pre_diff_code, + n_sectors)); } gr_constellation_psk::gr_constellation_psk (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, unsigned int n_sectors) : - gr_constellation_sector(constellation, pre_diff_code, n_sectors) + gr_constellation_sector(constellation, pre_diff_code, constellation.size(), n_sectors) { find_sector_values(); } @@ -241,6 +251,7 @@ gr_constellation_bpsk::gr_constellation_bpsk () d_constellation.resize(2); d_constellation[0] = gr_complex(-1, 0); d_constellation[1] = gr_complex(1, 0); + d_rotational_symmetry = 2; } unsigned int gr_constellation_bpsk::decision_maker(gr_complex sample) @@ -263,6 +274,7 @@ gr_constellation_qpsk::gr_constellation_qpsk () d_constellation[1] = gr_complex(SQRT_TWO, -SQRT_TWO); d_constellation[2] = gr_complex(-SQRT_TWO, SQRT_TWO); d_constellation[3] = gr_complex(SQRT_TWO, SQRT_TWO); + d_rotational_symmetry = 4; } unsigned int gr_constellation_qpsk::decision_maker(gr_complex sample) diff --git a/gnuradio-core/src/lib/general/gr_constellation.h b/gnuradio-core/src/lib/general/gr_constellation.h index 440e32e57..4083e5b5b 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.h +++ b/gnuradio-core/src/lib/general/gr_constellation.h @@ -40,13 +40,15 @@ typedef boost::shared_ptr<gr_constellation> gr_constellation_sptr; // public constructor gr_constellation_sptr -gr_make_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code); +gr_make_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry); class gr_constellation : public boost::enable_shared_from_this<gr_constellation> { public: - gr_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code); + gr_constellation (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry); gr_constellation (); //! Returns the set of points in this constellation. @@ -55,7 +57,9 @@ class gr_constellation : public boost::enable_shared_from_this<gr_constellation> bool apply_pre_diff_code() { return d_apply_pre_diff_code;} //! Returns the encoding to apply before differential encoding. std::vector<unsigned int> pre_diff_code() { return d_pre_diff_code;} - + //! Returns the order of rotational symmetry. + unsigned int rotational_symmetry() { return d_rotational_symmetry;} + //! Returns the constellation point that matches best. //! Also calculates the phase error. virtual unsigned int decision_maker (gr_complex sample); @@ -83,6 +87,7 @@ class gr_constellation : public boost::enable_shared_from_this<gr_constellation> std::vector<gr_complex> d_constellation; std::vector<unsigned int> d_pre_diff_code; bool d_apply_pre_diff_code; + unsigned int d_rotational_symmetry; private: friend gr_constellation_sptr @@ -104,6 +109,7 @@ class gr_constellation_sector : public gr_constellation gr_constellation_sector (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int n_sectors); unsigned int decision_maker (gr_complex sample); @@ -141,6 +147,7 @@ typedef boost::shared_ptr<gr_constellation_rect> gr_constellation_rect_sptr; // public constructor gr_constellation_rect_sptr gr_make_constellation_rect (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors); @@ -149,6 +156,7 @@ class gr_constellation_rect : public gr_constellation_sector public: gr_constellation_rect (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors); @@ -167,6 +175,7 @@ class gr_constellation_rect : public gr_constellation_sector friend gr_constellation_rect_sptr gr_make_constellation_rect (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors); diff --git a/gnuradio-core/src/lib/general/gr_constellation.i b/gnuradio-core/src/lib/general/gr_constellation.i index 762289c57..18d0cc92b 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.i +++ b/gnuradio-core/src/lib/general/gr_constellation.i @@ -31,14 +31,16 @@ typedef boost::shared_ptr<gr_constellation> gr_constellation_sptr; %template(gr_constellation_sptr) boost::shared_ptr<gr_constellation>; %rename(constellation) gr_make_constellation; gr_constellation_sptr gr_make_constellation(std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code); + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry); %ignore gr_constellation; class gr_constellation { public: gr_constellation (std::vector<gr_complex> constellation, - std::vector<unsigned int> pre_diff_code); + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry); std::vector<gr_complex> points(); unsigned int decision_maker (gr_complex sample); unsigned int bits_per_symbol (); @@ -46,6 +48,7 @@ public: gr_constellation_sptr base (); bool apply_pre_diff_code(); std::vector<unsigned int> pre_diff_code(); + unsigned int rotational_symmetry(); }; class gr_constellation_sector: public gr_constellation @@ -58,6 +61,7 @@ typedef boost::shared_ptr<gr_constellation_rect> gr_constellation_rect_sptr; %rename(constellation_rect) gr_make_constellation_rect; gr_constellation_rect_sptr gr_make_constellation_rect(std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors); %ignore gr_constellation_rect; @@ -67,6 +71,7 @@ class gr_constellation_rect : public gr_constellation_sector public: gr_constellation_rect (std::vector<gr_complex> constellation, std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors); }; |