commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r4107 - gnuradio/branches/developers/n4hy/ofdm/gnuradi


From: trondeau
Subject: [Commit-gnuradio] r4107 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general
Date: Sat, 16 Dec 2006 17:03:13 -0700 (MST)

Author: trondeau
Date: 2006-12-16 17:03:12 -0700 (Sat, 16 Dec 2006)
New Revision: 4107

Added:
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
Modified:
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
Log:
adding a clock sync and sampler for OFDM demod - needs testing

Modified: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
    2006-12-16 23:53:13 UTC (rev 4106)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
    2006-12-17 00:03:12 UTC (rev 4107)
@@ -165,6 +165,7 @@
        gr_ofdm_cyclic_prefixer.cc      \
        gr_ofdm_mapper_bcv.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        \
@@ -296,6 +297,7 @@
        gr_ofdm_cyclic_prefixer.h       \
        gr_ofdm_mapper_bcv.h            \
        gr_ofdm_bpsk_mapper.h           \
+       gr_ofdm_sampler.h               \
        gr_pa_2x2_phase_combiner.h      \
        gr_packet_sink.h                \
        gr_phase_modulator_fc.h         \
@@ -429,6 +431,7 @@
        gr_ofdm_cyclic_prefixer.i       \
        gr_ofdm_mapper_bcv.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         \

Modified: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i  
    2006-12-16 23:53:13 UTC (rev 4106)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i  
    2006-12-17 00:03:12 UTC (rev 4107)
@@ -93,6 +93,7 @@
 #include <gr_probe_signal_f.h>
 #include <gr_ofdm_cyclic_prefixer.h>
 #include <gr_ofdm_bpsk_mapper.h>
+#include <gr_ofdm_sampler.h>
 #include <gr_costas_loop_cc.h>
 #include <gr_pa_2x2_phase_combiner.h>
 #include <gr_kludge_copy.h>
@@ -161,7 +162,8 @@
 %include "gr_agc_ff.i"
 %include "gr_agc_cc.i"
 %include "gr_agc2_ff.i"
-%include "gr_agc2_cc.i"%include "gr_rms_cf.i"
+%include "gr_agc2_cc.i"
+%include "gr_rms_cf.i"
 %include "gr_rms_ff.i"
 %include "gr_nlog10_ff.i"
 %include "gr_fake_channel_coder_pp.i"
@@ -188,6 +190,7 @@
 %include "gr_probe_signal_f.i"
 %include "gr_ofdm_cyclic_prefixer.i"
 %include "gr_ofdm_bpsk_mapper.i"
+%include "gr_ofdm_sampler.i"
 %include "gr_costas_loop_cc.i"
 %include "gr_pa_2x2_phase_combiner.i"
 %include "gr_kludge_copy.i"

Added: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
                             (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
     2006-12-17 00:03:12 UTC (rev 4107)
@@ -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, 
+                     unsigned 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, 
+                                 unsigned 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)
+{
+  int nreqd = 0;
+
+  if(d_delay >= 0) {
+    nreqd = d_symbol_length * noutput_items + d_delay;
+  }
+  else if((unsigned)abs(d_delay) > d_symbol_length) {
+    nreqd = d_symbol_length * noutput_items + (abs(d_delay) - noutput_items);
+  }
+  else {
+    nreqd = d_symbol_length * noutput_items;
+  }
+
+  unsigned ninputs = ninput_items_required.size ();
+  for (unsigned i = 0; i < ninputs; i++)
+    ninput_items_required[i] = nreqd+1;
+}
+
+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];
+
+  bool found = false;
+  unsigned int peak_index=0;
+  unsigned int nproduced=0;
+  unsigned int i = 0;
+
+  while(i < -(std::min((unsigned)1, d_delay))) {
+    increment_loop((*theta++).real());
+    i++;
+  }
+       
+  unsigned int lastindex = ninput_items[0] - std::max((unsigned)0, d_delay - 
d_symbol_length);
+
+  while(i < lastindex) {
+    found = false;
+
+    // detect the peak of theta
+    if(theta[i].real() > d_avg*0.25) {
+      while((i < lastindex) && (!found)) {
+       if(theta[i].real() < theta[i-1].real()) {
+         peak_index = i-1;
+         d_freq = epsilon[peak_index].real();
+         found = true;
+
+         //memcpy(&optr[nproduced*d_fft_size], &iptr[peak_index], 
d_fft_size*sizeof(gr_complex));
+         nproduced++;
+         while(i < peak_index + d_symbol_length-1) {
+           gr_complex nco_out = gr_expj(-d_phase);
+           *optr++ = nco_out * iptr[i];
+           
+           increment_loop((*theta++).real());
+           i++;
+         }
+       }
+       else {
+         increment_loop((*theta++).real());
+         i++;
+       }
+      }
+    }
+    else {
+      increment_loop((*theta++).real());
+      i++;
+    }
+  }
+  
+  consume_each(i);
+  return nproduced;
+}
+
+void gr_ofdm_sampler::increment_loop(float theta)
+{
+  float alpha = 0.001;
+  d_phase += d_freq * (1.0/(2.0*M_PI));
+  d_avg = (alpha)*theta + (1-alpha)*d_avg;
+}

Added: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
      2006-12-17 00:03:12 UTC (rev 4107)
@@ -0,0 +1,68 @@
+/* -*- 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,
+                                          unsigned 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, 
+                                                   unsigned int delay);
+
+  gr_ofdm_sampler (unsigned int fft_length, 
+                  unsigned int symbol_length, 
+                  unsigned int delay);
+
+ private:
+  unsigned int d_fft_length;
+  unsigned int d_symbol_length;
+  unsigned int d_delay;
+  float d_phase;
+  float d_freq;
+  float d_avg;
+
+  void increment_loop(float theta);
+
+ public:
+  void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+  int general_work (int noutput_items,
+                   gr_vector_int &ninput_items,
+                   gr_vector_const_void_star &input_items,
+                   gr_vector_void_star &output_items);
+};
+
+#endif

Added: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.i
      2006-12-17 00:03:12 UTC (rev 4107)
@@ -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, unsigned int delay);
+
+class gr_ofdm_sampler : public gr_sync_block
+{
+ private:
+  gr_ofdm_sampler (unsigned int fft_length, unsigned int symbol_length, 
unsigned int delay);
+};





reply via email to

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