commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7980 - gnuradio/branches/developers/trondeau/ofdm/gnu


From: trondeau
Subject: [Commit-gnuradio] r7980 - gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general
Date: Sat, 8 Mar 2008 17:38:35 -0700 (MST)

Author: trondeau
Date: 2008-03-08 17:38:34 -0700 (Sat, 08 Mar 2008)
New Revision: 7980

Modified:
   
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
   
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
   
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
   
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
Log:
Added subcarrier map used to specify which subcarriers are used to carry data. 
It's represented by a hex string, 1 bit per carrier either on or off. This is 
currently hard-coded to null out the carriers around DC but designed in such a 
way to make the subcarrier choices more flexible for later. I also currently 
also still use the occupied_carriers value that specifies which side 
subcarriers are used as guardbands, so the subcarrier map must fit this 
restriction, which is one reason why I have hard-coded the map. Basically, this 
is designed to fix the DC carrier issue while providing a path to more 
flexibility later. Needs to be verified over the air.

Modified: 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
      2008-03-08 23:28:26 UTC (rev 7979)
+++ 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc
      2008-03-09 00:38:34 UTC (rev 7980)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -110,16 +110,19 @@
   carrier=gr_expj(d_phase);
 
   gr_complex accum_error = 0.0;
-  while(i < d_occupied_carriers) {
+  //while(i < d_occupied_carriers) {
+  while(i < d_subcarrier_map.size()) {
     if(d_nresid > 0) {
       d_partial_byte |= d_resid;
       d_byte_offset += d_nresid;
       d_nresid = 0;
       d_resid = 0;
     }
-
-    while((d_byte_offset < 8) && (i < d_occupied_carriers)) {
-      gr_complex sigrot = in[i]*carrier*d_dfe[i];
+    
+    //while((d_byte_offset < 8) && (i < d_occupied_carriers)) {
+    while((d_byte_offset < 8) && (i < d_subcarrier_map.size())) {
+      //gr_complex sigrot = in[i]*carrier*d_dfe[i];
+      gr_complex sigrot = in[d_subcarrier_map[i]]*carrier*d_dfe[i];
       
       if(d_derotated_output != NULL){
        d_derotated_output[i] = sigrot;
@@ -198,6 +201,25 @@
     d_resid(0), 
d_nresid(0),d_phase(0),d_freq(0),d_phase_gain(phase_gain),d_freq_gain(freq_gain),
     d_eq_gain(0.05)
 {
+  std::string carriers;
+  carriers  = "ffffffffffffffffffffffffC3ffffffffffffffffffffffff";
+
+  int i,j,k;
+  for(i = 0; i < (int)(d_occupied_carriers/4); i++) {
+    char c = carriers[i];
+    for(j = 0; j < 4; j++) {
+      k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1;
+      if(k) {
+       d_subcarrier_map.push_back(4*i + j);
+      }
+    }
+  }
+  
+  // make sure we stay in the limit currently imposed by the occupied_carriers
+  if(d_subcarrier_map.size() > d_occupied_carriers) {
+    throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated 
exceeds size of occupied carriers");
+  }
+
   d_bytes_out = new unsigned char[d_occupied_carriers];
   d_dfe.resize(occupied_carriers);
   fill(d_dfe.begin(), d_dfe.end(), gr_complex(1.0,0.0));

Modified: 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
       2008-03-08 23:28:26 UTC (rev 7979)
+++ 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.h
       2008-03-09 00:38:34 UTC (rev 7980)
@@ -88,6 +88,8 @@
   float d_freq_gain;
   float d_eq_gain;
 
+  std::vector<int> d_subcarrier_map;
+
  protected:
   gr_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, 
                     const std::vector<unsigned char> &sym_value_out,

Modified: 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
      2008-03-08 23:28:26 UTC (rev 7979)
+++ 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc
      2008-03-09 00:38:34 UTC (rev 7980)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2006,2007 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -54,6 +54,32 @@
 {
   if (!(d_occupied_carriers <= d_fft_length))
     throw std::invalid_argument("gr_ofdm_mapper_bcv: occupied carriers must be 
<= fft_length");
+
+  // this is not the final form of this solution since we still use the 
occupied_tones concept,
+  // which would get us into trouble if the number of carriers we seek is 
greater than the occupied carriers.
+  // Eventually, we will get rid of the occupied_carriers concept.
+  std::string carriers = "ffffffffffffffffffffffffC3ffffffffffffffffffffffff";
+
+  // find out how many zeros to pad on the sides; the difference between the 
fft length and the subcarrier
+  // mapping size in chunks of four. This is the number to pack on the left 
and this number plus any 
+  // residual nulls (if odd) will be packed on the right. 
+  int diff = (d_fft_length/4 - carriers.length())/2; 
+
+  int i,j,k;
+  for(i = 0; i < carriers.length(); i++) {
+    char c = carriers[i];                            // get the current hex 
character from the string
+    for(j = 0; j < 4; j++) {                        // walk through all four 
bits
+      k = (strtol(&c, NULL, 16) >> (3-j)) & 0x1;          // convert to int 
and extract next bit
+      if(k) {                                        // if bit is a 1, 
+       d_subcarrier_map.push_back(4*(i+diff) + j);  // use this subcarrier
+      }
+    }
+  }
+
+  // make sure we stay in the limit currently imposed by the occupied_carriers
+  if(d_subcarrier_map.size() > d_occupied_carriers) {
+    throw std::invalid_argument("gr_ofdm_mapper_bcv: subcarriers allocated 
exceeds size of occupied carriers");
+  }
   
   d_nbits = (unsigned long)ceil(log10(d_constellation.size()) / log10(2.0));
 }
@@ -107,8 +133,9 @@
   
   i = 0;
   unsigned char bits = 0;
-  while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) {
-    
+  //while((d_msg_offset < d_msg->length()) && (i < d_occupied_carriers)) {
+  while((d_msg_offset < d_msg->length()) && (i < d_subcarrier_map.size())) {
+
     // need new data to process
     if(d_bit_offset == 0) {
       d_msgbytes = d_msg->msg()[d_msg_offset];
@@ -119,7 +146,8 @@
       d_resid |= (((1 << d_nresid)-1) & d_msgbytes) << (d_nbits - d_nresid);
       bits = d_resid;
 
-      out[i + zeros_on_left] = d_constellation[bits];
+      //out[i + zeros_on_left] = d_constellation[bits];
+      out[d_subcarrier_map[i]] = d_constellation[bits];
       i++;
 
       d_bit_offset += d_nresid;
@@ -133,7 +161,8 @@
        bits = ((1 << d_nbits)-1) & (d_msgbytes >> d_bit_offset);
        d_bit_offset += d_nbits;
        
-       out[i + zeros_on_left] = d_constellation[bits];
+       //out[i + zeros_on_left] = d_constellation[bits];
+       out[d_subcarrier_map[i]] = d_constellation[bits];
        i++;
        
        /*
@@ -166,8 +195,11 @@
       d_resid = 0;
     }
 
-    while(i < d_occupied_carriers) {   // finish filling out the symbol
-      out[i + zeros_on_left] = d_constellation[randsym()];
+    //while(i < d_occupied_carriers) {   // finish filling out the symbol
+    while(i < d_subcarrier_map.size()) {   // finish filling out the symbol
+      //out[i + zeros_on_left] = d_constellation[randsym()];
+      out[d_subcarrier_map[i]] = d_constellation[randsym()];
+
       i++;
     }
 

Modified: 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
       2008-03-08 23:28:26 UTC (rev 7979)
+++ 
gnuradio/branches/developers/trondeau/ofdm/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.h
       2008-03-09 00:38:34 UTC (rev 7980)
@@ -69,6 +69,8 @@
   unsigned char d_resid;
   unsigned int d_nresid;
 
+  std::vector<int> d_subcarrier_map;
+
   int randsym();
 
  public:





reply via email to

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