commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7839 - gnuradio/branches/developers/trondeau/ofdmtimi


From: trondeau
Subject: [Commit-gnuradio] r7839 - gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general
Date: Tue, 26 Feb 2008 11:52:45 -0700 (MST)

Author: trondeau
Date: 2008-02-26 11:52:45 -0700 (Tue, 26 Feb 2008)
New Revision: 7839

Modified:
   
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
   
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
Log:
Adding state for moving symbols to the rest of the OFDM system. This removes 
the need for the regenerator block in the sync. The frame acq. block needs to 
take this in and better process the frame information. There is a lot of 
optimization that can be done here.

Modified: 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
   2008-02-26 18:51:18 UTC (rev 7838)
+++ 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
   2008-02-26 18:52:45 UTC (rev 7839)
@@ -39,8 +39,8 @@
                                  unsigned int symbol_length)
   : gr_block ("ofdm_sampler",
              gr_make_io_signature2 (2, 2, sizeof (gr_complex), sizeof(char)),
-             gr_make_io_signature (1, 1, sizeof (gr_complex)*fft_length)),
-    d_fft_length(fft_length), d_symbol_length(symbol_length)
+             gr_make_io_signature2 (2, 2, sizeof (gr_complex)*fft_length, 
sizeof(char)*fft_length)),
+    d_state(STATE_NO_SIG), d_fft_length(fft_length), 
d_symbol_length(symbol_length)
 {
 }
 
@@ -48,7 +48,8 @@
 gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int 
&ninput_items_required)
 {
   // FIXME do we need more
-  int nreqd  = (noutput_items-1) * d_symbol_length + d_fft_length;
+  //int nreqd  = (noutput_items-1) * d_symbol_length + d_fft_length;
+  int nreqd  = d_symbol_length + d_fft_length;
   unsigned ninputs = ninput_items_required.size ();
   for (unsigned i = 0; i < ninputs; i++)
     ninput_items_required[i] = nreqd;
@@ -64,34 +65,59 @@
   char *trigger = (char *) input_items[1];
 
   gr_complex *optr = (gr_complex *) output_items[0];
+  char *outsig = (char *) output_items[1];
 
-  int found=0, index=0;
+  //FIXME: we only process a single OFDM symbol at a time; after the preamble, 
we can 
+  // process a few at a time as long as we always look out for the next 
preamble.
 
-  int i=d_fft_length-1;
+  unsigned int index=d_fft_length;  // start one fft length into the input so 
we can always look back this far
 
-  // FIXME: This is where we miss if the regeneration happens too soon.
-  while(!found && i<std::min(ninput_items[0],ninput_items[1]) ) {
-    if(trigger[i]) {
-      found = 1;
-      index = i++;
+  outsig[0] = 0; // set output to no signal by default
+
+  // Search for a preamble trigger signal during the next symbol length
+  while((d_state != STATE_PREAMBLE) && (index <= 
(d_symbol_length+d_fft_length))) {
+    if(trigger[index]) {
+      outsig[0] = 1; // tell the next block there is a preamble coming
+      d_state = STATE_PREAMBLE;
     }
     else
-      i++;
+      index++;
   }
   
-  if(found) {
-    assert(index-d_fft_length+1 >= 0);
-    for(int j=index - d_fft_length + 1; j <= index; j++)
-      *optr++ = iptr[j];
-    consume_each(index - d_fft_length + 2);
-    //printf("OFDM Sampler found:  ninput_items: %d/%d   noutput_items: %d  
consumed: %d   found: %d\n", 
-    //   ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+2), 
found);
-  }
-  else {
-    consume_each(i-d_fft_length+1);
-    //printf("OFDM Sampler not found:  ninput_items: %d/%d   noutput_items: %d 
 consumed: %d   found: %d\n", 
-    //  ninput_items[0], ninput_items[1], noutput_items, (i-d_fft_length+1), 
found);
+  unsigned int i, pos, ret;
+  switch(d_state) {
+  case(STATE_PREAMBLE):
+    // When we found a preamble trigger, get it and set the symbol boundary 
here
+    for(i = (index - d_fft_length + 1); i <= index; i++) {
+      *optr++ = iptr[i];
+    }
+
+    d_state = STATE_FRAME;
+    consume_each(index - d_fft_length + 2); // consume up to one fft_length 
away to keep the history
+    ret = 1;
+    break;
+    
+  case(STATE_FRAME):
+    // use this state when we have processed a preamble and are getting the 
rest of the frames
+    //FIXME: add a timeout clause here to enter state STATE_NO_SIG after so 
many times here
+    //FIXME: we could also have a power squelch system here to enter 
STATE_NO_SIG if no power is received
+
+    // skip over fft length history and cyclic prefix
+    pos = d_symbol_length;  // keeps track of where we are in the input buffer
+    for(i=0; i < d_fft_length; i++) {
+      *optr++ = iptr[pos++];
+    }
+
+    consume_each(d_symbol_length); // jump up by 1 fft length and the cyclic 
prefix length
+    ret = 1;
+    break;
+
+  case(STATE_NO_SIG):
+  default: 
+    consume_each(index-d_fft_length); // consume everything we've gone through 
so far leaving the fft length history
+    ret = 0;
+    break;
  }
 
-  return found;
+  return ret;
 }

Modified: 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
    2008-02-26 18:51:18 UTC (rev 7838)
+++ 
gnuradio/branches/developers/trondeau/ofdmtiming/gnuradio-core/src/lib/general/gr_ofdm_sampler.h
    2008-02-26 18:52:45 UTC (rev 7839)
@@ -45,6 +45,9 @@
                   unsigned int symbol_length);
 
  private:
+  enum state_t {STATE_NO_SIG, STATE_PREAMBLE, STATE_FRAME};
+
+  state_t d_state;
   unsigned int d_fft_length;
   unsigned int d_symbol_length;
 





reply via email to

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