[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/01: digital:added new constellations obj
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/01: digital:added new constellations objects naturally mapped 8PSK and 16QAM |
Date: |
Wed, 21 Jan 2015 22:39:18 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit d11233f6cfb1f7c32bc1187a97b16e17806efc23
Author: fengzhe29888 <address@hidden>
Date: Wed Jan 21 16:41:54 2015 -0500
digital:added new constellations objects naturally mapped 8PSK and 16QAM
---
.../include/gnuradio/digital/constellation.h | 74 +++++++++++
gr-digital/lib/constellation.cc | 138 +++++++++++++++++++++
gr-digital/swig/constellation.i | 12 ++
3 files changed, 224 insertions(+)
diff --git a/gr-digital/include/gnuradio/digital/constellation.h
b/gr-digital/include/gnuradio/digital/constellation.h
index 0c29eff..67e6e80 100644
--- a/gr-digital/include/gnuradio/digital/constellation.h
+++ b/gr-digital/include/gnuradio/digital/constellation.h
@@ -619,6 +619,80 @@ namespace gr {
constellation_8psk();
};
+ /************************************************************/
+ /* constellation_8psk_natural */
+ /* */
+ /* Only works for natural 8psk */
+ /* */
+ /************************************************************/
+
+ /*!
+ * \brief Digital constellation for natually mapped 8PSK.
+ * \ingroup digital
+ *
+ * \details
+ * \verbatim
+ 011 | 010
+ 100 | 001
+ -----------------
+ 101 | 000
+ 110 | 111
+ \endverbatim
+ */
+ class DIGITAL_API constellation_8psk_natural : public constellation
+ {
+ public:
+ typedef boost::shared_ptr<constellation_8psk_natural> sptr;
+
+ // public constructor
+ static sptr make();
+
+ ~constellation_8psk_natural();
+
+ unsigned int decision_maker(const gr_complex *sample);
+
+ protected:
+ constellation_8psk_natural();
+ };
+
+ /************************************************************/
+ /* constellation_16qam */
+ /* */
+ /* the 16qam mapping used in set partition of tcm */
+ /* */
+ /************************************************************/
+
+ /*!
+ * \brief Digital constellation for 16qam.
+ * \ingroup digital
+ *
+ * \details
+ * \verbatim
+ 1000 1101 | 1100 1001
+ |
+ 1111 1010 | 1011 1110
+ -----------------
+ 0100 0001 | 0000 0101
+ |
+ 0011 0110 | 0111 0010
+ \endverbatim
+ */
+ class DIGITAL_API constellation_16qam : public constellation
+ {
+ public:
+ typedef boost::shared_ptr<constellation_16qam> sptr;
+
+ // public constructor
+ static sptr make();
+
+ ~constellation_16qam();
+
+ unsigned int decision_maker(const gr_complex *sample);
+
+ protected:
+ constellation_16qam();
+ };
+
} /* namespace digital */
} /* namespace gr */
diff --git a/gr-digital/lib/constellation.cc b/gr-digital/lib/constellation.cc
index a477aa8..f8ea72d 100644
--- a/gr-digital/lib/constellation.cc
+++ b/gr-digital/lib/constellation.cc
@@ -846,5 +846,143 @@ namespace gr {
return ret;
}
+
+ /********************************************************************/
+
+
+ constellation_8psk_natural::sptr
+ constellation_8psk_natural::make()
+ {
+ return constellation_8psk_natural::sptr(new
constellation_8psk_natural());
+ }
+
+ constellation_8psk_natural::constellation_8psk_natural()
+ {
+ float angle = M_PI/8.0;
+ d_constellation.resize(8);
+ // Natural-mapping
+ d_constellation[0] = gr_complex(cos( 15*angle), sin( 15*angle));
+ d_constellation[1] = gr_complex(cos( 1*angle), sin( 1*angle));
+ d_constellation[2] = gr_complex(cos(3*angle), sin(3*angle));
+ d_constellation[3] = gr_complex(cos( 5*angle), sin( 5*angle));
+ d_constellation[4] = gr_complex(cos( 7*angle), sin( 7*angle));
+ d_constellation[5] = gr_complex(cos( 9*angle), sin( 9*angle));
+ d_constellation[6] = gr_complex(cos(11*angle), sin(11*angle));
+ d_constellation[7] = gr_complex(cos(13*angle), sin(13*angle));
+ d_rotational_symmetry = 8;
+ d_dimensionality = 1;
+ calc_arity();
+ }
+
+ constellation_8psk_natural::~constellation_8psk_natural()
+ {
+ }
+
+ unsigned int
+ constellation_8psk_natural::decision_maker(const gr_complex *sample)
+ {
+ unsigned int ret = 0;
+
+ float re = sample->real();
+ float im = sample->imag();
+
+ if((re+im) < 0)
+ ret = 4;
+ if(fabsf(im) > fabsf(re)){
+ ret |= 2;
+ if(re*im < 0)
+ ret |= 1;
+ }
+ if(fabsf(im) < fabsf(re) && re*im > 0)
+ ret |= 1;
+
+ return ret;
+ }
+
+
+ /********************************************************************/
+
+
+ constellation_16qam::sptr
+ constellation_16qam::make()
+ {
+ return constellation_16qam::sptr(new constellation_16qam());
+ }
+
+ constellation_16qam::constellation_16qam()
+ {
+ const float level = sqrt(float(0.1));
+ d_constellation.resize(16);
+ // The mapping used in 16qam set partition
+ d_constellation[0] = gr_complex(1*level,-1*level);
+ d_constellation[1] = gr_complex(-1*level,-1*level);
+ d_constellation[2] = gr_complex(3*level,-3*level);
+ d_constellation[3] = gr_complex(-3*level,-3*level);
+ d_constellation[4] = gr_complex(-3*level,-1*level);
+ d_constellation[5] = gr_complex(3*level,-1*level);
+ d_constellation[6] = gr_complex(-1*level,-3*level);
+ d_constellation[7] = gr_complex(1*level,-3*level);
+ d_constellation[8] = gr_complex(-3*level,3*level);
+ d_constellation[9] = gr_complex(3*level,3*level);
+ d_constellation[10] = gr_complex(-1*level,1*level);
+ d_constellation[11] = gr_complex(1*level,1*level);
+ d_constellation[12] = gr_complex(1*level,3*level);
+ d_constellation[13] = gr_complex(-1*level,3*level);
+ d_constellation[14] = gr_complex(3*level,1*level);
+ d_constellation[15] = gr_complex(-3*level,1*level);
+ d_rotational_symmetry = 4;
+ d_dimensionality = 1;
+ calc_arity();
+ }
+
+ constellation_16qam::~constellation_16qam()
+ {
+ }
+
+ unsigned int
+ constellation_16qam::decision_maker(const gr_complex *sample)
+ {
+ unsigned int ret = 0;
+ const float level = sqrt(float(0.1));
+ float re = sample->real();
+ float im = sample->imag();
+
+ if(im < 0 && im > -2*level && re > 0 && re < 2*level)
+ ret = 0;
+ if(im < 0 && im > -2*level && re < 0 && re > -2*level)
+ ret = 1;
+ if(im < -2*level && re > 2*level)
+ ret = 2;
+ if(im < -2*level && re < -2*level)
+ ret = 3;
+ if(im < 0 && im > -2*level && re < -2*level)
+ ret = 4;
+ if(im < 0 && im > -2*level && re > 2*level)
+ ret = 5;
+ if(im < -2*level && re < 0 && re > -2*level)
+ ret = 6;
+ if(im < -2*level && re > 0 && re < 2*level)
+ ret = 7;
+ if(im > 2*level && re < -2*level)
+ ret = 8;
+ if(im > 2*level && re > 2*level)
+ ret = 9;
+ if(im > 0 && im < 2*level && re < 0 && re < -2*level)
+ ret = 10;
+ if(im > 0 && im < 2*level && re > 0 && re < 2*level)
+ ret = 11;
+ if(im > 2*level && re > 0 && re < 2*level)
+ ret = 12;
+ if(im > 2*level && re < 0 && re > -2*level)
+ ret = 13;
+ if(im > 0 && im < 2*level && re > 2*level)
+ ret = 14;
+ if(im > 0 && im < 2*level && re < -2*level)
+ ret = 15;
+
+ return ret;
+ }
+
+
} /* namespace digital */
} /* namespace gr */
diff --git a/gr-digital/swig/constellation.i b/gr-digital/swig/constellation.i
index 7ff2d63..ceb1fea 100644
--- a/gr-digital/swig/constellation.i
+++ b/gr-digital/swig/constellation.i
@@ -69,3 +69,15 @@ constellation_dqpsk = constellation_dqpsk.make;
constellation_8psk_sptr.__repr__ = lambda self: "<constellation 8PSK>"
constellation_8psk = constellation_8psk.make;
%}
+
+%template(constellation_8psk_natural_sptr)
boost::shared_ptr<gr::digital::constellation_8psk_natural>;
+%pythoncode %{
+constellation_8psk_natural_sptr.__repr__ = lambda self: "<constellation
8PSK_natural>"
+constellation_8psk_natural = constellation_8psk_natural.make;
+%}
+
+%template(constellation_16qam_sptr)
boost::shared_ptr<gr::digital::constellation_16qam>;
+%pythoncode %{
+constellation_16qam_sptr.__repr__ = lambda self: "<constellation 16qam>"
+constellation_16qam = constellation_16qam.make;
+%}