Revision 0e8c3542 gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py
| b/gnuradio-core/src/python/gnuradio/blks2impl/ofdm.py | ||
|---|---|---|
| 21 | 21 |
# |
| 22 | 22 |
|
| 23 | 23 |
import math |
| 24 |
from gnuradio import gr, ofdm_packet_utils |
|
| 24 |
from gnuradio import gr, ofdm_packet_utils, modulation_utils2
|
|
| 25 | 25 |
import gnuradio.gr.gr_threading as _threading |
| 26 | 26 |
import psk, qam |
| 27 | 27 |
|
| 28 | 28 |
from gnuradio.blks2impl.ofdm_receiver import ofdm_receiver |
| 29 | 29 |
|
| 30 |
def _add_common_options(normal, expert): |
|
| 31 |
""" |
|
| 32 |
Adds OFDM-specific options to the Options Parser that are common |
|
| 33 |
both to the modulator and demodulator. |
|
| 34 |
""" |
|
| 35 |
mods_list = ", ".join(modulation_utils2.type_1_mods().keys()) |
|
| 36 |
normal.add_option("-m", "--modulation", type="string", default="psk",
|
|
| 37 |
help="set modulation type (" + mods_list + ") [default=%default]")
|
|
| 38 |
expert.add_option("", "--fft-length", type="intx", default=512,
|
|
| 39 |
help="set the number of FFT bins [default=%default]") |
|
| 40 |
expert.add_option("", "--occupied-tones", type="intx", default=200,
|
|
| 41 |
help="set the number of occupied FFT bins [default=%default]") |
|
| 42 |
expert.add_option("", "--cp-length", type="intx", default=128,
|
|
| 43 |
help="set the number of bits in the cyclic prefix [default=%default]") |
|
| 30 | 44 |
|
| 31 | 45 |
# ///////////////////////////////////////////////////////////////////////////// |
| 32 | 46 |
# mod/demod with packets as i/o |
| ... | ... | |
| 61 | 75 |
self._fft_length = options.fft_length |
| 62 | 76 |
self._occupied_tones = options.occupied_tones |
| 63 | 77 |
self._cp_length = options.cp_length |
| 78 |
|
|
| 79 |
arity = options.constellation_points |
|
| 64 | 80 |
|
| 65 | 81 |
win = [] #[1 for i in range(self._fft_length)] |
| 66 | 82 |
|
| ... | ... | |
| 82 | 98 |
|
| 83 | 99 |
symbol_length = options.fft_length + options.cp_length |
| 84 | 100 |
|
| 85 |
mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
|
|
| 86 |
arity = mods[self._modulation] |
|
| 87 |
|
|
| 88 |
rot = 1 |
|
| 89 |
if self._modulation == "qpsk": |
|
| 90 |
rot = (0.707+0.707j) |
|
| 91 |
|
|
| 92 |
if(self._modulation.find("psk") >= 0):
|
|
| 93 |
rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) |
|
| 94 |
elif(self._modulation.find("qam") >= 0):
|
|
| 95 |
rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) |
|
| 96 |
#print rotated_const |
|
| 97 |
self._pkt_input = gr.ofdm_mapper_bcv(rotated_const, msgq_limit, |
|
| 101 |
const = modulation_utils2.type_1_constellations()[self._modulation](arity).points() |
|
| 102 |
|
|
| 103 |
self._pkt_input = gr.ofdm_mapper_bcv(const, msgq_limit, |
|
| 98 | 104 |
options.occupied_tones, options.fft_length) |
| 99 | 105 |
|
| 100 | 106 |
self.preambles = gr.ofdm_insert_preamble(self._fft_length, padded_preambles) |
| ... | ... | |
| 140 | 146 |
""" |
| 141 | 147 |
Adds OFDM-specific options to the Options Parser |
| 142 | 148 |
""" |
| 143 |
normal.add_option("-m", "--modulation", type="string", default="bpsk",
|
|
| 144 |
help="set modulation type (bpsk, qpsk, 8psk, qam{16,64}) [default=%default]")
|
|
| 145 |
expert.add_option("", "--fft-length", type="intx", default=512,
|
|
| 146 |
help="set the number of FFT bins [default=%default]") |
|
| 147 |
expert.add_option("", "--occupied-tones", type="intx", default=200,
|
|
| 148 |
help="set the number of occupied FFT bins [default=%default]") |
|
| 149 |
expert.add_option("", "--cp-length", type="intx", default=128,
|
|
| 150 |
help="set the number of bits in the cyclic prefix [default=%default]") |
|
| 149 |
_add_common_options(normal, expert) |
|
| 150 |
for mod in modulation_utils2.type_1_mods().values(): |
|
| 151 |
mod.add_options(expert) |
|
| 152 |
|
|
| 151 | 153 |
# Make a static method to call before instantiation |
| 152 | 154 |
add_options = staticmethod(add_options) |
| 153 | 155 |
|
| ... | ... | |
| 196 | 198 |
self._cp_length = options.cp_length |
| 197 | 199 |
self._snr = options.snr |
| 198 | 200 |
|
| 201 |
arity = options.constellation_points |
|
| 202 |
print("con points is %s" % options.constellation_points)
|
|
| 203 |
|
|
| 199 | 204 |
# Use freq domain to get doubled-up known symbol for correlation in time domain |
| 200 | 205 |
zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) |
| 201 | 206 |
ksfreq = known_symbols_4512_3[0:self._occupied_tones] |
| ... | ... | |
| 211 | 216 |
self._occupied_tones, self._snr, preambles, |
| 212 | 217 |
options.log) |
| 213 | 218 |
|
| 214 |
mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256}
|
|
| 215 |
arity = mods[self._modulation] |
|
| 216 |
|
|
| 217 |
rot = 1 |
|
| 218 |
if self._modulation == "qpsk": |
|
| 219 |
rot = (0.707+0.707j) |
|
| 220 |
|
|
| 221 |
if(self._modulation.find("psk") >= 0):
|
|
| 222 |
rotated_const = map(lambda pt: pt * rot, psk.gray_constellation[arity]) |
|
| 223 |
elif(self._modulation.find("qam") >= 0):
|
|
| 224 |
rotated_const = map(lambda pt: pt * rot, qam.constellation[arity]) |
|
| 225 |
#print rotated_const |
|
| 219 |
constell = modulation_utils2.type_1_constellations()[self._modulation](arity).points() |
|
| 226 | 220 |
|
| 227 | 221 |
phgain = 0.25 |
| 228 | 222 |
frgain = phgain*phgain / 4.0 |
| 229 |
self.ofdm_demod = gr.ofdm_frame_sink(rotated_const, range(arity),
|
|
| 223 |
self.ofdm_demod = gr.ofdm_frame_sink(constell, range(arity),
|
|
| 230 | 224 |
self._rcvd_pktq, |
| 231 | 225 |
self._occupied_tones, |
| 232 | 226 |
phgain, frgain) |
| ... | ... | |
| 253 | 247 |
""" |
| 254 | 248 |
Adds OFDM-specific options to the Options Parser |
| 255 | 249 |
""" |
| 256 |
normal.add_option("-m", "--modulation", type="string", default="bpsk",
|
|
| 257 |
help="set modulation type (bpsk or qpsk) [default=%default]") |
|
| 258 |
expert.add_option("", "--fft-length", type="intx", default=512,
|
|
| 259 |
help="set the number of FFT bins [default=%default]") |
|
| 260 |
expert.add_option("", "--occupied-tones", type="intx", default=200,
|
|
| 261 |
help="set the number of occupied FFT bins [default=%default]") |
|
| 262 |
expert.add_option("", "--cp-length", type="intx", default=128,
|
|
| 263 |
help="set the number of bits in the cyclic prefix [default=%default]") |
|
| 250 |
_add_common_options(normal, expert) |
|
| 251 |
for demod in modulation_utils2.type_1_demods().values(): |
|
| 252 |
demod.add_options(expert) |
|
| 264 | 253 |
# Make a static method to call before instantiation |
| 265 | 254 |
add_options = staticmethod(add_options) |
| 266 | 255 |
|
Also available in: Unified diff