diff options
5 files changed, 72 insertions, 3 deletions
diff --git a/gnuradio-core/src/lib/general/gr_constellation.cc b/gnuradio-core/src/lib/general/gr_constellation.cc index 477532e5c..403394eaa 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.cc +++ b/gnuradio-core/src/lib/general/gr_constellation.cc @@ -29,6 +29,7 @@ #include <stdlib.h> #define M_TWOPI (2*M_PI) +#define SQRT_TWO 0.707107 gr_constellation_sptr gr_make_constellation(std::vector<gr_complex> constellation) @@ -190,3 +191,27 @@ unsigned int gr_constellation_bpsk::decision_maker(gr_complex sample) { return (real(sample) > 0); } + + +gr_constellation_qpsk_sptr +gr_make_constellation_qpsk() +{ + return gr_constellation_qpsk_sptr(new gr_constellation_qpsk ()); +} + +gr_constellation_qpsk::gr_constellation_qpsk () +{ + d_constellation.resize(4); + // Gray-coded + d_constellation[0] = gr_complex(-SQRT_TWO, -SQRT_TWO); + 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); +} + +unsigned int gr_constellation_qpsk::decision_maker(gr_complex sample) +{ + // Real component determines small bit. + // Imag component determines big bit. + return 2*(imag(sample)>0) + (real(sample)>0); +} diff --git a/gnuradio-core/src/lib/general/gr_constellation.h b/gnuradio-core/src/lib/general/gr_constellation.h index fcc947ca6..8ba22d59a 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.h +++ b/gnuradio-core/src/lib/general/gr_constellation.h @@ -213,4 +213,30 @@ class gr_constellation_bpsk : public gr_constellation }; +/************************************************************/ +/* gr_constellation_qpsk */ +/* */ +/* Only works for QPSK. */ +/* */ +/************************************************************/ + +class gr_constellation_qpsk; +typedef boost::shared_ptr<gr_constellation_qpsk> gr_constellation_qpsk_sptr; + +// public constructor +gr_constellation_qpsk_sptr +gr_make_constellation_qpsk (); + +class gr_constellation_qpsk : public gr_constellation +{ + public: + + gr_constellation_qpsk (); + unsigned int decision_maker (gr_complex sample); + + friend gr_constellation_qpsk_sptr + gr_make_constellation_qpsk (); + +}; + #endif diff --git a/gnuradio-core/src/lib/general/gr_constellation.i b/gnuradio-core/src/lib/general/gr_constellation.i index a34aade9f..6620721ea 100644 --- a/gnuradio-core/src/lib/general/gr_constellation.i +++ b/gnuradio-core/src/lib/general/gr_constellation.i @@ -97,3 +97,20 @@ public: gr_constellation_sptr base (); }; +class gr_constellation_qpsk; +typedef boost::shared_ptr<gr_constellation_qpsk> gr_constellation_qpsk_sptr; +%template(gr_constellation_qpsk_sptr) boost::shared_ptr<gr_constellation_qpsk>; +%rename(constellation_qpsk) gr_make_constellation_qpsk; +gr_constellation_qpsk_sptr gr_make_constellation_qpsk(); +%ignore gr_constellation_qpsk; + +class gr_constellation_qpsk : public gr_constellation +{ +public: + gr_constellation_qpsk (); + std::vector<gr_complex> points(); + unsigned int decision_maker (gr_complex sample); + unsigned int bits_per_symbol (); + gr_constellation_sptr base (); +}; + diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am index 2a7f59176..6a2e7d5f7 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/blks2impl/Makefile.am @@ -60,6 +60,7 @@ grblkspython_PYTHON = \ psk.py \ psk2.py \ qam.py \ + qpsk.py \ rational_resampler.py \ standard_squelch.py \ stream_to_vector_decimator.py \ diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py index 997df0bdf..3b1cd12ac 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py @@ -32,7 +32,7 @@ def _add_common_options(normal, expert): Adds OFDM-specific options to the Options Parser that are common both to the modulator and demodulator. """ - mods_list = ", ".join(modulation_utils2.type_1_mods().keys()) + mods_list = ", ".join(modulation_utils2.type_1_constellations().keys()) normal.add_option("-m", "--modulation", type="string", default="psk", help="set modulation type (" + mods_list + ") [default=%default]") expert.add_option("", "--fft-length", type="intx", default=512, @@ -248,8 +248,8 @@ class ofdm_demod(gr.hier_block2): Adds OFDM-specific options to the Options Parser """ _add_common_options(normal, expert) - for demod in modulation_utils2.type_1_demods().values(): - demod.add_options(expert) + for mod in modulation_utils2.type_1_mods().values(): + mod.add_options(expert) # Make a static method to call before instantiation add_options = staticmethod(add_options) |