chunks to symbols: use constellations

This commit is contained in:
Bastian Bloessl
2016-05-31 15:37:28 +02:00
parent 9ca1f310f5
commit dd89949184
2 changed files with 23 additions and 68 deletions
+14 -61
View File
@@ -28,10 +28,17 @@ chunks_to_symbols::make()
return gnuradio::get_initial_sptr(new chunks_to_symbols_impl()); return gnuradio::get_initial_sptr(new chunks_to_symbols_impl());
} }
chunks_to_symbols_impl::chunks_to_symbols_impl() chunks_to_symbols_impl::chunks_to_symbols_impl() :
: tagged_stream_block("chunks_to_symbols", tagged_stream_block("chunks_to_symbols",
io_signature::make(1, 1, sizeof(char)), io_signature::make(1, 1, sizeof(char)),
io_signature::make(1, 1, sizeof(gr_complex)), "packet_len") { io_signature::make(1, 1, sizeof(gr_complex)), "packet_len") {
d_bpsk = constellation_bpsk::make();
d_qpsk = constellation_qpsk::make();
d_16qam = constellation_16qam::make();
d_64qam = constellation_64qam::make();
d_mapping = d_bpsk;
} }
chunks_to_symbols_impl::~chunks_to_symbols_impl() { } chunks_to_symbols_impl::~chunks_to_symbols_impl() { }
@@ -56,27 +63,25 @@ chunks_to_symbols_impl::work(int noutput_items,
Encoding encoding = (Encoding)pmt::to_long(tags[0].value); Encoding encoding = (Encoding)pmt::to_long(tags[0].value);
const gr_complex *mapping;
switch (encoding) { switch (encoding) {
case BPSK_1_2: case BPSK_1_2:
case BPSK_3_4: case BPSK_3_4:
mapping = BPSK; d_mapping = d_bpsk;
break; break;
case QPSK_1_2: case QPSK_1_2:
case QPSK_3_4: case QPSK_3_4:
mapping = QPSK; d_mapping = d_qpsk;
break; break;
case QAM16_1_2: case QAM16_1_2:
case QAM16_3_4: case QAM16_3_4:
mapping = QAM16; d_mapping = d_16qam;
break; break;
case QAM64_2_3: case QAM64_2_3:
case QAM64_3_4: case QAM64_3_4:
mapping = QAM64; d_mapping = d_64qam;
break; break;
default: default:
@@ -85,60 +90,8 @@ chunks_to_symbols_impl::work(int noutput_items,
} }
for(int i = 0; i < ninput_items[0]; i++) { for(int i = 0; i < ninput_items[0]; i++) {
out[i] = mapping[in[i]]; d_mapping->map_to_points(in[i], out + i);
} }
return ninput_items[0]; return ninput_items[0];
} }
const gr_complex chunks_to_symbols_impl::BPSK[2] = {
gr_complex(-1.0, 0.0), gr_complex(1.0, 0.0)};
const gr_complex chunks_to_symbols_impl::QPSK[4] = {
gr_complex(-0.7071, -0.7071), gr_complex(-0.7071, 0.7071),
gr_complex(+0.7071, -0.7071), gr_complex(+0.7071, 0.7071)};
const gr_complex chunks_to_symbols_impl::QAM16[16] = {
gr_complex(-0.9487, -0.9487), gr_complex(-0.9487, -0.3162),
gr_complex(-0.9487, 0.9487), gr_complex(-0.9487, 0.3162),
gr_complex(-0.3162, -0.9487), gr_complex(-0.3162, -0.3162),
gr_complex(-0.3162, 0.9487), gr_complex(-0.3162, 0.3162),
gr_complex(0.9487, -0.9487), gr_complex(0.9487, -0.3162),
gr_complex(0.9487, 0.9487), gr_complex(0.9487, 0.3162),
gr_complex(0.3162, -0.9487), gr_complex(0.3162, -0.3162),
gr_complex(0.3162, 0.9487), gr_complex(0.3162, 0.3162)};
const gr_complex chunks_to_symbols_impl::QAM64[64] = {
gr_complex(-1.0801, -1.0801), gr_complex(-1.0801, -0.7715),
gr_complex(-1.0801, -0.1543), gr_complex(-1.0801, -0.4629),
gr_complex(-1.0801, 1.0801), gr_complex(-1.0801, 0.7715),
gr_complex(-1.0801, 0.1543), gr_complex(-1.0801, 0.4629),
gr_complex(-0.7715, -1.0801), gr_complex(-0.7715, -0.7715),
gr_complex(-0.7715, -0.1543), gr_complex(-0.7715, -0.4629),
gr_complex(-0.7715, 1.0801), gr_complex(-0.7715, 0.7715),
gr_complex(-0.7715, 0.1543), gr_complex(-0.7715, 0.4629),
gr_complex(-0.1543, -1.0801), gr_complex(-0.1543, -0.7715),
gr_complex(-0.1543, -0.1543), gr_complex(-0.1543, -0.4629),
gr_complex(-0.1543, 1.0801), gr_complex(-0.1543, 0.7715),
gr_complex(-0.1543, 0.1543), gr_complex(-0.1543, 0.4629),
gr_complex(-0.4629, -1.0801), gr_complex(-0.4629, -0.7715),
gr_complex(-0.4629, -0.1543), gr_complex(-0.4629, -0.4629),
gr_complex(-0.4629, 1.0801), gr_complex(-0.4629, 0.7715),
gr_complex(-0.4629, 0.1543), gr_complex(-0.4629, 0.4629),
gr_complex(1.0801, -1.0801), gr_complex(1.0801, -0.7715),
gr_complex(1.0801, -0.1543), gr_complex(1.0801, -0.4629),
gr_complex(1.0801, 1.0801), gr_complex(1.0801, 0.7715),
gr_complex(1.0801, 0.1543), gr_complex(1.0801, 0.4629),
gr_complex(0.7715, -1.0801), gr_complex(0.7715, -0.7715),
gr_complex(0.7715, -0.1543), gr_complex(0.7715, -0.4629),
gr_complex(0.7715, 1.0801), gr_complex(0.7715, 0.7715),
gr_complex(0.7715, 0.1543), gr_complex(0.7715, 0.4629),
gr_complex(0.1543, -1.0801), gr_complex(0.1543, -0.7715),
gr_complex(0.1543, -0.1543), gr_complex(0.1543, -0.4629),
gr_complex(0.1543, 1.0801), gr_complex(0.1543, 0.7715),
gr_complex(0.1543, 0.1543), gr_complex(0.1543, 0.4629),
gr_complex(0.4629, -1.0801), gr_complex(0.4629, -0.7715),
gr_complex(0.4629, -0.1543), gr_complex(0.4629, -0.4629),
gr_complex(0.4629, 1.0801), gr_complex(0.4629, 0.7715),
gr_complex(0.4629, 0.1543), gr_complex(0.4629, 0.4629)};
+7 -5
View File
@@ -18,6 +18,7 @@
#define INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H #define INCLUDED_IEEE802_11_CHUNKS_TO_SYMBOLS_IMPL_H
#include <ieee802-11/chunks_to_symbols.h> #include <ieee802-11/chunks_to_symbols.h>
#include <ieee802-11/constellations.h>
namespace gr { namespace gr {
namespace ieee802_11 { namespace ieee802_11 {
@@ -33,11 +34,12 @@ public:
gr_vector_const_void_star &input_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items); gr_vector_void_star &output_items);
protected: private:
static const gr_complex BPSK[2]; boost::shared_ptr<gr::digital::constellation> d_mapping;
static const gr_complex QPSK[4]; constellation_bpsk::sptr d_bpsk;
static const gr_complex QAM16[16]; constellation_qpsk::sptr d_qpsk;
static const gr_complex QAM64[64]; constellation_16qam::sptr d_16qam;
constellation_64qam::sptr d_64qam;
}; };
} /* namespace ieee802_11 */ } /* namespace ieee802_11 */