[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5724 - gnuradio/branches/features/ofdm/sync/gnuradio-
From: |
trondeau |
Subject: |
[Commit-gnuradio] r5724 - gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general |
Date: |
Wed, 6 Jun 2007 19:43:02 -0600 (MDT) |
Author: trondeau
Date: 2007-06-06 19:43:02 -0600 (Wed, 06 Jun 2007)
New Revision: 5724
Modified:
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h
Log:
quick hack to get QAM16 to work
Modified:
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc
===================================================================
---
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc
2007-06-06 23:09:49 UTC (rev 5723)
+++
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.cc
2007-06-07 01:43:02 UTC (rev 5724)
@@ -72,24 +72,30 @@
if(!ok)
throw std::invalid_argument("Order M must be [2, 4, 16, 64, 256]");
+
+ make_constellation();
}
gr_ofdm_qam_mapper::~gr_ofdm_qam_mapper(void)
{
}
-void gr_ofdm_qam_mapper::make_constellation(int m)
+void gr_ofdm_qam_mapper::make_constellation()
{
int i = 0, j = 0, ii = 0, jj = 0;
// number of bits/symbol (log2(M))
- int k = (int)(log10(m) / log10(2.0));
+ int k = (int)(log10(d_mod_order) / log10(2.0));
int a, b;
float re, im;
float coeff = 1;
std::vector<int> bits_i, bits_q;
- for(i=0; i < m; i++) {
+ int rr = 0;
+ int ss = 0;
+ int ll = bits_i.size();
+
+ for(i=0; i < d_mod_order; i++) {
a = (i & (0x01 << (k-1))) >> (k-1);
b = (i & (0x01 << (k-2))) >> (k-2);
for(j=2; j < k; j+=2) {
@@ -97,38 +103,57 @@
bits_q.push_back( (i & (0x01 << (k-(j+1)-1))) >> (k-(j+1)-1));
}
- int ss = 0;
- int ll = bits_i.size();
- for(ii = 0; i < ll; i++) {
- int rr = 0;
+ ss = 0;
+ ll = bits_i.size();
+ for(ii = 0; ii < ll; ii++) {
+ rr = 0;
for(jj = 0; jj < (ll-ii); jj++) {
rr = abs(bits_i[jj] - rr);
- ss += rr * pow(2.0, ii+1);
}
- re = (2.0*a-1.0)*(ss+1.0);
-
- ss = 0;
- ll = bits_q.size();
- for(ii = 0; ii < ll; ii++) {
- rr = 0;
- for(jj = 0; jj < (ll-ii); jj++) {
- rr = abs(bits_q[jj] - rr);
- }
- ss += rr*pow(2.0, ii+1.0);
+ ss += rr * pow(2.0, ii+1.0);
+ }
+ re = (2.0*a-1.0)*(ss+1.0);
+
+ ss = 0;
+ ll = bits_q.size();
+ for(ii = 0; ii < ll; ii++) {
+ rr = 0;
+ for(jj = 0; jj < (ll-ii); jj++) {
+ rr = abs(bits_q[jj] - rr);
}
- im = (2.0*b-1.0)*(ss+1.0);
+ ss += rr*pow(2.0, ii+1.0);
+ }
+ im = (2.0*b-1.0)*(ss+1.0);
- a = std::max(re, im);
- if(a > coeff) {
- coeff = a;
- }
- d_constellation_map.push_back(gr_complex(re, im));
+ a = std::max(re, im);
+ if(a > coeff) {
+ coeff = a;
}
-
- for(i = 0; i < d_constellation_map.size(); i++) {
- d_constellation_map[i] /= coeff;
- }
+ d_constellation_map.push_back(gr_complex(re, im));
}
+
+ d_constellation_map[0] = gr_complex(-3, -3);
+ d_constellation_map[1] = gr_complex(-3, -1);
+ d_constellation_map[2] = gr_complex(-3, 1);
+ d_constellation_map[3] = gr_complex(-3, 3);
+ d_constellation_map[4] = gr_complex(-1, -3);
+ d_constellation_map[5] = gr_complex(-1, -1);
+ d_constellation_map[6] = gr_complex(-1, 1);
+ d_constellation_map[7] = gr_complex(-1, 3);
+ d_constellation_map[8] = gr_complex(1, -3);
+ d_constellation_map[9] = gr_complex(1, -1);
+ d_constellation_map[10] = gr_complex(1, 1);
+ d_constellation_map[11] = gr_complex(1, 3);
+ d_constellation_map[12] = gr_complex(3, -3);
+ d_constellation_map[13] = gr_complex(3, -1);
+ d_constellation_map[14] = gr_complex(3, 1);
+ d_constellation_map[15] = gr_complex(3, 3);
+
+ coeff = sqrt(31.0)/2.0;
+ for(i = 0; i < d_constellation_map.size(); i++) {
+ d_constellation_map[i] /= coeff;
+ printf("const[%d]: %f + j%f\n", i, d_constellation_map[i].real(),
d_constellation_map[i].imag());
+ }
}
static float
@@ -186,7 +211,15 @@
unsigned char bit1 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01;
d_bit_offset++;
- out[i + zeros_on_left] = gr_complex(-1+2*(bit0), -1+2*(bit1) );
+ unsigned char bit2 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01;
+ d_bit_offset++;
+
+ unsigned char bit3 = (d_msg->msg()[d_msg_offset] >> (d_bit_offset)) & 0x01;
+ d_bit_offset++;
+
+ unsigned char bit = (bit0 << 3) | (bit1 << 2) | (bit2 << 1) | (bit3 << 0);
+
+ out[i + zeros_on_left] = d_constellation_map[bit];
i++;
if(d_bit_offset == 8) {
d_bit_offset = 0;
@@ -197,7 +230,7 @@
// Ran out of data to put in symbol
if (d_msg_offset == d_msg->length()) {
while(i < d_occupied_carriers) { // finish filling out the symbol
- out[i + zeros_on_left] = gr_complex(randombit(),0);
+ out[i + zeros_on_left] = d_constellation_map[rand() & 0x0F];
i++;
}
Modified:
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h
===================================================================
---
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h
2007-06-06 23:09:49 UTC (rev 5723)
+++
gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general/gr_ofdm_qam_mapper.h
2007-06-07 01:43:02 UTC (rev 5724)
@@ -67,7 +67,7 @@
int d_mod_order;
std::vector<gr_complex> d_constellation_map;
- void make_constellation(int m);
+ void make_constellation();
public:
~gr_ofdm_qam_mapper(void);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5724 - gnuradio/branches/features/ofdm/sync/gnuradio-core/src/lib/general,
trondeau <=