3 # Copyright 2006, 2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
24 from gnuradio import gr
25 from gnuradio.blksimpl.ofdm_sync_ml import ofdm_sync_ml
26 from gnuradio.blksimpl.ofdm_sync_pn import ofdm_sync_pn
27 from gnuradio.blksimpl.ofdm_sync_pnac import ofdm_sync_pnac
29 class ofdm_receiver(gr.hier_block):
30 def __init__(self, fg, fft_length, cp_length, occupied_tones, snr, ks, logging=False):
33 bw = (float(occupied_tones) / float(fft_length)) / 2.0
35 chan_coeffs = gr.firdes.low_pass (1.0, # gain
37 bw+tb, # midpoint of trans. band
38 tb, # width of trans. band
39 gr.firdes.WIN_HAMMING) # filter type
40 self.chan_filt = gr.fft_filter_ccc(1, chan_coeffs)
42 win = [1 for i in range(fft_length)]
46 self.ofdm_sync = ofdm_sync_ml(fg, fft_length, cp_length, snr, logging)
48 self.ofdm_sync = ofdm_sync_pn(fg, fft_length, cp_length, logging)
50 self.ofdm_sync = ofdm_sync_pnac(fg, fft_length, cp_length, ks[0])
52 self.fft_demod = gr.fft_vcc(fft_length, True, win, True)
53 self.ofdm_corr = gr.ofdm_correlator(occupied_tones, fft_length,
54 cp_length, ks[1], ks[2])
56 self.fg.connect(self.chan_filt, self.ofdm_sync, self.fft_demod, self.ofdm_corr)
59 self.fg.connect(self.chan_filt, gr.file_sink(gr.sizeof_gr_complex, "chan_filt_c.dat"))
60 self.fg.connect(self.fft_demod, gr.file_sink(gr.sizeof_gr_complex*fft_length, "fft_out_c.dat"))
61 self.fg.connect(self.ofdm_corr, gr.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_corr_out_c.dat"))
62 self.fg.connect((self.ofdm_corr,1), gr.file_sink(1, "found_corr_b.dat"))
64 gr.hier_block.__init__(self, fg, self.chan_filt, self.ofdm_corr)