commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4306 - in gnuradio/branches/developers/n4hy/ofdm2: gn


From: n4hy
Subject: [Commit-gnuradio] r4306 - in gnuradio/branches/developers/n4hy/ofdm2: gnuradio-core/src/lib/general gnuradio-examples/python gnuradio-examples/python/ofdm
Date: Sun, 28 Jan 2007 10:41:59 -0700 (MST)

Author: n4hy
Date: 2007-01-28 10:41:58 -0700 (Sun, 28 Jan 2007)
New Revision: 4306

Added:
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
   gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/fftshift.py
   gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm_receiver.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/pick_bitrate.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path_simple.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path.py
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path_simple.py
Modified:
   
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/Makefile.am
Log:
ofdm merged with trunk at 4305

Modified: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/Makefile.am
   2007-01-28 17:19:30 UTC (rev 4305)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/Makefile.am
   2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc
      2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.h
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.i
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
                                (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.cc
        2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.h
 2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_bpsk_mapper.i
 2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc
    2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.h
     2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.i
     2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.cc
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
                                (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.h
        2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
                                (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_demapper_vcb.i
        2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
 2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
                          (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
  2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
                          (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.i
  2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
                            (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
    2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
     2007-01-28 17:41:58 UTC (rev 4306)
@@ -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/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
     2007-01-28 17:41:58 UTC (rev 4306)
@@ -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);
+};

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm.py
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm.py
     2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+#
+# 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 gnuradio import gr, gru, modulation_utils
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+import random, time, struct, sys, math, os
+
+# from current dir
+from transmit_path_simple import transmit_path
+from receive_path_simple import receive_path
+import ofdm
+
+class awgn_channel(gr.hier_block):
+    def __init__(self, fg, sample_rate, noise_voltage, frequency_offset):
+
+        self.input = gr.add_const_cc(0)
+        
+        self.noise_adder = gr.add_cc()
+        self.noise = gr.noise_source_c(gr.GR_GAUSSIAN,noise_voltage)
+        self.offset = gr.sig_source_c((sample_rate*1.0), gr.GR_SIN_WAVE, 
frequency_offset, 1.0, 0.0)
+        self.mixer_offset = gr.multiply_cc()
+
+        fg.connect(self.input, (self.mixer_offset,0))
+        fg.connect(self.offset,(self.mixer_offset,1))
+        fg.connect(self.mixer_offset, (self.noise_adder,1))
+        fg.connect(self.noise, (self.noise_adder,0))
+
+        gr.hier_block.__init__(self, fg, self.input, self.noise_adder)
+
+class my_graph(gr.flow_graph):
+    def __init__(self, callback, options):
+        gr.flow_graph.__init__(self)
+
+        channel_on = True
+
+        SNR = 10.0**(options.snr/10.0)
+        frequency_offset = options.frequency_offset / options.fft_length
+        
+        power_in_signal = options.occupied_tones
+        noise_power_in_channel = power_in_signal/SNR
+        noise_power_required = noise_power_in_channel * options.fft_length / 
options.occupied_tones
+        noise_voltage = math.sqrt(noise_power_required)
+        
+        self.txpath = transmit_path(self, options)
+        self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
+        self.rxpath = receive_path(self, callback, options)
+
+        if channel_on:
+            self.channel = awgn_channel(self, options.sample_rate, 
noise_voltage, frequency_offset)
+            self.connect(self.txpath, self.throttle, self.channel)
+            self.connect(self.channel, self.rxpath)
+        else:
+            self.connect(self.txpath, self.throttle, self.rxpath)
+            self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, "tx"))
+            self.connect(self.rxpath.ofdm_demod.ofdm_rx, 
gr.file_sink(options.fft_length*gr.sizeof_gr_complex, "rx"))
+
+
+# /////////////////////////////////////////////////////////////////////////////
+#                                   main
+# /////////////////////////////////////////////////////////////////////////////
+
+def main():
+    global n_rcvd, n_right
+        
+    n_rcvd = 0
+    n_right = 0
+        
+    def send_pkt(payload='', eof=False):
+        return fg.txpath.send_pkt(payload, eof)
+        
+    def rx_callback(ok, payload):
+        global n_rcvd, n_right
+        n_rcvd += 1
+        if ok:
+            n_right += 1
+        print "ok: %r \t n_rcvd: %d \t n_right: %d" % (ok, n_rcvd, n_right)
+                
+    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
+    expert_grp = parser.add_option_group("Expert")
+    parser.add_option("-s", "--size", type="eng_float", default=1450,
+                      help="set packet size [default=%default]")
+    parser.add_option("-M", "--megabytes", type="eng_float", default=1.0,
+                      help="set megabytes to transmit [default=%default]")
+    parser.add_option("-r", "--sample-rate", type="eng_float", default=1e5,
+                      help="set sample rate to RATE (%default)") 
+    parser.add_option("", "--snr", type="eng_float", default=30,
+                      help="set the SNR of the channel in dB 
[default=%default]")
+    parser.add_option("", "--frequency-offset", type="eng_float", default=0,
+                      help="set frequency offset introduced by channel 
[default=%default]")
+    transmit_path.add_options(parser, expert_grp)
+    ofdm.ofdm_mod.add_options(parser, expert_grp)
+    ofdm.ofdm_demod.add_options(parser, expert_grp)
+    
+    (options, args) = parser.parse_args ()
+
+    if(options.mtu < options.size):
+        sys.stderr.write("MTU (%.0f) must be larger than the packet size 
(%.0f)\n"
+                         % (options.mtu, options.size))
+        sys.exit(1)
+        
+    # build the graph
+    fg = my_graph(rx_callback, options)
+    
+    r = gr.enable_realtime_scheduling()
+    #    if r != gr.RT_OK:
+    #        print "Warning: failed to enable realtime scheduling"
+        
+    fg.start()                       # start flow graph
+    
+    # generate and send packets
+    nbytes = int(1e6 * options.megabytes)
+    n = 0
+    pktno = 0
+    pkt_size = int(options.size)
+    
+    while n < nbytes:
+        pkt_contents = struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 
0xff)
+        send_pkt(pkt_contents)
+        n += pkt_size
+        #sys.stderr.write('.')
+        #if options.discontinuous and pktno % 5 == 4:
+        #    time.sleep(1)
+        pktno += 1
+        
+    send_pkt(eof=True)
+    fg.wait()                       # wait for it to finish
+
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass


Property changes on: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm.py
___________________________________________________________________
Name: svn:executable
   + *

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py
                          (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py
  2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# 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 gnuradio import gr, gru, modulation_utils
+from gnuradio import usrp
+from gnuradio import eng_notation
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+import random, time, struct, sys, math
+
+# from current dir
+from transmit_path import transmit_path
+
+class my_graph(gr.flow_graph):
+    def __init__(self, callback, occupied_tones, fftsize, symbol_length, rho):
+        gr.flow_graph.__init__(self)
+        self.txpath = transmit_path(self, occupied_tones, fftsize, 
symbol_length)
+
+# /////////////////////////////////////////////////////////////////////////////
+#                                   main
+# /////////////////////////////////////////////////////////////////////////////
+
+def main():
+
+    def send_pkt(payload='', eof=False):
+        return fg.txpath.send_pkt(payload, eof)
+
+    # build the graph
+    fg = my_graph(rx_callback, options)
+
+    r = gr.enable_realtime_scheduling()
+    if r != gr.RT_OK:
+        print "Warning: failed to enable realtime scheduling"
+
+    fg.start()                       # start flow graph
+
+    # generate and send packets
+    nbytes = int(1e6 * options.megabytes)
+    n = 0
+    pktno = 0
+    pkt_size = int(options.size)
+
+    while n < nbytes:
+        send_pkt(struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff))
+        n += pkt_size
+        sys.stderr.write('.')
+        #if options.discontinuous and pktno % 5 == 4:
+        #    time.sleep(1)
+        pktno += 1
+        
+    send_pkt(eof=True)
+    fg.wait()                       # wait for it to finish
+
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass


Property changes on: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/benchmark_ofdm_tx.py
___________________________________________________________________
Name: svn:executable
   + *

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/fftshift.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/fftshift.py
                           (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/fftshift.py
   2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+from gnuradio import gr
+
+class my_graph(gr.flow_graph):
+    def __init__(self):
+        gr.flow_graph.__init__(self)
+
+        length = 101
+
+        data_r = range(length)
+        data_i = range(length,2*length)
+        src_r = gr.vector_source_s(data_r, False)
+        src_i = gr.vector_source_s(data_i, False)
+        s2f_r = gr.short_to_float()
+        s2f_i = gr.short_to_float()
+        f2c = gr.float_to_complex()
+        s2v = gr.stream_to_vector(gr.sizeof_gr_complex, length)
+
+        shift = True
+        ifft = gr.fft_vcc(length, False, [], shift)
+        fft  = gr.fft_vcc(length, True, [], shift)
+        
+        v2s = gr.vector_to_stream(gr.sizeof_gr_complex, length)
+        snk_in = gr.file_sink(gr.sizeof_gr_complex, "fftshift.in")
+        snk_out = gr.file_sink(gr.sizeof_gr_complex, "fftshift.out")
+
+        self.connect(src_r, s2f_r, (f2c,0))
+        self.connect(src_i, s2f_i, (f2c,1))
+        self.connect(f2c, snk_in)
+        self.connect(f2c, s2v, ifft, fft, v2s, snk_out)
+        
+
+def main():
+    fg = my_graph()
+    fg.start()
+    fg.wait()
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


Property changes on: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/fftshift.py
___________________________________________________________________
Name: svn:executable
   + *

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm.py   
                            (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm.py   
    2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,140 @@
+#!/usr/bin/env python
+#
+# 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.
+# 
+
+from gnuradio import gr
+from optparse import OptionParser
+from ofdm_receiver import ofdm_receiver
+
+class ofdm_mod(gr.hier_block):
+    def __init__(self, fg, options):
+        self.fg = fg
+        self._occupied_tones = options.occupied_tones
+        self._fft_length = options.fft_length
+        self._cp_length = options.cp_length
+        self._mtu = options.mtu
+
+        symbol_length = self._fft_length + self._cp_length
+
+        if self._fft_length < self._occupied_tones:
+            sys.stderr.write("occupied tones must be less than FFT length\n")
+            raise SystemExit
+        if self._fft_length < self._cp_length:
+            sys.stderr.write("cyclic prefix length  must be less than FFT 
length\n")
+            raise SystemExit
+
+        win = [] #[1 for i in range(self._fft_length)]
+
+        self.ofdm = gr.ofdm_bpsk_mapper(self._mtu, self._occupied_tones, 
self._fft_length)
+        self.ifft = gr.fft_vcc(self._fft_length, False, win, True)
+        self.cp_adder = gr.ofdm_cyclic_prefixer(self._fft_length, 
symbol_length)
+        
+        if options.verbose:
+            self._print_verbage()
+
+        self.fg.connect(self.ofdm, self.ifft, self.cp_adder)
+        gr.hier_block.__init__(self, self.fg, self.ofdm, self.cp_adder)
+
+    def samples_per_symbol(self):
+        return 2
+
+    def mtu(self):
+        return self._mtu
+
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
+        return 1
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
+
+    def add_options(normal, expert):
+        """
+        Adds OFDM-specific options to the Options Parser
+        """
+        expert.add_option("", "--mtu", type="int", default=1500,
+                          help="set maximum transmit unit [default=%default]")
+        expert.add_option("", "--fft-length", type="intx", default=512,
+                          help="set the number of FFT bins [default=%default]")
+        expert.add_option("", "--occupied-tones", type="intx", default=480,
+                          help="set the number of occupied FFT bins 
[default=%default]")
+        expert.add_option("", "--cp-length", type="intx", default=32,
+                          help="set the number of bits in the cyclic prefix 
[default=%default]")
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the OFDM modulator
+        """
+        print "\nOFDM Modulator:"
+        print "FFT length:      %3d"   % (self._fft_length)
+        print "Occupied Tones:  %3d"   % (self._occupied_tones)
+        print "CP length:       %3d"   % (self._cp_length)
+
+
+class ofdm_demod(gr.hier_block):
+    def __init__(self, fg, options):
+        self.fg = fg
+        self._occupied_tones = options.occupied_tones
+        self._fft_length = options.fft_length
+        self._cp_length = options.cp_length
+        self._snr = options.snr
+
+        symbol_length = self._fft_length + self._cp_length
+
+        win = [1 for i in range(self._fft_length)]
+
+        # ML Sync
+        self.ofdm_rx = ofdm_receiver(self.fg, self._fft_length, symbol_length, 
self._snr)
+        
+        # OFDM Demod
+        self.fftdemod = gr.fft_vcc(self._fft_length, True, win, True)
+        self.ofdm = gr.ofdm_bpsk_demapper(self._occupied_tones, 
self._fft_length)
+
+        if options.verbose:
+            self._print_verbage()
+
+        self.fg.connect(self.ofdm_rx, self.fftdemod, self.ofdm)
+        gr.hier_block.__init__(self, self.fg, self.ofdm_rx, self.ofdm)
+
+    def bits_per_symbol(self=None):   # staticmethod that's also callable on 
an instance
+        return 1
+    bits_per_symbol = staticmethod(bits_per_symbol)      # make it a static 
method.  RTFM
+
+    def add_options(normal, expert):
+        """
+        Adds OFDM-specific options to the Options Parser
+        """
+        expert.add_option("", "--fft-length", type="intx", default=512,
+                          help="set the number of FFT bins [default=%default]")
+        expert.add_option("", "--occupied-tones", type="intx", default=480,
+                          help="set the number of occupied FFT bins 
[default=%default]")
+        expert.add_option("", "--cp-length", type="intx", default=32,
+                          help="set the number of bits in the cyclic prefix 
[default=%default]")
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the OFDM demodulator
+        """
+        print "\nOFDM Demodulator:"
+        print "FFT length:      %3d"   % (self._fft_length)
+        print "Occupied Tones:  %3d"   % (self._occupied_tones)
+        print "CP length:       %3d"   % (self._cp_length)

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm_receiver.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm_receiver.py
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/ofdm_receiver.py
      2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+#
+# 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.
+# 
+
+import math
+from gnuradio import gr
+from gnuradio import audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class ofdm_receiver(gr.hier_block):
+    def __init__(self, fg, fft_length, symbol_length, snr):
+        self.input = gr.add_const_cc(0) # Kluge that goes away with hier_block2
+
+        self.fg = fg
+        
+        cpsize = symbol_length - fft_length;
+
+        SNR = 10.0**(snr/10.0)
+        rho = SNR / (SNR + 1.0)
+
+        # ML Sync
+
+        # Energy Detection from ML Sync
+
+        # Create a delay line
+        delayline = [0.0 for i in range(fft_length+1)]
+        delayline[fft_length] = 1.0
+        self.delay = gr.fir_filter_ccf(1,delayline)
+        self.fg.connect(self.input, self.delay)
+
+        # magnitude squared blocks
+        self.magsqrd1 = gr.complex_to_mag_squared()
+        self.magsqrd2 = gr.complex_to_mag_squared()
+        self.adder = gr.add_ff()
+
+        moving_sum_taps = [rho/2 for i in range(cpsize)]
+        self.moving_sum_filter = gr.fir_filter_fff(1,moving_sum_taps)
+        
+        self.fg.connect(self.input,self.magsqrd1)
+        self.fg.connect(self.delay,self.magsqrd2)
+        self.fg.connect(self.magsqrd1,(self.adder,0))
+        self.fg.connect(self.magsqrd2,(self.adder,1))
+        self.fg.connect(self.adder,self.moving_sum_filter)
+        
+
+        # Correlation from ML Sync
+        self.conjg = gr.conjugate_cc();
+        self.mixer = gr.multiply_cc();
+
+        movingsum2_taps = [1.0 for i in range(cpsize)]
+        self.movingsum2 = gr.fir_filter_ccf(1,movingsum2_taps)
+        
+
+        # Correlator data handler
+        self.c2mag = gr.complex_to_mag()
+        self.angle = gr.complex_to_arg()
+        self.fg.connect(self.input,(self.mixer,1))
+        self.fg.connect(self.delay,self.conjg,(self.mixer,0))
+        self.fg.connect(self.mixer,self.movingsum2,self.c2mag)
+        self.fg.connect(self.movingsum2,self.angle)
+             
+        # ML Sync output arg, need to find maximum point of this
+        self.diff = gr.sub_ff()
+        self.fg.connect(self.c2mag,(self.diff,0))
+        self.fg.connect(self.moving_sum_filter,(self.diff,1))
+
+        #ML measurements input to sampler block and detect
+        self.sampler = gr.ofdm_sampler(fft_length,symbol_length,1)
+
+        self.f2c1 = gr.float_to_complex()
+        self.f2c2 = gr.float_to_complex()
+
+        # Connect inputs to OFDM sampler:
+        #   1: stream to get downconverted to baseband
+        #   2: output of difference block (theta)
+        #   3: frequency error estimate (epsilon)
+        self.fg.connect(self.input, (self.sampler,0))
+        self.fg.connect(self.diff, self.f2c1,(self.sampler,1))
+        self.fg.connect(self.angle, self.f2c2,(self.sampler,2))
+
+        self.fg.connect(self.diff, gr.file_sink(gr.sizeof_float, "theta.out"))
+
+        gr.hier_block.__init__(self, fg, self.input, self.sampler)

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/pick_bitrate.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/pick_bitrate.py
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/pick_bitrate.py
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,143 @@
+#
+# 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.
+# 
+
+_default_bitrate = 500e3
+
+_valid_samples_per_symbol = (2,3,4,5,6,7)
+
+def _gen_tx_info(converter_rate):
+    results = []
+    for samples_per_symbol in _valid_samples_per_symbol:
+        for interp in range(16, 512 + 1, 4):
+            bitrate = converter_rate / interp / samples_per_symbol
+            results.append((bitrate, samples_per_symbol, interp))
+    results.sort()
+    return results
+
+def _gen_rx_info(converter_rate):
+    results = []
+    for samples_per_symbol in _valid_samples_per_symbol:
+        for decim in range(8, 256 + 1, 2):
+            bitrate = converter_rate / decim / samples_per_symbol
+            results.append((bitrate, samples_per_symbol, decim))
+    results.sort()
+    return results
+    
+def _filter_info(info, samples_per_symbol, xrate):
+    if samples_per_symbol is not None:
+        info = [x for x in info if x[1] == samples_per_symbol]
+    if xrate is not None:
+        info = [x for x in info if x[2] == xrate]
+    return info
+
+def _pick_best(target_bitrate, bits_per_symbol, info):
+    """
+    @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate)
+    """
+    if len(info) == 0:
+        raise RuntimeError, "info is zero length!"
+
+    if target_bitrate is None:     # return the fastest one
+        return info[-1]
+    
+    # convert bit rate to symbol rate
+    target_symbolrate = target_bitrate / bits_per_symbol
+    
+    # Find the closest matching symbol rate.
+    # In the event of a tie, the one with the lowest samples_per_symbol wins.
+    # (We already sorted them, so the first one is the one we take)
+
+    best = info[0]
+    best_delta = abs(target_symbolrate - best[0])
+    for x in info[1:]:
+        delta = abs(target_symbolrate - x[0])
+        if delta < best_delta:
+            best_delta = delta
+            best = x
+
+    # convert symbol rate back to bit rate
+    return ((best[0] * bits_per_symbol),) + best[1:]
+
+def _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
+                  xrate, converter_rate, gen_info):
+    """
+    @returns tuple (bitrate, samples_per_symbol, interp_rate_or_decim_rate)
+    """
+    if not isinstance(bits_per_symbol, int) or bits_per_symbol < 1:
+        raise ValueError, "bits_per_symbol must be an int >= 1"
+    
+    if samples_per_symbol is not None and xrate is not None:  # completely 
determined
+        return (float(converter_rate) / xrate / samples_per_symbol,
+                samples_per_symbol, xrate)
+
+    if bitrate is None and samples_per_symbol is None and xrate is None:
+        bitrate = _default_bitrate
+
+    # now we have a target bitrate and possibly an xrate or
+    # samples_per_symbol constraint, but not both of them.
+
+    return _pick_best(bitrate, bits_per_symbol,
+                      _filter_info(gen_info(converter_rate), 
samples_per_symbol, xrate))
+    
+# 
---------------------------------------------------------------------------------------
+
+def pick_tx_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
+                    interp_rate, converter_rate=128e6):
+    """
+    Given the 4 input parameters, return at configuration that matches
+
+    @param bitrate: desired bitrate or None
+    @type bitrate: number or None
+    @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3
+    @type bits_per_symbol: integer >= 1
+    @param samples_per_symbol: samples/baud (aka samples/symbol)
+    @type samples_per_symbol: number or None
+    @param interp_rate: USRP interpolation factor
+    @type interp_rate: integer or None
+    @param converter_rate: converter sample rate in Hz
+    @type converter_rate: number
+
+    @returns tuple (bitrate, samples_per_symbol, interp_rate)
+    """
+    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
+                         interp_rate, converter_rate, _gen_tx_info)
+
+
+def pick_rx_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
+                    decim_rate, converter_rate=64e6):
+    """
+    Given the 4 input parameters, return at configuration that matches
+
+    @param bitrate: desired bitrate or None
+    @type bitrate: number or None
+    @param bits_per_symbol: E.g., BPSK -> 1, QPSK -> 2, 8-PSK -> 3
+    @type bits_per_symbol: integer >= 1
+    @param samples_per_symbol: samples/baud (aka samples/symbol)
+    @type samples_per_symbol: number or None
+    @param decim_rate: USRP decimation factor
+    @type decim_rate: integer or None
+    @param converter_rate: converter sample rate in Hz
+    @type converter_rate: number
+
+    @returns tuple (bitrate, samples_per_symbol, decim_rate)
+    """
+    return _pick_bitrate(bitrate, bits_per_symbol, samples_per_symbol,
+                         decim_rate, converter_rate, _gen_rx_info)

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path.py
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path.py
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,254 @@
+#!/usr/bin/env python
+#
+# 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 gnuradio import gr, gru, blks
+from gnuradio import usrp
+from gnuradio import eng_notation
+import copy
+import sys
+
+# from current dir
+from pick_bitrate import pick_rx_bitrate
+import ofdm
+
+# /////////////////////////////////////////////////////////////////////////////
+#                              receive path
+# /////////////////////////////////////////////////////////////////////////////
+
+class receive_path(gr.hier_block):
+    def __init__(self, fg, demod_class, rx_callback, options):
+
+        options = copy.copy(options)    # make a copy so we can destructively 
modify
+
+        self._verbose            = options.verbose
+        self._rx_freq            = options.rx_freq         # receiver's center 
frequency
+        self._rx_gain            = options.rx_gain         # receiver's gain
+        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to 
use
+        self._bitrate            = options.bitrate         # desired bit rate
+        self._decim              = options.decim           # Decimating rate 
for the USRP (prelim)
+        self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/symbol
+        self._fft_length         = options.fft_length      # number of bins in 
the FFT
+        self._occupied_tones     = options.occupied_tones  # number of used 
carriers
+        self._cp_length          = options.cp_length       # length of the 
cyclic prefix
+        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
+        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
+
+        self._rx_callback   = rx_callback      # this callback is fired when 
there's a packet available
+
+        if self._rx_freq is None:
+            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be 
specified\n")
+            raise SystemExit
+
+        # Set up USRP source; also adjusts decim, samples_per_symbol, and 
bitrate
+        self._setup_usrp_source()
+
+        ok = self.set_freq(self._rx_freq)
+        if not ok:
+            print "Failed to set Rx frequency to %s" % 
(eng_notation.num_to_str(self._rx_freq))
+            raise ValueError, eng_notation.num_to_str(self._rx_freq)
+    
+        g = self.subdev.gain_range()
+        if options.show_rx_gain_range:
+            print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \
+                  % (g[0], g[1], g[2])
+
+        self.set_gain(options.rx_gain)
+
+        self.set_auto_tr(True)                 # enable Auto Transmit/Receive 
switching
+
+        # copy the final answers back into options for use by demodulator
+        options.samples_per_symbol = self._samples_per_symbol
+        options.bitrate = self._bitrate
+        options.decim = self._decim
+
+        # Design filter to get actual channel we want
+        sw_decim = 1
+        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
+                                          sw_decim * self._samples_per_symbol, 
# sampling rate
+                                          1.0,                  # midpoint of 
trans. band
+                                          0.1,                  # width of 
trans. band
+                                          gr.firdes.WIN_HANN)   # filter type 
+
+        # Decimating channel filter
+        # complex in and out, float taps
+        self.chan_filt = gr.fft_filter_ccc(sw_decim, chan_coeffs)
+        #self.chan_filt = gr.fir_filter_ccf(sw_decim, chan_coeffs)
+
+        self.ofdm_demod = ofdm.ofdm_demod(fg, occupied_tones, fftsize, 
symbol_length, rho)
+        
+        # receiver
+        self.packet_receiver = \
+            blks.demod_pkts(fg,
+                            self.ofdm_demod,
+                            access_code=None,
+                            callback=self._rx_callback,
+                            threshold=-1)
+
+        # Carrier Sensing Blocks
+        alpha = 0.001
+        thresh = 30   # in dB, will have to adjust
+        self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha)
+        fg.connect(self.chan_filt, self.probe)
+
+        # Display some information about the setup
+        if self._verbose:
+            self._print_verbage()
+            
+        fg.connect(self.u, self.chan_filt, self.packet_receiver)
+        gr.hier_block.__init__(self, fg, None, None)
+
+    def _setup_usrp_source(self):
+        self.u = usrp.source_c (fusb_block_size=self._fusb_block_size,
+                                fusb_nblocks=self._fusb_nblocks)
+        adc_rate = self.u.adc_rate()
+
+        # derive values of bitrate, samples_per_symbol, and decim from desired 
info
+        (self._bitrate, self._samples_per_symbol, self._decim) = \
+            pick_rx_bitrate(self._bitrate, 
self._demod_class.bits_per_symbol(), \
+                            self._samples_per_symbol, self._decim, adc_rate)
+
+        self.u.set_decim_rate(self._decim)
+
+        # determine the daughterboard subdevice we're using
+        if self._rx_subdev_spec is None:
+            self._rx_subdev_spec = usrp.pick_rx_subdevice(self.u)
+        self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec)
+
+        self.u.set_mux(usrp.determine_rx_mux_value(self.u, 
self._rx_subdev_spec))
+
+    def set_freq(self, target_freq):
+        """
+        Set the center frequency we're interested in.
+
+        @param target_freq: frequency in Hz
+        @rypte: bool
+
+        Tuning is a two step process.  First we ask the front-end to
+        tune as close to the desired frequency as it can.  Then we use
+        the result of that operation and our target_frequency to
+        determine the value for the digital up converter.
+        """
+        r = self.u.tune(0, self.subdev, target_freq)
+        if r:
+            return True
+
+        return False
+
+    def set_gain(self, gain):
+        """
+        Sets the analog gain in the USRP
+        """
+        if gain is None:
+            r = self.subdev.gain_range()
+            gain = (r[0] + r[1])/2               # set gain to midpoint
+        self.gain = gain
+        return self.subdev.set_gain(gain)
+
+    def set_auto_tr(self, enable):
+        return self.subdev.set_auto_tr(enable)
+        
+    def bitrate(self):
+        return self._bitrate
+
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
+
+    def decim(self):
+        return self._decim
+
+    def carrier_sensed(self):
+        """
+        Return True if we think carrier is present.
+        """
+        #return self.probe.level() > X
+        return self.probe.unmuted()
+
+    def carrier_threshold(self):
+        """
+        Return current setting in dB.
+        """
+        return self.probe.threshold()
+
+    def set_carrier_threshold(self, threshold_in_db):
+        """
+        Set carrier threshold.
+
+        @param threshold_in_db: set detection threshold
+        @type threshold_in_db:  float (dB)
+        """
+        self.probe.set_threshold(threshold_in_db)
+    
+        
+    def add_options(normal, expert):
+        """
+        Adds receiver-specific options to the Options Parser
+        """
+        add_freq_option(normal)
+        if not normal.has_option("--bitrate"):
+            normal.add_option("-r", "--bitrate", type="eng_float", 
default=None,
+                              help="specify bitrate.  samples-per-symbol and 
interp/decim will be derived.")
+        normal.add_option("-R", "--rx-subdev-spec", type="subdev", 
default=None,
+                          help="select USRP Rx side A or B")
+        normal.add_option("", "--rx-gain", type="eng_float", default=None, 
metavar="GAIN",
+                          help="set receiver gain in dB [default=midpoint].  
See also --show-rx-gain-range")
+        normal.add_option("", "--show-rx-gain-range", action="store_true", 
default=False, 
+                          help="print min and max Rx gain available on 
selected daughterboard")
+        normal.add_option("-v", "--verbose", action="store_true", 
default=False)
+        expert.add_option("-S", "--samples-per-symbol", type="int", 
default=None,
+                          help="set samples/symbol [default=%default]")
+        expert.add_option("", "--rx-freq", type="eng_float", default=None,
+                          help="set Rx frequency to FREQ [default=%default]", 
metavar="FREQ")
+        expert.add_option("-d", "--decim", type="intx", default=None,
+                          help="set fpga decimation rate to DECIM 
[default=%default]")
+        expert.add_option("", "--log", action="store_true", default=False,
+                          help="Log all parts of flow graph to files (CAUTION: 
lots of data)")
+
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+
+    def _print_verbage(self):
+        """
+        Prints information about the receive path
+        """
+        print "Using RX d'board %s"    % (self.subdev.side_and_name(),)
+        print "Rx gain:         %g"    % (self.gain,)
+        print "modulation:      %s"    % (self._demod_class.__name__)
+        print "bitrate:         %sb/s" % 
(eng_notation.num_to_str(self._bitrate))
+        print "samples/symbol:  %3d"   % (self._samples_per_symbol)
+        print "decim:           %3d"   % (self._decim)
+        print "Rx Frequency:    %s"    % 
(eng_notation.num_to_str(self._rx_freq))
+        # print "Rx Frequency:    %f"    % (self._rx_freq)
+
+def add_freq_option(parser):
+    """
+    Hackery that has the -f / --freq option set both tx_freq and rx_freq
+    """
+    def freq_callback(option, opt_str, value, parser):
+        parser.values.rx_freq = value
+        parser.values.tx_freq = value
+
+    if not parser.has_option('--freq'):
+        parser.add_option('-f', '--freq', type="eng_float",
+                          action="callback", callback=freq_callback,
+                          help="set Tx and/or Rx frequency to FREQ 
[default=%default]",
+                          metavar="FREQ")

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path_simple.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path_simple.py
                                (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/receive_path_simple.py
        2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# 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 gnuradio import gr, gru, blks
+from gnuradio import usrp
+from gnuradio import eng_notation
+import copy
+import sys
+
+import ofdm
+
+# /////////////////////////////////////////////////////////////////////////////
+#                              receive path
+# /////////////////////////////////////////////////////////////////////////////
+
+class receive_path(gr.hier_block):
+    def __init__(self, fg, rx_callback, options):
+
+        options = copy.copy(options)    # make a copy so we can destructively 
modify
+
+        self._verbose            = options.verbose
+        self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/symbol
+
+        self._rx_callback   = rx_callback      # this callback is fired when 
there's a packet available
+         
+        # Design filter to get actual channel we want
+        sw_decim = 1
+        bw = float(options.occupied_tones+25) / float(options.fft_length)
+        print options.occupied_tones
+        print options.fft_length
+        print bw
+        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
+                                          2.0,                  # sampling rate
+                                          bw,                   # midpoint of 
trans. band
+                                          1*bw,               # width of 
trans. band
+                                          gr.firdes.WIN_KAISER)   # filter 
type 
+
+        # Decimating channel filter
+        self.chan_filt = gr.fft_filter_ccc(sw_decim, chan_coeffs)
+        
+        self.ofdm_demod = ofdm.ofdm_demod(fg, options)
+
+        # receiver
+        self.packet_receiver = \
+            blks.demod_ofdm_pkts(fg,
+                                 self.ofdm_demod,
+                                 access_code=None,
+                                 callback=self._rx_callback,
+                                 threshold=-1)
+
+        if 0:
+            fg.connect(self.chan_filt, self.packet_receiver)
+            gr.hier_block.__init__(self, fg, self.chan_filt, None)
+        else:
+            gr.hier_block.__init__(self, fg, self.packet_receiver, None)
+            
+    def add_options(normal, expert):
+        """
+        Adds receiver-specific options to the Options Parser
+        """
+        normal.add_option("-v", "--verbose", action="store_true", 
default=False)
+        expert.add_option("", "--log", action="store_true", default=False,
+                          help="Log all parts of flow graph to files (CAUTION: 
lots of data)")
+        expert.add_option("-S", "--samples-per-symbol", type="int", default=2,
+                          help="set samples/symbol [default=%default]")
+
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the receive path
+        """
+        pass

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path.py
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path.py
      2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,243 @@
+#
+# 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 gnuradio import gr, gru, blks
+from gnuradio import usrp
+from gnuradio import eng_notation
+
+import copy
+import sys
+
+# from current dir
+from pick_bitrate import pick_tx_bitrate
+import ofdm
+
+# /////////////////////////////////////////////////////////////////////////////
+#                              transmit path
+# /////////////////////////////////////////////////////////////////////////////
+
+class transmit_path(gr.hier_block): 
+    def __init__(self, fg, modulator_class, options):
+        '''
+        See below for what options should hold
+        '''
+
+        options = copy.copy(options)    # make a copy so we can destructively 
modify
+
+        self._verbose            = options.verbose
+        self._tx_freq            = options.tx_freq         # tranmitter's 
center frequency
+        self._tx_amplitude       = options.tx_amplitude    # digital amplitude 
sent to USRP
+        self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to 
use
+        self._bitrate            = options.bitrate         # desired bit rate
+        self._interp             = options.interp          # interpolating 
rate for the USRP (prelim)
+        self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/baud
+        self._fft_length         = options.fft_length      # number of bins in 
the FFT
+        self._occupied_tones     = options.occupied_tones  # number of used 
carriers
+        self._cp_length          = options.cp_length       # length of the 
cyclic prefix
+        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
+        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
+    
+        if self._tx_freq is None:
+            sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be 
specified\n")
+            raise SystemExit
+
+        if self._fft_length < self.occupied_tones:
+            sys.stderr.write("occupied tones must be less than FFT length\n")
+            raise SystemExit
+        if self._fft_length < self._cp_length:
+            sys.stderr.write("cyclic prefix length  must be less than FFT 
length\n")
+            raise SystemExit
+
+        # Set up USRP sink; also adjusts interp, samples_per_symbol, and 
bitrate
+        self._setup_usrp_sink()
+
+        # copy the final answers back into options for use by modulator
+        options.samples_per_symbol = self._samples_per_symbol
+        options.bitrate = self._bitrate
+        options.interp = self._interp
+
+        # Set center frequency of USRP
+        ok = self.set_freq(self._tx_freq)
+        if not ok:
+            print "Failed to set Tx frequency to %s" % 
(eng_notation.num_to_str(self._tx_freq),)
+            raise ValueError
+
+        # Set the USRP for maximum transmit gain
+        # (Note that on the RFX cards this is a nop.)
+        self.set_gain(self.subdev.gain_range()[0])
+
+        # enable Auto Transmit/Receive switching
+        self.set_auto_tr(True)
+
+
+        symbol_length = self._fft_length + self._cp_length
+        self.ofdm_mod = ofdm.ofdm_mod(fg, self._occupied_tones, 
self.fft_length, symbol_length)
+        # transmitter
+        self.packet_transmitter = \
+            blks.mod_pkts(fg,
+                          self.ofdm_mod,
+                          access_code=None,
+                          msgq_limit=4,
+                          pad_for_usrp=True)
+
+        self.amp = gr.multiply_const_cc(1)
+        self.set_tx_amplitude(self._tx_amplitude)
+
+        # Display some information about the setup
+        if self._verbose:
+            self._print_verbage()
+
+        # Create and setup transmit path flow graph
+        fg.connect(self.packet_transmitter, self.amp, self.u)
+        gr.hier_block.__init__(self, fg, None, None)
+
+    def _setup_usrp_sink(self):
+        """
+        Creates a USRP sink, determines the settings for best bitrate,
+        and attaches to the transmitter's subdevice.
+        """
+        self.u = usrp.sink_c(fusb_block_size=self._fusb_block_size,
+                             fusb_nblocks=self._fusb_nblocks)
+        dac_rate = self.u.dac_rate();
+
+        # derive values of bitrate, samples_per_symbol, and interp from 
desired info
+        (self._bitrate, self._samples_per_symbol, self._interp) = \
+            pick_tx_bitrate(self._bitrate, 
self._modulator_class.bits_per_symbol(),
+                            self._samples_per_symbol, self._interp, dac_rate)
+        
+        self.u.set_interp_rate(self._interp)
+
+        # determine the daughterboard subdevice we're using
+        if self._tx_subdev_spec is None:
+            self._tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
+        self.u.set_mux(usrp.determine_tx_mux_value(self.u, 
self._tx_subdev_spec))
+        self.subdev = usrp.selected_subdev(self.u, self._tx_subdev_spec)
+
+
+    def set_freq(self, target_freq):
+        """
+        Set the center frequency we're interested in.
+
+        @param target_freq: frequency in Hz
+        @rypte: bool
+
+        Tuning is a two step process.  First we ask the front-end to
+        tune as close to the desired frequency as it can.  Then we use
+        the result of that operation and our target_frequency to
+        determine the value for the digital up converter.
+        """
+        r = self.u.tune(self.subdev._which, self.subdev, target_freq)
+        if r:
+            return True
+
+        return False
+        
+    def set_gain(self, gain):
+        """
+        Sets the analog gain in the USRP
+        """
+        self.gain = gain
+        self.subdev.set_gain(gain)
+
+    def set_tx_amplitude(self, ampl):
+        """
+        Sets the transmit amplitude sent to the USRP
+        @param: ampl 0 <= ampl < 32768.  Try 8000
+        """
+        self._tx_amplitude = max(0.0, min(ampl, 32767.0))
+        self.amp.set_k(self._tx_amplitude)
+        
+    def set_auto_tr(self, enable):
+        """
+        Turns on auto transmit/receive of USRP daughterboard (if exits; else 
ignored)
+        """
+        return self.subdev.set_auto_tr(enable)
+        
+    def send_pkt(self, payload='', eof=False):
+        """
+        Calls the transmitter method to send a packet
+        """
+        return self.packet_transmitter.send_pkt(payload, eof)
+        
+    def bitrate(self):
+        return self._bitrate
+
+    def samples_per_symbol(self):
+        return self._samples_per_symbol
+
+    def interp(self):
+        return self._interp
+
+    def add_options(normal, expert):
+        """
+        Adds transmitter-specific options to the Options Parser
+        """
+        add_freq_option(normal)
+        if not normal.has_option('--bitrate'):
+            normal.add_option("-r", "--bitrate", type="eng_float", 
default=None,
+                              help="specify bitrate.  samples-per-symbol and 
interp/decim will be derived.")
+        normal.add_option("-T", "--tx-subdev-spec", type="subdev", 
default=None,
+                          help="select USRP Tx side A or B")
+        normal.add_option("", "--tx-amplitude", type="eng_float", 
default=12000, metavar="AMPL",
+                          help="set transmitter digital amplitude: 0 <= AMPL < 
32768 [default=%default]")
+        normal.add_option("-v", "--verbose", action="store_true", 
default=False)
+
+        expert.add_option("-S", "--samples-per-symbol", type="int", 
default=None,
+                          help="set samples/symbol [default=%default]")
+        expert.add_option("", "--tx-freq", type="eng_float", default=None,
+                          help="set transmit frequency to FREQ 
[default=%default]", metavar="FREQ")
+        expert.add_option("-i", "--interp", type="intx", default=None,
+                          help="set fpga interpolation rate to INTERP 
[default=%default]")
+        expert.add_option("", "--log", action="store_true", default=False,
+                          help="Log all parts of flow graph to file (CAUTION: 
lots of data)")
+
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the transmit path
+        """
+        print "Using TX d'board %s"    % (self.subdev.side_and_name(),)
+        print "Tx amplitude     %s"    % (self._tx_amplitude)
+        print "modulation:      %s"    % (self._modulator_class.__name__)
+        print "bitrate:         %sb/s" % 
(eng_notation.num_to_str(self._bitrate))
+        print "samples/symbol:  %3d"   % (self._samples_per_symbol)
+        print "interp:          %3d"   % (self._interp)
+        print "FFT length:      %3d"   % (self._fft_length)
+        print "Occupied Tones:  %3d"   % (self._occupied_tones)
+        print "CP length:       %3d"   % (self._cp_length)
+        print "Tx Frequency:    %s"    % 
(eng_notation.num_to_str(self._tx_freq))
+        
+
+def add_freq_option(parser):
+    """
+    Hackery that has the -f / --freq option set both tx_freq and rx_freq
+    """
+    def freq_callback(option, opt_str, value, parser):
+        parser.values.rx_freq = value
+        parser.values.tx_freq = value
+
+    if not parser.has_option('--freq'):
+        parser.add_option('-f', '--freq', type="eng_float",
+                          action="callback", callback=freq_callback,
+                          help="set Tx and/or Rx frequency to FREQ 
[default=%default]",
+                          metavar="FREQ")

Added: 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path_simple.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path_simple.py
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm2/gnuradio-examples/python/ofdm/transmit_path_simple.py
       2007-01-28 17:41:58 UTC (rev 4306)
@@ -0,0 +1,79 @@
+#
+# 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 gnuradio import gr, gru, blks
+from gnuradio import usrp
+from gnuradio import eng_notation
+
+import copy
+import sys
+
+import ofdm
+
+# /////////////////////////////////////////////////////////////////////////////
+#                              transmit path
+# /////////////////////////////////////////////////////////////////////////////
+
+class transmit_path(gr.hier_block): 
+    def __init__(self, fg, options):
+        '''
+        See below for what options should hold
+        '''
+        options = copy.copy(options)    # make a copy so we can destructively 
modify
+
+        self._verbose            = options.verbose
+        self._samples_per_symbol = options.samples_per_symbol  # desired 
samples/baud
+        
+        self.ofdm_mod = ofdm.ofdm_mod(fg, options)
+        self.packet_transmitter = \
+            blks.mod_ofdm_pkts(fg,
+                               self.ofdm_mod,
+                               access_code=None,
+                               msgq_limit=4,
+                               pad_for_usrp=False)
+
+        gr.hier_block.__init__(self, fg, None, self.packet_transmitter)
+
+    def send_pkt(self, payload='', eof=False):
+        """
+        Calls the transmitter method to send a packet
+        """
+        return self.packet_transmitter.send_pkt(payload, eof)
+        
+    def add_options(normal, expert):
+        """
+        Adds transmitter-specific options to the Options Parser
+        """
+        normal.add_option("-v", "--verbose", action="store_true", 
default=False)
+
+        expert.add_option("-S", "--samples-per-symbol", type="int", default=2,
+                          help="set samples/symbol [default=%default]")
+        expert.add_option("", "--log", action="store_true", default=False,
+                          help="Log all parts of flow graph to file (CAUTION: 
lots of data)")
+
+    # Make a static method to call before instantiation
+    add_options = staticmethod(add_options)
+
+    def _print_verbage(self):
+        """
+        Prints information about the transmit path
+        """
+        pass





reply via email to

[Prev in Thread] Current Thread [Next in Thread]