diff options
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/general/Makefile.am | 12 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/general.i | 8 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc | 137 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h | 77 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i | 44 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc | 252 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h | 85 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.i | 46 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.cc | 142 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.h | 77 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.i | 44 |
13 files changed, 4 insertions, 928 deletions
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index 73ba67a70..8ee900183 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -105,10 +105,6 @@ libgeneral_la_SOURCES = \ gr_ofdm_cyclic_prefixer.cc \ gr_ofdm_demapper_vcb.cc \ gr_ofdm_mapper_bcv.cc \ - gr_ofdm_bpsk_demapper.cc \ - gr_ofdm_bpsk_mapper.cc \ - gr_ofdm_qpsk_mapper.cc \ - gr_ofdm_qam_mapper.cc \ gr_ofdm_frame_sink.cc \ gr_ofdm_insert_preamble.cc \ gr_ofdm_sampler.cc \ @@ -255,10 +251,6 @@ grinclude_HEADERS = \ gr_ofdm_cyclic_prefixer.h \ gr_ofdm_demapper_vcb.h \ gr_ofdm_mapper_bcv.h \ - gr_ofdm_bpsk_mapper.h \ - gr_ofdm_qpsk_mapper.h \ - gr_ofdm_qam_mapper.h \ - gr_ofdm_bpsk_demapper.h \ gr_ofdm_frame_sink.h \ gr_ofdm_insert_preamble.h \ gr_ofdm_sampler.h \ @@ -408,10 +400,6 @@ swiginclude_HEADERS = \ gr_ofdm_cyclic_prefixer.i \ gr_ofdm_demapper_vcb.i \ gr_ofdm_mapper_bcv.i \ - gr_ofdm_bpsk_demapper.i \ - gr_ofdm_bpsk_mapper.i \ - gr_ofdm_qpsk_mapper.i \ - gr_ofdm_qam_mapper.i \ gr_ofdm_frame_sink.i \ gr_ofdm_insert_preamble.i \ gr_ofdm_sampler.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 21bbdb2c5..435271f79 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -95,11 +95,7 @@ #include <gr_probe_signal_f.h> #include <gr_ofdm_frame_acquisition.h> #include <gr_ofdm_cyclic_prefixer.h> -#include <gr_ofdm_bpsk_demapper.h> #include <gr_ofdm_mapper_bcv.h> -#include <gr_ofdm_bpsk_mapper.h> -#include <gr_ofdm_qpsk_mapper.h> -#include <gr_ofdm_qam_mapper.h> #include <gr_ofdm_frame_sink.h> #include <gr_ofdm_insert_preamble.h> #include <gr_ofdm_sampler.h> @@ -208,11 +204,7 @@ %include "gr_probe_signal_f.i" %include "gr_ofdm_frame_acquisition.i" %include "gr_ofdm_cyclic_prefixer.i" -%include "gr_ofdm_bpsk_demapper.i" %include "gr_ofdm_mapper_bcv.i" -%include "gr_ofdm_bpsk_mapper.i" -%include "gr_ofdm_qpsk_mapper.i" -%include "gr_ofdm_qam_mapper.i" %include "gr_ofdm_frame_sink.i" %include "gr_ofdm_insert_preamble.i" %include "gr_ofdm_sampler.i" diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc deleted file mode 100644 index 786584357..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ofdm_bpsk_mapper.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <string.h> - -gr_ofdm_bpsk_mapper_sptr -gr_make_ofdm_bpsk_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) -{ - return gr_ofdm_bpsk_mapper_sptr (new gr_ofdm_bpsk_mapper (msgq_limit, occupied_carriers, fft_length)); -} - -// Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -gr_ofdm_bpsk_mapper::gr_ofdm_bpsk_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) - : gr_sync_block ("ofdm_bpsk_mapper", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), - d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_bit_offset(0), - d_pending_flag(0) -{ - if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("gr_ofdm_bpsk_mapper: occupied carriers must be <= fft_length"); -} - -gr_ofdm_bpsk_mapper::~gr_ofdm_bpsk_mapper(void) -{ -} - -static float -randombit() -{ - int r = rand()&1; - return (float)(1 - 2*r); -} - -int -gr_ofdm_bpsk_mapper::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - unsigned int i=0; - unsigned int unoccupied_carriers = d_fft_length - d_occupied_carriers; - unsigned int zeros_on_left = (unsigned)ceil(unoccupied_carriers/2.0); - - //printf("OFDM BPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); - - if(d_eof) { - return -1; - } - - if(!d_msg) { - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - d_bit_offset = 0; - d_pending_flag = 1; // new packet, write start of packet flag - - if((d_msg->length() == 0) && (d_msg->type() == 1)) { - d_msg.reset(); - return -1; // We're done; no more messages coming. - } - } - - char *out_flag = 0; - if(output_items.size() == 2) - out_flag = (char *) output_items[1]; - - - // Build a single symbol: - - - // Initialize all bins to 0 to set unused carriers - memset(out, 0, d_fft_length*sizeof(gr_complex)); - - i = 0; - while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { - unsigned char bit = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - out[i + zeros_on_left] = gr_complex(1-2*(bit)); - i++; - d_bit_offset++; - if(d_bit_offset == 8) { - d_bit_offset = 0; - d_msg_offset++; - } - } - - // Ran out of data to put in symbol - if (d_msg_offset == d_msg->length()) { - while(i < d_occupied_carriers) { // finish filling out the symbol - out[i + zeros_on_left] = gr_complex(randombit(),0); - i++; - } - - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); // finished packet, free message - assert(d_bit_offset == 0); - } - - if (out_flag) - out_flag[0] = d_pending_flag; - d_pending_flag = 0; - - return 1; // produced symbol -} - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h deleted file mode 100644 index 9142228f1..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_OFDM_BPSK_MAPPER_H -#define INCLUDED_GR_OFDM_BPSK_MAPPER_H - - -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_ofdm_bpsk_mapper; -typedef boost::shared_ptr<gr_ofdm_bpsk_mapper> gr_ofdm_bpsk_mapper_sptr; - -gr_ofdm_bpsk_mapper_sptr -gr_make_ofdm_bpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - -/*! - * \brief take a message in and map to a vector of complex - * constellation points suitable for IFFT input to be used in an ofdm - * modulator. Simple BPSK version. - * \ingroup modulation - */ - -class gr_ofdm_bpsk_mapper : public gr_sync_block -{ - friend gr_ofdm_bpsk_mapper_sptr - gr_make_ofdm_bpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - protected: - gr_ofdm_bpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - - private: - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - unsigned int d_occupied_carriers; - unsigned int d_fft_length; - unsigned int d_bit_offset; - int d_pending_flag; - - public: - ~gr_ofdm_bpsk_mapper(void); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i deleted file mode 100644 index a36827ecf..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_bpsk_mapper); - -gr_ofdm_bpsk_mapper_sptr -gr_make_ofdm_bpsk_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - -class gr_ofdm_bpsk_mapper : public gr_sync_block -{ - protected: - gr_ofdm_bpsk_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - public: - gr_msg_queue_sptr msgq(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc index 7e4996b0b..26a5cf0fe 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc @@ -227,11 +227,11 @@ gr_ofdm_frame_sink::gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_positi char c[2] = {0,0}; diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[((1 << diff_left) - 1)]; // convert to bits and move to ASCI integer + c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer carriers.insert(0, c); diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[(0xF^(1 << diff_left) - 1)]; // convert to bits and move to ASCI integer + c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer carriers.insert(carriers.length(), c); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc index 56701b3c1..02f09f5f2 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc @@ -84,11 +84,11 @@ gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (const std::vector<gr_complex> &constella char c[2] = {0,0}; diff_left = (int)ceil((float)diff/2.0f); // number of carriers to put on the left side - c[0] = abc[((1 << diff_left) - 1)]; // convert to bits and move to ASCI integer + c[0] = abc[(1 << diff_left) - 1]; // convert to bits and move to ASCI integer carriers.insert(0, c); diff_right = diff - diff_left; // number of carriers to put on the right side - c[0] = abc[(0xF^(1 << diff_left) - 1)]; // convert to bits and move to ASCI integer + c[0] = abc[0xF^((1 << diff_right) - 1)]; // convert to bits and move to ASCI integer carriers.insert(carriers.length(), c); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc deleted file mode 100644 index 0f974069e..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc +++ /dev/null @@ -1,252 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ofdm_qam_mapper.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <string.h> - -gr_ofdm_qam_mapper_sptr -gr_make_ofdm_qam_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length, - int m) -{ - return gr_ofdm_qam_mapper_sptr (new gr_ofdm_qam_mapper (msgq_limit, occupied_carriers, fft_length, m)); -} - -// Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -gr_ofdm_qam_mapper::gr_ofdm_qam_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length, - int m) - : gr_sync_block ("ofdm_qam_mapper", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), - d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_bit_offset(0), - d_pending_flag(0), - d_mod_order(m) -{ - if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("gr_ofdm_qam_mapper: occupied carriers must be <= fft_length"); - - bool ok = false; - if(m == 2) { - ok = true; - } - if(m == 4) { - ok = true; - } - if(m == 16) { - ok = true; - } - if(m == 64) { - ok = true; - } - if(m == 256) { - ok = true; - } - - if(!ok) - throw std::invalid_argument("Order M must be [2, 4, 16, 64, 256]"); - - make_constellation(); -} - -gr_ofdm_qam_mapper::~gr_ofdm_qam_mapper(void) -{ -} - -void gr_ofdm_qam_mapper::make_constellation() -{ - int i = 0, j = 0, ii = 0, jj = 0; - // number of bits/symbol (log2(M)) - int k = (int)(log10(d_mod_order) / log10(2.0)); - - int a, b; - float re, im; - float coeff = 1; - std::vector<int> bits_i, bits_q; - - int rr = 0; - int ss = 0; - int ll = bits_i.size(); - - for(i=0; i < d_mod_order; i++) { - a = (i & (0x01 << (k-1))) >> (k-1); - b = (i & (0x01 << (k-2))) >> (k-2); - for(j=2; j < k; j+=2) { - bits_i.push_back( (i & (0x01 << (k-j-1))) >> (k-j-1)); - bits_q.push_back( (i & (0x01 << (k-(j+1)-1))) >> (k-(j+1)-1)); - } - - ss = 0; - ll = bits_i.size(); - for(ii = 0; ii < ll; ii++) { - rr = 0; - for(jj = 0; jj < (ll-ii); jj++) { - rr = abs(bits_i[jj] - rr); - } - ss += rr * pow(2.0, ii+1.0); - } - re = (2.0*a-1.0)*(ss+1.0); - - ss = 0; - ll = bits_q.size(); - for(ii = 0; ii < ll; ii++) { - rr = 0; - for(jj = 0; jj < (ll-ii); jj++) { - rr = abs(bits_q[jj] - rr); - } - ss += rr*pow(2.0, ii+1.0); - } - im = (2.0*b-1.0)*(ss+1.0); - - a = std::max(re, im); - if(a > coeff) { - coeff = a; - } - d_constellation_map.push_back(gr_complex(re, im)); - } - - d_constellation_map[0] = gr_complex(-3, -3); - d_constellation_map[1] = gr_complex(-3, -1); - d_constellation_map[2] = gr_complex(-3, 1); - d_constellation_map[3] = gr_complex(-3, 3); - d_constellation_map[4] = gr_complex(-1, -3); - d_constellation_map[5] = gr_complex(-1, -1); - d_constellation_map[6] = gr_complex(-1, 1); - d_constellation_map[7] = gr_complex(-1, 3); - d_constellation_map[8] = gr_complex(1, -3); - d_constellation_map[9] = gr_complex(1, -1); - d_constellation_map[10] = gr_complex(1, 1); - d_constellation_map[11] = gr_complex(1, 3); - d_constellation_map[12] = gr_complex(3, -3); - d_constellation_map[13] = gr_complex(3, -1); - d_constellation_map[14] = gr_complex(3, 1); - d_constellation_map[15] = gr_complex(3, 3); - - coeff = sqrt(31.0)/2.0; - for(i = 0; i < static_cast<int>(d_constellation_map.size()); i++) { - d_constellation_map[i] /= coeff; - printf("const[%d]: %f + j%f\n", i, d_constellation_map[i].real(), d_constellation_map[i].imag()); - } -} - -#if 0 -static float -randombit() -{ - int r = rand()&1; - return (float)(-1 + 2*r); -} -#endif - -int -gr_ofdm_qam_mapper::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - unsigned int i=0; - unsigned int unoccupied_carriers = d_fft_length - d_occupied_carriers; - unsigned int zeros_on_left = (unsigned)ceil(unoccupied_carriers/2.0); - - //printf("OFDM QAM Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); - - if(d_eof) { - return -1; - } - - if(!d_msg) { - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - d_bit_offset = 0; - d_pending_flag = 1; // new packet, write start of packet flag - - if((d_msg->length() == 0) && (d_msg->type() == 1)) { - d_msg.reset(); - return -1; // We're done; no more messages coming. - } - } - - char *out_flag = 0; - if(output_items.size() == 2) - out_flag = (char *) output_items[1]; - - - // Build a single symbol: - - - // Initialize all bins to 0 to set unused carriers - memset(out, 0, d_fft_length*sizeof(gr_complex)); - - i = 0; - while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { - unsigned char bit0 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - unsigned char bit1 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - unsigned char bit2 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - unsigned char bit3 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - unsigned char bit = (bit0 << 3) | (bit1 << 2) | (bit2 << 1) | (bit3 << 0); - - out[i + zeros_on_left] = d_constellation_map[bit]; - i++; - if(d_bit_offset == 8) { - d_bit_offset = 0; - d_msg_offset++; - } - } - - // Ran out of data to put in symbol - if (d_msg_offset == d_msg->length()) { - while(i < d_occupied_carriers) { // finish filling out the symbol - out[i + zeros_on_left] = d_constellation_map[rand() & 0x0F]; - i++; - } - - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); // finished packet, free message - assert(d_bit_offset == 0); - } - - if (out_flag) - out_flag[0] = d_pending_flag; - d_pending_flag = 0; - - return 1; // produced symbol -} - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h b/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h deleted file mode 100644 index 7be03b41f..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_OFDM_QAM_MAPPER_H -#define INCLUDED_GR_OFDM_QAM_MAPPER_H - - -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_ofdm_qam_mapper; -typedef boost::shared_ptr<gr_ofdm_qam_mapper> gr_ofdm_qam_mapper_sptr; - -gr_ofdm_qam_mapper_sptr -gr_make_ofdm_qam_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length, - int m=4); - -/*! - * \brief take a message in and map to a vector of complex - * constellation points suitable for IFFT input to be used in an ofdm - * modulator. Simple QAM version. - * \ingroup modulation - */ - -class gr_ofdm_qam_mapper : public gr_sync_block -{ - friend gr_ofdm_qam_mapper_sptr - gr_make_ofdm_qam_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length, - int m); - protected: - gr_ofdm_qam_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length, - int m); - - private: - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - unsigned int d_occupied_carriers; - unsigned int d_fft_length; - unsigned int d_bit_offset; - int d_pending_flag; - - int d_mod_order; - std::vector<gr_complex> d_constellation_map; - - void make_constellation(); - - public: - ~gr_ofdm_qam_mapper(void); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.i b/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.i deleted file mode 100644 index 85ea84026..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.i +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_qam_mapper); - -gr_ofdm_qam_mapper_sptr -gr_make_ofdm_qam_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length, - int m=16); - - -class gr_ofdm_qam_mapper : public gr_sync_block -{ - protected: - gr_ofdm_qam_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length, - int m); - - public: - gr_msg_queue_sptr msgq(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.cc deleted file mode 100644 index 2c6fe5a55..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <gr_ofdm_qpsk_mapper.h> -#include <gr_io_signature.h> -#include <stdexcept> -#include <string.h> - -gr_ofdm_qpsk_mapper_sptr -gr_make_ofdm_qpsk_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) -{ - return gr_ofdm_qpsk_mapper_sptr (new gr_ofdm_qpsk_mapper (msgq_limit, occupied_carriers, fft_length)); -} - -// Consumes 1 packet and produces as many OFDM symbols of fft_length to hold the full packet -gr_ofdm_qpsk_mapper::gr_ofdm_qpsk_mapper (unsigned int msgq_limit, - unsigned int occupied_carriers, unsigned int fft_length) - : gr_sync_block ("ofdm_qpsk_mapper", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature2 (1, 2, sizeof(gr_complex)*fft_length, sizeof(char))), - d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), - d_occupied_carriers(occupied_carriers), - d_fft_length(fft_length), - d_bit_offset(0), - d_pending_flag(0) -{ - if (!(d_occupied_carriers <= d_fft_length)) - throw std::invalid_argument("gr_ofdm_qpsk_mapper: occupied carriers must be <= fft_length"); -} - -gr_ofdm_qpsk_mapper::~gr_ofdm_qpsk_mapper(void) -{ -} - -static gr_complex -randombit() -{ - int r1 = rand()&1; - int r2 = rand()&1; - return gr_complex((0.707)*(1 - 2*r1),(0.707)*(1 - 2*r2)); -} - -int -gr_ofdm_qpsk_mapper::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - unsigned int i=0; - unsigned int unoccupied_carriers = d_fft_length - d_occupied_carriers; - unsigned int zeros_on_left = (unsigned)ceil(unoccupied_carriers/2.0); - - //printf("OFDM QPSK Mapper: ninput_items: %d noutput_items: %d\n", ninput_items[0], noutput_items); - - if(d_eof) { - return -1; - } - - if(!d_msg) { - d_msg = d_msgq->delete_head(); // block, waiting for a message - d_msg_offset = 0; - d_bit_offset = 0; - d_pending_flag = 1; // new packet, write start of packet flag - - if((d_msg->length() == 0) && (d_msg->type() == 1)) { - d_msg.reset(); - return -1; // We're done; no more messages coming. - } - } - - char *out_flag = 0; - if(output_items.size() == 2) - out_flag = (char *) output_items[1]; - - - // Build a single symbol: - - - // Initialize all bins to 0 to set unused carriers - memset(out, 0, d_fft_length*sizeof(gr_complex)); - - i = 0; - while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) { - unsigned char bit0 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - unsigned char bit1 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01; - d_bit_offset++; - - out[i + zeros_on_left] = gr_complex((0.707)*(1-2*(bit0)), (0.707)*(1-2*(bit1)) ); - i++; - if(d_bit_offset == 8) { - d_bit_offset = 0; - d_msg_offset++; - } - } - - // Ran out of data to put in symbol - if (d_msg_offset == d_msg->length()) { - while(i < d_occupied_carriers) { // finish filling out the symbol - out[i + zeros_on_left] = randombit(); - i++; - } - - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); // finished packet, free message - assert(d_bit_offset == 0); - } - - if (out_flag) - out_flag[0] = d_pending_flag; - d_pending_flag = 0; - - return 1; // produced symbol -} - diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.h b/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.h deleted file mode 100644 index aa424ad65..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_GR_OFDM_QPSK_MAPPER_H -#define INCLUDED_GR_OFDM_QPSK_MAPPER_H - - -#include <gr_sync_block.h> -#include <gr_message.h> -#include <gr_msg_queue.h> - -class gr_ofdm_qpsk_mapper; -typedef boost::shared_ptr<gr_ofdm_qpsk_mapper> gr_ofdm_qpsk_mapper_sptr; - -gr_ofdm_qpsk_mapper_sptr -gr_make_ofdm_qpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - -/*! - * \brief take a message in and map to a vector of complex - * constellation points suitable for IFFT input to be used in an ofdm - * modulator. Simple QPSK version. - * \ingroup modulation - */ - -class gr_ofdm_qpsk_mapper : public gr_sync_block -{ - friend gr_ofdm_qpsk_mapper_sptr - gr_make_ofdm_qpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - protected: - gr_ofdm_qpsk_mapper (unsigned msgq_limit, - unsigned occupied_carriers, unsigned int fft_length); - - private: - gr_msg_queue_sptr d_msgq; - gr_message_sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - - unsigned int d_occupied_carriers; - unsigned int d_fft_length; - unsigned int d_bit_offset; - int d_pending_flag; - - public: - ~gr_ofdm_qpsk_mapper(void); - - gr_msg_queue_sptr msgq() const { return d_msgq; } - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -}; - - -#endif diff --git a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.i b/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.i deleted file mode 100644 index a36005c8f..000000000 --- a/gnuradio-core/src/lib/general/gr_ofdm_qpsk_mapper.i +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -GR_SWIG_BLOCK_MAGIC(gr,ofdm_qpsk_mapper); - -gr_ofdm_qpsk_mapper_sptr -gr_make_ofdm_qpsk_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - -class gr_ofdm_qpsk_mapper : public gr_sync_block -{ - protected: - gr_ofdm_qpsk_mapper (unsigned int msgq_limit, - unsigned int bits_per_symbol, - unsigned int fft_length); - - public: - gr_msg_queue_sptr msgq(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; |