[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4521 - in gnuradio/branches/developers/n4hy/ofdm/gnur
From: |
n4hy |
Subject: |
[Commit-gnuradio] r4521 - in gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src: lib/general python/gnuradio/blksimpl |
Date: |
Mon, 19 Feb 2007 15:25:35 -0700 (MST) |
Author: n4hy
Date: 2007-02-19 15:25:35 -0700 (Mon, 19 Feb 2007)
New Revision: 4521
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/ofdm_pkt.py
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am
Log:
trying this way to merge
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2007-02-19 22:14:55 UTC (rev 4520)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2007-02-19 22:25:35 UTC (rev 4521)
@@ -91,6 +91,12 @@
gr_nop.cc \
gr_null_sink.cc \
gr_null_source.cc \
+ 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_sampler.cc \
gr_pa_2x2_phase_combiner.cc \
gr_packet_sink.cc \
gr_phase_modulator_fc.cc \
@@ -213,6 +219,12 @@
gr_nop.h \
gr_null_sink.h \
gr_null_source.h \
+ gr_ofdm_cyclic_prefixer.h \
+ gr_ofdm_demapper_vcb.h \
+ gr_ofdm_mapper_bcv.h \
+ gr_ofdm_bpsk_mapper.h \
+ gr_ofdm_bpsk_demapper.h \
+ gr_ofdm_sampler.h \
gr_pa_2x2_phase_combiner.h \
gr_packet_sink.h \
gr_phase_modulator_fc.h \
@@ -336,6 +348,12 @@
gr_nop.i \
gr_null_sink.i \
gr_null_source.i \
+ 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_sampler.i \
gr_pa_2x2_phase_combiner.i \
gr_packet_sink.i \
gr_phase_modulator_fc.i \
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,103 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_demapper.h>
+#include <gr_io_signature.h>
+#include <vector>
+
+gr_ofdm_bpsk_demapper_sptr
+gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers, unsigned int vlen)
+{
+ return gr_ofdm_bpsk_demapper_sptr (new gr_ofdm_bpsk_demapper
(occupied_carriers, vlen));
+}
+
+gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers,
unsigned int vlen)
+ : gr_block ("ofdm_bpsk_demapper",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof(unsigned char))),
+ d_occupied_carriers(occupied_carriers),
+ d_vlen(vlen),
+ d_byte_offset(0)
+{
+}
+
+gr_ofdm_bpsk_demapper::~gr_ofdm_bpsk_demapper(void)
+{
+}
+
+unsigned char gr_ofdm_bpsk_demapper::slicer(gr_complex x)
+{
+ return (unsigned char)(x.real() > 0 ? 1 : 0);
+}
+
+void
+gr_ofdm_bpsk_demapper::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size ();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = 1;
+}
+
+int
+gr_ofdm_bpsk_demapper::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_complex *in = (const gr_complex *)input_items[0];
+ unsigned char *out = (unsigned char *) output_items[0];
+
+ unsigned int i=0, bytes_produced=0;
+
+ int unoccupied_carriers = d_vlen - d_occupied_carriers;
+ int zeros_on_left = (int)ceil(unoccupied_carriers/2.0);
+ // int zeros_on_right = (int)unoccupied_carriers - zeros_on_left;
+
+ i = zeros_on_left;
+ while(i < zeros_on_left+d_occupied_carriers) {
+
+ while((d_byte_offset < 8) && (i < zeros_on_left+d_occupied_carriers)) {
+ d_partial_byte |= slicer(in[i++]) << (d_byte_offset++);
+ }
+
+ if(d_byte_offset == 8) {
+ out[bytes_produced++] = d_partial_byte;
+ d_byte_offset = 0;
+ d_partial_byte = 0;
+ }
+ }
+
+#if 0
+printf("demod out: ");
+ for(i = 0; i < bytes_produced; i++) {
+ printf("%4x", out[i]);
+ }
+ printf(" \tlen: %d\n", i);
+#endif
+
+ consume_each(1);
+ return bytes_produced;
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_DEMAPPER_H
+#define INCLUDED_GR_OFDM_BPSK_DEMAPPER_H
+
+
+#include <gr_block.h>
+
+class gr_ofdm_bpsk_demapper;
+typedef boost::shared_ptr<gr_ofdm_bpsk_demapper> gr_ofdm_bpsk_demapper_sptr;
+
+gr_ofdm_bpsk_demapper_sptr
+gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers, unsigned int vlen);
+
+
+/*!
+ * \brief take a vector of complex constellation points in from an FFT
+ * and demodulate to a stream of bits. Simple BPSK version.
+ */
+
+class gr_ofdm_bpsk_demapper : public gr_block
+{
+ friend gr_ofdm_bpsk_demapper_sptr
+ gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers, unsigned int
vlen);
+
+ protected:
+ gr_ofdm_bpsk_demapper (unsigned int occupied_carriers, unsigned int vlen);
+
+ private:
+ unsigned char slicer(gr_complex x);
+
+ unsigned int d_occupied_carriers;
+ unsigned int d_vlen;
+ unsigned int d_byte_offset;
+ unsigned char d_partial_byte;
+
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+ ~gr_ofdm_bpsk_demapper(void);
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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_demapper)
+
+gr_ofdm_bpsk_demapper_sptr
+gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers,
+ unsigned int vlen);
+
+class gr_ofdm_bpsk_demapper : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_bpsk_demapper (unsigned int occupied_carriers,
+ unsigned int vlen);
+
+ public:
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,140 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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 <vector>
+
+gr_ofdm_bpsk_mapper_sptr
+gr_make_ofdm_bpsk_mapper (unsigned int mtu, unsigned int occupied_carriers,
unsigned int vlen)
+{
+ return gr_ofdm_bpsk_mapper_sptr (new gr_ofdm_bpsk_mapper (mtu,
occupied_carriers, vlen));
+}
+
+gr_ofdm_bpsk_mapper::gr_ofdm_bpsk_mapper (unsigned int mtu, unsigned int
occupied_carriers, unsigned int vlen)
+ : gr_block ("ofdm_bpsk_mapper",
+ gr_make_io_signature (1, 1, 2*sizeof(int) + sizeof(unsigned
char)*mtu),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen)),
+ d_mtu(mtu),
+ d_occupied_carriers(occupied_carriers),
+ d_vlen(vlen),
+ d_packet_offset(0),
+ d_bit_offset(0),
+ d_header_sent(0)
+{
+ assert(d_occupied_carriers < d_vlen);
+}
+
+gr_ofdm_bpsk_mapper::~gr_ofdm_bpsk_mapper(void)
+{
+}
+
+void
+gr_ofdm_bpsk_mapper::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size ();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = 1;
+}
+
+int
+gr_ofdm_bpsk_mapper::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const gr_frame *in = (const gr_frame *) input_items[0];
+ gr_complex *out = (gr_complex *)output_items[0];
+
+ unsigned int i=0;
+ unsigned int num_symbols = 0, pkt_length;
+
+ pkt_length = in[0].length;
+
+ if(!d_header_sent) {
+ // Add training symbols here
+ for(i=0; i < (ceil((d_vlen - d_occupied_carriers)/2.0)); i++) {
+ out[i] = gr_complex(0,0);
+ }
+ for(;i<d_vlen - ceil((d_vlen-d_occupied_carriers)/2.0);i++) {
+ out[i] = gr_complex(1,0);
+ }
+ for(; i < d_vlen; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ num_symbols = 1;
+ out += d_vlen;
+ d_header_sent = true;
+ }
+
+ unsigned int unoccupied_carriers = d_vlen - d_occupied_carriers;
+ unsigned int zeros_on_left = (unsigned)ceil(unoccupied_carriers/2.0);
+ unsigned int zeros_on_right = unoccupied_carriers - zeros_on_left;
+
+
+ while(num_symbols < (unsigned)noutput_items) {
+
+ // stick in unused carriers
+ for(i = d_vlen-zeros_on_right; i < d_vlen; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ for(i=0; i < zeros_on_left; i++) {
+ out[i] = gr_complex(0,0);
+ }
+
+ while((d_packet_offset < pkt_length) && (i < d_vlen-zeros_on_right)) {
+ unsigned char bit = (in[0].data[d_packet_offset] >> (d_bit_offset++)) &
0x01;
+ out[i++] = gr_complex(-1+2*(bit));
+ if(d_bit_offset == 8) {
+ d_bit_offset = 0;
+ d_packet_offset++;
+ }
+ }
+
+ // Ran out of data to put in symbols
+ if(d_packet_offset == pkt_length) {
+ while(i < d_vlen-zeros_on_right) {
+ out[i++] = gr_complex(0,0);
+ }
+
+ d_packet_offset = 0;
+ assert(d_bit_offset == 0);
+ num_symbols++;
+ d_header_sent = false;
+ consume_each(1);
+ return num_symbols;
+ }
+
+ // Ran out of space in symbol
+ out += d_vlen;
+ num_symbols++;
+ }
+ consume_each(0);
+ return num_symbols;
+}
+
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_block.h>
+#include <gr_frame.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 mtu, unsigned occupied_carriers, unsigned
int vlen);
+
+
+/*!
+ * \brief take a stream of bytes in and map to a vector of complex
+ * constellation points suitable for IFFT input to be used in an ofdm
+ * modulator. Simple BPSK version.
+ */
+
+class gr_ofdm_bpsk_mapper : public gr_block
+{
+ friend gr_ofdm_bpsk_mapper_sptr
+ gr_make_ofdm_bpsk_mapper (unsigned mtu, unsigned occupied_carriers,
unsigned int vlen);
+
+ protected:
+ gr_ofdm_bpsk_mapper (unsigned mtu, unsigned occupied_carriers, unsigned int
vlen);
+
+ private:
+ unsigned int d_mtu;
+ unsigned int d_occupied_carriers;
+ unsigned int d_vlen;
+ unsigned int d_packet_offset;
+ unsigned int d_bit_offset;
+ bool d_header_sent;
+
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ public:
+ ~gr_ofdm_bpsk_mapper(void);
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+};
+
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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 mtu,
+ unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+class gr_ofdm_bpsk_mapper : public gr_block
+{
+ protected:
+ gr_ofdm_bpsk_mapper (unsigned int mtu,
+ unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+ public:
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,69 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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_cyclic_prefixer.h>
+#include <gr_io_signature.h>
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size)
+{
+ return gr_ofdm_cyclic_prefixer_sptr (new gr_ofdm_cyclic_prefixer
(input_size, output_size));
+}
+
+gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t
output_size)
+ : gr_sync_interpolator ("ofdm_cyclic_prefixer",
+ gr_make_io_signature (1, 1,
input_size*sizeof(gr_complex)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)),
+ output_size),
+ d_input_size(input_size),
+ d_output_size(output_size)
+
+{
+}
+
+int
+gr_ofdm_cyclic_prefixer::work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *iptr, *optr;
+ gr_complex *in = (gr_complex *) input_items[0];
+ gr_complex *out = (gr_complex *) output_items[0];
+ size_t cp_size = d_output_size - d_input_size;
+ unsigned int i=0;
+
+ optr = &out[cp_size];
+ for(i=0; i < d_input_size; i++,optr++) {
+ *optr = in[i];
+ }
+
+ iptr = &in[d_input_size - cp_size];
+ for(i=0; i < cp_size; i++, iptr++) {
+ out[i] = *iptr;
+ }
+
+ return d_output_size;
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2005,2006 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 2, 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_CYCLIC_PREFIXER_H
+#define INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H
+
+#include <gr_sync_interpolator.h>
+#include <stdio.h>
+
+class gr_ofdm_cyclic_prefixer;
+typedef boost::shared_ptr<gr_ofdm_cyclic_prefixer>
gr_ofdm_cyclic_prefixer_sptr;
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+
+/*!
+ * \brief adds a cyclic prefix vector to an input size long ofdm
+ * symbol(vector) and converts vector to a stream output_size long.
+ * \ingroup block
+ */
+class gr_ofdm_cyclic_prefixer : public gr_sync_interpolator
+{
+ friend gr_ofdm_cyclic_prefixer_sptr
+ gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ protected:
+ gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ public:
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ private:
+ size_t d_input_size;
+ size_t d_output_size;
+};
+
+#endif /* INCLUDED_GR_OFDM_CYCLIC_PREFIXER_H */
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_cyclic_prefixer)
+
+gr_ofdm_cyclic_prefixer_sptr
+gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+class gr_ofdm_cyclic_prefixer : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size);
+
+ public:
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,41 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2005 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 2, 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_demapper_vcb.h>
+#include <gr_io_signature.h>
+
+gr_ofdm_demapper_vcb::~gr_ofdm_demapper_vcb(void)
+{
+}
+
+gr_ofdm_demapper_vcb::gr_ofdm_demapper_vcb (unsigned bits_per_symbol,unsigned
int vlen)
+ : gr_sync_decimator ("ofdm_demapper_vcb",
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen),
+ gr_make_io_signature (1, 1, sizeof(unsigned char)),
+ bits_per_symbol)
+{
+}
+
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_DEMAPPER_VCB_H
+#define INCLUDED_GR_OFDM_DEMAPPER_VCB_H
+
+#include <gr_sync_decimator.h>
+
+class gr_ofdm_demapper_vcb;
+typedef boost::shared_ptr<gr_ofdm_demapper_vcb> gr_ofdm_demapper_vcb_sptr;
+
+gr_ofdm_demapper_vcb_sptr
+gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen);
+
+
+/*!
+ * \brief take a stream of vectors in from an FFT and demodulate to a stream of
+ * bits. Abstract class must be subclassed with specific mapping.
+ *
+ */
+
+class gr_ofdm_demapper_vcb : public gr_sync_decimator
+{
+ friend gr_ofdm_demapper_vcb_sptr
+ gr_make_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen);
+
+protected:
+ gr_ofdm_demapper_vcb (unsigned int bits_per_symbol, unsigned int vlen);
+
+public:
+ ~gr_ofdm_demapper_vcb(void);
+};
+
+
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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_mapper_bcv)
+
+gr_ofdm_mapper_bcv_sptr
+gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+ public:
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,41 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2005 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 2, 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_mapper_bcv.h>
+#include <gr_io_signature.h>
+
+gr_ofdm_mapper_bcv::~gr_ofdm_mapper_bcv(void)
+{
+}
+
+gr_ofdm_mapper_bcv::gr_ofdm_mapper_bcv (unsigned bits_per_symbol,unsigned int
vlen)
+ : gr_sync_decimator ("ofdm_mapper_bcv",
+ gr_make_io_signature (1, 1, sizeof(unsigned char)),
+ gr_make_io_signature (1, 1, sizeof(gr_complex)*vlen),
+ bits_per_symbol)
+{
+}
+
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 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 2, 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_MAPPER_BCV_H
+#define INCLUDED_GR_OFDM_MAPPER_BCV_H
+
+#include <gr_sync_decimator.h>
+
+class gr_ofdm_mapper_bcv;
+typedef boost::shared_ptr<gr_ofdm_mapper_bcv> gr_ofdm_mapper_bcv_sptr;
+
+gr_ofdm_mapper_bcv_sptr
+gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol, unsigned int vlen);
+
+
+/*!
+ * \brief take a stream of bytes in and map to a vector of complex
+ * constellation points suitable for IFFT input to be used in an ofdm
+ * modulator. Abstract class must be subclassed with specific mapping.
+ *
+ */
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ friend gr_ofdm_mapper_bcv_sptr
+ gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol, unsigned int vlen);
+
+protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol, unsigned int vlen);
+
+public:
+ ~gr_ofdm_mapper_bcv(void);
+};
+
+
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 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 2, 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_mapper_bcv)
+
+gr_ofdm_mapper_bcv_sptr
+gr_make_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+class gr_ofdm_mapper_bcv : public gr_sync_decimator
+{
+ protected:
+ gr_ofdm_mapper_bcv (unsigned int bits_per_symbol,
+ unsigned int vlen);
+
+ public:
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,135 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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 2, 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_sampler.h>
+#include <gr_io_signature.h>
+#include <gr_expj.h>
+
+gr_ofdm_sampler_sptr
+gr_make_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length,
+ int delay)
+{
+ return gr_ofdm_sampler_sptr (new gr_ofdm_sampler (fft_length, symbol_length,
delay));
+}
+
+gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length,
+ int delay)
+ : gr_block ("ofdm_sampler",
+ gr_make_io_signature (3, 3, sizeof (gr_complex)),
+ gr_make_io_signature (1, 1, sizeof (gr_complex)*fft_length)),
+ d_fft_length(fft_length), d_symbol_length(symbol_length), d_delay(delay),
+ d_phase(0), d_freq(0), d_avg(0)
+{
+}
+
+void
+gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
+{
+ // FIXME need more if we want to produce more than 1
+ int nreqd = d_fft_length + d_symbol_length + 1;
+ unsigned ninputs = ninput_items_required.size ();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = nreqd;
+}
+
+int
+gr_ofdm_sampler::general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *theta = (gr_complex *) input_items[1];
+ gr_complex *epsilon = (gr_complex *) input_items[2];
+ gr_complex *iptr = (gr_complex *) input_items[0];
+ gr_complex *optr = (gr_complex *) output_items[0];
+
+ int found=0;
+ float alpha = 0.01;
+
+ d_avg = 0;
+ for(unsigned int i=0;i<d_symbol_length+d_fft_length;i++) {
+ //d_avg = (alpha)*theta[i].real() + (1-alpha)*d_avg;
+ d_avg += theta[i].real();
+ }
+ d_avg /= (d_symbol_length+d_fft_length);
+
+ unsigned int i=d_fft_length;
+
+ #if DEBUG
+ for(i = 0; i < d_fft_length; i++)
+ fprintf(stderr,"%d %f -2000 -1000\n",i, theta[i].real());
+ #endif
+
+ while(i<d_symbol_length+d_fft_length && (found==0)) {
+#if 0
+ if( (theta[i].real() > d_avg*0.25) &&
+ (theta[i].real() > theta[i+1].real()) ) {
+ found = 1;
+ for(unsigned int j=1; j < 10; j++) {
+ if(theta[i+j].real() > theta[i].real()) {
+ found = 0;
+ d_phase += d_freq;
+ i++;
+ break;
+ }
+ }
+#else
+ if(i == d_symbol_length-1) {
+ found = 1;
+#endif
+
+ if(found) {
+ //fprintf(stderr,"%d %f\n",i,theta[i].real());
+ #if DEBUG
+ if(i != d_symbol_length-1) {
+ fprintf(stderr,"%d %f 0 0\n",i, theta[i].real());
+ }
+ else
+ fprintf(stderr,"%d %f 0 -1000\n",i, theta[i].real());
+ #endif
+
+ d_freq = epsilon[i].real() / d_fft_length;
+ for(unsigned int j=0;j<d_fft_length;j++) {
+ d_phase += d_freq;
+ gr_complex nco = gr_expj(-d_phase);
+ *optr++ = nco * iptr[i-d_fft_length+j+1];
+ }
+ }
+ i++;
+ }
+ else {
+ d_phase += d_freq;
+ i++;
+ #if DEBUG
+ fprintf(stderr,"%d %f -2000 -1000\n",i, theta[i].real());
+ #endif
+ }
+ }
+ consume_each(d_symbol_length);
+ return found;
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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 2, 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_SAMPLER_H
+#define INCLUDED_GR_OFDM_SAMPLER_H
+
+#include <gr_sync_block.h>
+
+class gr_ofdm_sampler;
+typedef boost::shared_ptr<gr_ofdm_sampler> gr_ofdm_sampler_sptr;
+
+gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length,
+ int delay);
+
+/*!
+ * \brief does the rest of the OFDM stuff (fixme)
+ */
+
+class gr_ofdm_sampler : public gr_block
+{
+ friend gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length,
+ int delay);
+
+ gr_ofdm_sampler (unsigned int fft_length,
+ unsigned int symbol_length,
+ int delay);
+
+ private:
+ unsigned int d_fft_length;
+ unsigned int d_symbol_length;
+ int d_delay;
+ float d_phase;
+ float d_freq;
+ float d_avg;
+
+ public:
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ int general_work (int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,31 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004 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 2, 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_sampler)
+
+gr_ofdm_sampler_sptr gr_make_ofdm_sampler (unsigned int fft_length, unsigned
int symbol_length, int delay);
+
+class gr_ofdm_sampler : public gr_sync_block
+{
+ private:
+ gr_ofdm_sampler (unsigned int fft_length, unsigned int symbol_length, int
delay);
+};
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am
2007-02-19 22:14:55 UTC (rev 4520)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/Makefile.am
2007-02-19 22:25:35 UTC (rev 4521)
@@ -37,6 +37,7 @@
gmsk.py \
nbfm_rx.py \
nbfm_tx.py \
+ ofdm_pkt.py \
pkt.py \
psk.py \
rational_resampler.py \
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/ofdm_pkt.py
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/ofdm_pkt.py
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/python/gnuradio/blksimpl/ofdm_pkt.py
2007-02-19 22:25:35 UTC (rev 4521)
@@ -0,0 +1,159 @@
+#
+# Copyright 2005,2006 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 2, 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.
+#
+
+from math import pi
+import Numeric
+
+from gnuradio import gr, packet_utils
+import gnuradio.gr.gr_threading as _threading
+
+
+# /////////////////////////////////////////////////////////////////////////////
+# mod/demod with packets as i/o
+# /////////////////////////////////////////////////////////////////////////////
+
+class mod_ofdm_pkts(gr.hier_block):
+ """
+ Wrap an arbitrary digital modulator in our packet handling framework.
+
+ Send packets by calling send_pkt
+ """
+ def __init__(self, fg, modulator, access_code=None, msgq_limit=2,
pad_for_usrp=True):
+ """
+ Hierarchical block for sending packets
+
+ Packets to be sent are enqueued by calling send_pkt.
+ The output is the complex modulated signal at baseband.
+
+ @param fg: flow graph
+ @type fg: flow graph
+ @param modulator: instance of modulator class (gr_block or hier_block)
+ @type modulator: complex baseband out
+ @param access_code: AKA sync vector
+ @type access_code: string of 1's and 0's between 1 and 64 long
+ @param msgq_limit: maximum number of messages in message queue
+ @type msgq_limit: int
+ @param pad_for_usrp: If true, packets are padded such that they end up
a multiple of 128 samples
+
+ See modulators for remaining parameters
+ """
+ self._modulator = modulator
+ self._pad_for_usrp = pad_for_usrp
+
+ if access_code is None:
+ access_code = packet_utils.default_access_code
+ if not packet_utils.is_1_0_string(access_code):
+ raise ValueError, "Invalid access_code %r. Must be string of 1's
and 0's" % (access_code,)
+ self._access_code = access_code
+
+ # accepts messages from the outside world
+ self._pkt_input = gr.message_vector_source(self._modulator.mtu(),
msgq_limit)
+ fg.connect(self._pkt_input, self._modulator)
+ gr.hier_block.__init__(self, fg, None, self._modulator)
+
+ def send_pkt(self, payload='', eof=False):
+ """
+ Send the payload.
+
+ @param payload: data to send
+ @type payload: string
+ """
+ if eof:
+ msg = gr.message(1) # tell self._pkt_input we're not sending any
more packets
+ else:
+ # print "original_payload =", string_to_hex_list(payload)
+ pkt = packet_utils.make_packet(payload,
+
self._modulator.samples_per_symbol(),
+ self._modulator.bits_per_symbol(),
+ self._access_code,
+ self._pad_for_usrp)
+ #print "pkt =", string_to_hex_list(pkt)
+ msg = gr.message_from_string(pkt)
+ self._pkt_input.msgq().insert_tail(msg)
+
+
+
+class demod_ofdm_pkts(gr.hier_block):
+ """
+ Wrap an arbitrary digital demodulator in our packet handling framework.
+
+ The input is complex baseband. When packets are demodulated, they are
passed to the
+ app via the callback.
+ """
+
+ def __init__(self, fg, demodulator, access_code=None, callback=None,
threshold=-1):
+ """
+ Hierarchical block for demodulating and deframing packets.
+
+ The input is the complex modulated signal at baseband.
+ Demodulated packets are sent to the handler.
+
+ @param fg: flow graph
+ @type fg: flow graph
+ @param demodulator: instance of demodulator class (gr_block or
hier_block)
+ @type demodulator: complex baseband in
+ @param access_code: AKA sync vector
+ @type access_code: string of 1's and 0's
+ @param callback: function of two args: ok, payload
+ @type callback: ok: bool; payload: string
+ @param threshold: detect access_code with up to threshold bits wrong
(-1 -> use default)
+ @type threshold: int
+ """
+
+ self._demodulator = demodulator
+ if access_code is None:
+ access_code = packet_utils.default_access_code
+ if not packet_utils.is_1_0_string(access_code):
+ raise ValueError, "Invalid access_code %r. Must be string of 1's
and 0's" % (access_code,)
+ self._access_code = access_code
+
+ if threshold == -1:
+ threshold = 12 # FIXME raise exception
+
+ self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY
+ self.bytes_to_bits = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
+ self.correlator = gr.correlate_access_code_bb(access_code, threshold)
+
+ self.framer_sink = gr.framer_sink_1(self._rcvd_pktq)
+ fg.connect(self._demodulator, self.bytes_to_bits, self.correlator,
self.framer_sink)
+
+ fg.connect(self.bytes_to_bits, gr.file_sink(gr.sizeof_char,
"received_bits.out"))
+
+ gr.hier_block.__init__(self, fg, self._demodulator, None)
+ self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
+
+
+class _queue_watcher_thread(_threading.Thread):
+ def __init__(self, rcvd_pktq, callback):
+ _threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.rcvd_pktq = rcvd_pktq
+ self.callback = callback
+ self.keep_running = True
+ self.start()
+
+
+ def run(self):
+ while self.keep_running:
+ msg = self.rcvd_pktq.delete_head()
+ ok, payload = packet_utils.unmake_packet(msg.to_string())
+ if self.callback:
+ self.callback(ok, payload)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4521 - in gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src: lib/general python/gnuradio/blksimpl,
n4hy <=