Пример #1
0
    def __init__(self, options):
        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0),
                                gr.io_signature(2, 2, gr.sizeof_gr_complex))

        common_options.defaults(options)

        config = self.config = station_configuration()

        config.data_subcarriers = options.subcarriers
        config.cp_length = options.cp_length
        config.frame_data_blocks = options.data_blocks
        config._verbose = options.verbose
        config.fft_length = options.fft_length
        config.training_data = default_block_header(config.data_subcarriers,
                                                    config.fft_length, options)
        config.tx_station_id = options.station_id
        config.coding = options.coding

        if config.tx_station_id is None:
            raise SystemError, "Station ID not set"

        config.frame_id_blocks = 1  # FIXME

        # digital rms amplitude sent to USRP
        rms_amp = options.rms_amplitude
        self._options = copy.copy(options)

        self.servants = []  # FIXME

        config.block_length = config.fft_length + config.cp_length
        config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks
        config.frame_length = config.frame_data_part + \
                              config.training_data.no_pilotsyms
        config.subcarriers = config.data_subcarriers + \
                             config.training_data.pilot_subcarriers
        config.virtual_subcarriers = config.fft_length - config.subcarriers

        # default values if parameters not set
        if rms_amp is None:
            rms_amp = math.sqrt(config.subcarriers)
        config.rms_amplitude = rms_amp

        # check some bounds
        if config.fft_length < config.subcarriers:
            raise SystemError, "Subcarrier number must be less than FFT length"
        if config.fft_length < config.cp_length:
            raise SystemError, "Cyclic prefix length must be less than FFT length"

        ## shortcuts
        blen = config.block_length
        flen = config.frame_length
        dsubc = config.data_subcarriers
        vsubc = config.virtual_subcarriers

        # ------------------------------------------------------------------------ #
        # Adaptive Transmitter Concept

        used_id_bits = config.used_id_bits = 8  #TODO: no constant in source code
        rep_id_bits = config.rep_id_bits = config.data_subcarriers / used_id_bits  #BPSK
        if config.data_subcarriers % used_id_bits <> 0:
            raise SystemError, "Data subcarriers need to be multiple of %d" % (
                used_id_bits)

        ## Control Part
        if options.debug:
            self._control = ctrl = static_tx_control(options)
            print "Statix TX Control used"
        else:
            self._control = ctrl = corba_tx_control(options)
            print "CORBA TX Control used"

        id_src = (ctrl, 0)
        mux_src = (ctrl, 1)
        map_src = self._map_src = (ctrl, 2)
        pa_src = (ctrl, 3)

        if options.log:
            id_src_f = gr.short_to_float()
            self.connect(id_src, id_src_f)
            log_to_file(self, id_src_f, "data/id_src_out.float")

            mux_src_f = gr.short_to_float()
            self.connect(mux_src, mux_src_f)
            log_to_file(self, mux_src_f, "data/mux_src_out.float")

            map_src_s = blocks.vector_to_stream(gr.sizeof_char,
                                                config.data_subcarriers)
            map_src_f = gr.char_to_float()
            self.connect(map_src, map_src_s, map_src_f)
            ##log_to_file(self, map_src_f, "data/map_src.float")

            ##log_to_file(self, pa_src, "data/pa_src_out.float")

        ## Workaround to avoid periodic structure
        seed(1)
        whitener_pn = [
            randint(0, 1) for i in range(used_id_bits * rep_id_bits)
        ]

        ## ID Encoder
        id_enc = self._id_encoder = repetition_encoder_sb(
            used_id_bits, rep_id_bits, whitener_pn)
        self.connect(id_src, id_enc)

        if options.log:
            id_enc_f = gr.char_to_float()
            self.connect(id_enc, id_enc_f)
            log_to_file(self, id_enc_f, "data/id_enc_out.float")

        ## Bitmap Update Trigger
        # TODO
        #bmaptrig_stream = concatenate([[1, 2],[0]*(config.frame_data_part-7)])
        bmaptrig_stream = concatenate([[1, 1],
                                       [0] * (config.frame_data_part - 2)])
        print "bmaptrig_stream = ", bmaptrig_stream
        btrig = self._bitmap_trigger = blocks.vector_source_b(
            bmaptrig_stream.tolist(), True)
        if options.log:
            log_to_file(self, btrig, "data/bitmap_trig.char")

        ## Bitmap Update Trigger for puncturing
        # TODO
        if not options.nopunct:
            #bmaptrig_stream_puncturing = concatenate([[1],[0]*(config.frame_data_part-2)])
            bmaptrig_stream_puncturing = concatenate(
                [[1], [0] * (config.frame_data_blocks / 2 - 1)])

            btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(
                bmaptrig_stream_puncturing.tolist(), True)
            bmapsrc_stream_puncturing = concatenate([[1] * dsubc, [2] * dsubc])
            bsrc_puncturing = self._bitmap_src_puncturing = blocks.vector_source_b(
                bmapsrc_stream_puncturing.tolist(), True, dsubc)

        if options.log and options.coding and not options.nopunct:
            log_to_file(self, btrig_puncturing,
                        "data/bitmap_trig_puncturing.char")

        ## Frame Trigger
        # TODO
        ftrig_stream = concatenate([[1], [0] * (config.frame_data_part - 1)])
        ftrig = self._frame_trigger = blocks.vector_source_b(
            ftrig_stream.tolist(), True)

        ## Data Multiplexer
        # Input 0: control stream
        # Input 1: encoded ID stream
        # Inputs 2..n: data streams
        dmux = self._data_multiplexer = stream_controlled_mux_b()
        self.connect(mux_src, (dmux, 0))
        self.connect(id_enc, (dmux, 1))

        self._data_multiplexer_nextport = 2

        if options.log:
            dmux_f = gr.char_to_float()
            self.connect(dmux, dmux_f)
            log_to_file(self, dmux_f, "data/dmux_out.float")

        ## Modulator
        mod = self._modulator = generic_mapper_bcv(config.data_subcarriers,
                                                   options.coding)

        self.connect(dmux, (mod, 0))
        self.connect(map_src, (mod, 1))
        self.connect(btrig, (mod, 2))

        if options.log:
            log_to_file(self, mod, "data/mod_out.compl")
            modi = gr.complex_to_imag(config.data_subcarriers)
            modr = gr.complex_to_real(config.data_subcarriers)
            self.connect(mod, modi)
            self.connect(mod, modr)
            log_to_file(self, modi, "data/mod_imag_out.float")
            log_to_file(self, modr, "data/mod_real_out.float")

        ## Power allocator
        if options.debug:

            ## static
            pa = self._power_allocator = power_allocator(
                config.data_subcarriers)
            self.connect(mod, (pa, 0))
            self.connect(pa_src, (pa, 1))

        else:

            ## with CORBA control event channel
            ns_ip = ctrl.ns_ip
            ns_port = ctrl.ns_port
            evchan = ctrl.evchan
            pa = self._power_allocator = corba_power_allocator(dsubc, \
                evchan, ns_ip, ns_port, True)

            self.connect(mod, (pa, 0))
            self.connect(id_src, (pa, 1))
            self.connect(ftrig, (pa, 2))

        if options.log:
            log_to_file(self, pa, "data/pa_out.compl")

        ## Pilot subcarriers
        psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter()
        self.connect(pa, psubc)

        pilot_subc = config.training_data.shifted_pilot_tones
        print "pilot_subc", pilot_subc
        stc = stc_encoder(config.subcarriers, config.frame_data_blocks,
                          pilot_subc)

        self.connect(psubc, stc)

        if options.log:
            log_to_file(self, psubc, "data/psubc_out.compl")
            log_to_file(self, psubc_2, "data/psubc2_out.compl")
            log_to_file(self, pa, "data/pa.compl")
            log_to_file(self, (stc, 0), "data/stc_0.compl")
            log_to_file(self, (stc, 1), "data/stc_1.compl")

        ## Add virtual subcarriers
        if config.fft_length > config.subcarriers:
            vsubc = self._virtual_subcarrier_extender = \
                    vector_padding(config.subcarriers, config.fft_length)
            self.connect(stc, vsubc)
            vsubc_2 = self._virtual_subcarrier_extender_2 = \
                    vector_padding(config.subcarriers, config.fft_length)
            self.connect((stc, 1), vsubc_2)
        else:
            vsubc = self._virtual_subcarrier_extender = psubc
            vsubc_2 = self._virtual_subcarrier_extender_2 = psubc_2

        log_to_file(self, psubc, "data/psubc.compl")
        log_to_file(self, stc, "data/stc1.compl")
        log_to_file(self, (stc, 1), "data/stc2.compl")
        if options.log:
            log_to_file(self, vsubc, "data/vsubc_out.compl")
            log_to_file(self, vsubc_2, "data/vsubc2_out.compl")

        ## IFFT, no window, block shift
        ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length, False, [],
                                               True)
        self.connect(vsubc, ifft)
        ifft_2 = self._ifft_2 = fft_blocks.fft_vcc(config.fft_length, False,
                                                   [], True)
        self.connect(vsubc_2, ifft_2)

        if options.log:
            log_to_file(self, ifft, "data/ifft_out.compl")
            log_to_file(self, ifft_2, "data/ifft2_out.compl")

        ## Pilot blocks (preambles)
        pblocks = self._pilot_block_inserter = pilot_block_inserter(1, False)
        self.connect(ifft, pblocks)
        pblocks_2 = self._pilot_block_inserter_2 = pilot_block_inserter(
            2, False)
        self.connect(ifft_2, pblocks_2)

        if options.log:
            log_to_file(self, pblocks, "data/pilot_block_ins_out.compl")
            log_to_file(self, pblocks_2, "data/pilot_block_ins2_out.compl")

        ## Cyclic Prefix
        cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length,
                                                     config.block_length)
        self.connect(pblocks, cp)
        cp_2 = self._cyclic_prefixer_2 = cyclic_prefixer(
            config.fft_length, config.block_length)
        self.connect(pblocks_2, cp_2)

        lastblock = cp
        lastblock_2 = cp_2

        if options.log:
            log_to_file(self, cp, "data/cp_out.compl")
            log_to_file(self, cp_2, "data/cp2_out.compl")

        if options.cheat:
            ## Artificial Channel
            # kept to compare with previous system
            achan_ir = concatenate([[1.0], [0.0] * (config.cp_length - 1)])
            achan = self._artificial_channel = gr.fir_filter_ccc(1, achan_ir)
            self.connect(lastblock, achan)
            lastblock = achan
            achan_2 = self._artificial_channel_2 = gr.fir_filter_ccc(
                1, achan_ir)
            self.connect(lastblock_2, achan_2)
            lastblock_2 = achan_2

        ## Digital Amplifier
        amp = self._amplifier = ofdm.multiply_const_ccf(1.0 / math.sqrt(2))
        self.connect(lastblock, amp)
        amp_2 = self._amplifier_2 = ofdm.multiply_const_ccf(1.0 / math.sqrt(2))
        self.connect(lastblock_2, amp_2)
        self.set_rms_amplitude(rms_amp)

        if options.log:
            log_to_file(self, amp, "data/amp_tx_out.compl")
            log_to_file(self, amp_2, "data/amp_tx2_out.compl")

        ## Setup Output
        self.connect(amp, (self, 0))
        self.connect(amp_2, (self, 1))

        # ------------------------------------------------------------------------ #

        # Display some information about the setup
        if config._verbose:
            self._print_verbage()
Пример #2
0
    def __init__(self,
                 M=1024,
                 K=4,
                 qam_size=16,
                 syms_per_frame=10,
                 carriers=924,
                 theta_sel=0,
                 exclude_preamble=0,
                 sel_preamble=0,
                 zero_pads=1,
                 extra_pad=False):
        gr.hier_block2.__init__(
            self,
            "fbmc_transmitter_demo",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * M),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.syms_per_frame = syms_per_frame
        self.qam_size = qam_size
        self.K = K
        self.M = M
        self.exclude_preamble = exclude_preamble
        self.theta_sel = theta_sel
        self.zero_pads = zero_pads

        ##################################################
        # Variables
        ##################################################

        # Assertions
        assert (M > 0 and K > 0
                and qam_size > 0), "M, K and qam_size should be bigger than 0"
        assert ((math.log(M) / math.log(2)) == int(
            math.log(M) / math.log(2))), "M shouldbe a power of 2"
        assert (K == 4), "for now only K=4 s supported."
        assert (qam_size == 4 or qam_size == 16 or qam_size == 64
                or qam_size == 256
                ), "Only 4-,16-,64-,256-qam constellations are supported."
        assert (theta_sel == 0 or theta_sel == 1)
        assert (exclude_preamble == 0 or exclude_preamble == 1)

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0_0 = fft.fft_vcc(M, False, (), True, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            ([1.0 / (M * 0.6863)] * M))
        # self.fbmc_symbol_creation_bvc_0 = ofdm.fbmc_symbol_creation_bvc(carriers, qam_size)
        self.vector_padding_0 = ofdm.vector_padding(carriers, M, -1)
        self.fbmc_separate_vcvc_0 = ofdm.fbmc_separate_vcvc(M, 2)
        self.fbmc_polyphase_network_vcvc_0_0 = ofdm.fbmc_polyphase_network_vcvc(
            M, K, K * M - 1, False)
        self.fbmc_polyphase_network_vcvc_0 = ofdm.fbmc_polyphase_network_vcvc(
            M, K, K * M - 1, False)
        self.fbmc_overlapping_parallel_to_serial_vcc_0 = ofdm.fbmc_overlapping_parallel_to_serial_vcc(
            M)
        self.fbmc_oqam_preprocessing_vcvc_0 = ofdm.fbmc_oqam_preprocessing_vcvc(
            M, 0, theta_sel)
        self.fbmc_insert_preamble_vcvc_0 = ofdm.fbmc_insert_preamble_vcvc(
            M, syms_per_frame, sel_preamble, zero_pads, extra_pad)
        self.fbmc_beta_multiplier_vcvc_0 = ofdm.fbmc_beta_multiplier_vcvc(
            M, K, K * M - 1, 0)
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex * M,
            num_inputs=2,
            num_outputs=1,
            input_index=exclude_preamble,
            output_index=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.vector_padding_0, 0))
        self.connect((self.vector_padding_0, 0),
                     (self.fbmc_oqam_preprocessing_vcvc_0, 0))
        # self.connect(, (self.fbmc_symbol_creation_bvc_0, 0))
        self.connect((self.fbmc_beta_multiplier_vcvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.fbmc_separate_vcvc_0, 0))
        self.connect((self.fbmc_polyphase_network_vcvc_0, 0),
                     (self.fbmc_overlapping_parallel_to_serial_vcc_0, 0))
        self.connect((self.fbmc_polyphase_network_vcvc_0_0, 0),
                     (self.fbmc_overlapping_parallel_to_serial_vcc_0, 1))
        self.connect((self.fbmc_separate_vcvc_0, 1),
                     (self.fbmc_polyphase_network_vcvc_0_0, 0))
        self.connect((self.fbmc_separate_vcvc_0, 0),
                     (self.fbmc_polyphase_network_vcvc_0, 0))
        self.connect((self.fbmc_overlapping_parallel_to_serial_vcc_0, 0),
                     (self, 0))
        self.connect((self.fbmc_oqam_preprocessing_vcvc_0, 0),
                     (self.blks2_selector_0, 1))
        self.connect((self.fbmc_oqam_preprocessing_vcvc_0, 0),
                     (self.fbmc_insert_preamble_vcvc_0, 0))
        self.connect((self.fbmc_insert_preamble_vcvc_0, 0),
                     (self.blks2_selector_0, 0))
        self.connect((self.blks2_selector_0, 0),
                     (self.fbmc_beta_multiplier_vcvc_0, 0))
Пример #3
0
    def __init__(self, M=1024, K=4, qam_size=16, syms_per_frame=10, carriers=924, theta_sel=0, exclude_preamble=0, sel_preamble=0, zero_pads=1, extra_pad=False):
        gr.hier_block2.__init__(self,
            "fbmc_transmitter_demo",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*M),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.syms_per_frame = syms_per_frame
        self.qam_size = qam_size
        self.K = K
        self.M = M
        self.exclude_preamble = exclude_preamble
        self.theta_sel = theta_sel
        self.zero_pads = zero_pads

        ##################################################
        # Variables
        ##################################################

        # Assertions
        assert(M>0 and K>0 and qam_size>0), "M, K and qam_size should be bigger than 0"
        assert((math.log(M)/math.log(2))==int(math.log(M)/math.log(2))), "M shouldbe a power of 2"
        assert(K==4), "for now only K=4 s supported."
        assert(qam_size==4 or qam_size==16 or qam_size==64 or qam_size==256 ), "Only 4-,16-,64-,256-qam constellations are supported."
        assert(theta_sel==0 or theta_sel==1)
        assert(exclude_preamble==0 or exclude_preamble==1)

        ##################################################
        # Blocks
        ##################################################
        self.fft_vxx_0_0 = fft.fft_vcc(M, False, (), True, 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(([1.0/(M*0.6863)]*M))
        # self.fbmc_symbol_creation_bvc_0 = ofdm.fbmc_symbol_creation_bvc(carriers, qam_size)
        self.vector_padding_0 = ofdm.vector_padding(carriers,M,-1)
        self.fbmc_separate_vcvc_0 = ofdm.fbmc_separate_vcvc(M, 2)
        self.fbmc_polyphase_network_vcvc_0_0 = ofdm.fbmc_polyphase_network_vcvc(M, K, K*M-1, False)
        self.fbmc_polyphase_network_vcvc_0 = ofdm.fbmc_polyphase_network_vcvc(M, K, K*M-1, False)
        self.fbmc_overlapping_parallel_to_serial_vcc_0 = ofdm.fbmc_overlapping_parallel_to_serial_vcc(M)
        self.fbmc_oqam_preprocessing_vcvc_0 = ofdm.fbmc_oqam_preprocessing_vcvc(M, 0, theta_sel)
        self.fbmc_insert_preamble_vcvc_0 = ofdm.fbmc_insert_preamble_vcvc(M, syms_per_frame, sel_preamble, zero_pads,extra_pad)
        self.fbmc_beta_multiplier_vcvc_0 = ofdm.fbmc_beta_multiplier_vcvc(M, K, K*M-1, 0)
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex*M,
            num_inputs=2,
            num_outputs=1,
            input_index=exclude_preamble,
            output_index=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.vector_padding_0,0))
        self.connect((self.vector_padding_0,0),(self.fbmc_oqam_preprocessing_vcvc_0, 0))
        # self.connect(, (self.fbmc_symbol_creation_bvc_0, 0))
        self.connect((self.fbmc_beta_multiplier_vcvc_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_multiply_const_vxx_0,0))
        self.connect((self.blocks_multiply_const_vxx_0,0), (self.fbmc_separate_vcvc_0, 0))
        self.connect((self.fbmc_polyphase_network_vcvc_0, 0), (self.fbmc_overlapping_parallel_to_serial_vcc_0, 0))
        self.connect((self.fbmc_polyphase_network_vcvc_0_0, 0), (self.fbmc_overlapping_parallel_to_serial_vcc_0, 1))
        self.connect((self.fbmc_separate_vcvc_0, 1), (self.fbmc_polyphase_network_vcvc_0_0, 0))
        self.connect((self.fbmc_separate_vcvc_0, 0), (self.fbmc_polyphase_network_vcvc_0, 0))
        self.connect((self.fbmc_overlapping_parallel_to_serial_vcc_0, 0), (self, 0))
        self.connect((self.fbmc_oqam_preprocessing_vcvc_0, 0), (self.blks2_selector_0, 1))
        self.connect((self.fbmc_oqam_preprocessing_vcvc_0, 0), (self.fbmc_insert_preamble_vcvc_0, 0))
        self.connect((self.fbmc_insert_preamble_vcvc_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.fbmc_beta_multiplier_vcvc_0, 0))
Пример #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.used_id_bits = used_id_bits = 8
        self.subcarriers = subcarriers = 208
        self.id_blocks = id_blocks = 1
        self.fft_length = fft_length = 256
        self.fbmc = fbmc = 1
        self.estimation_preamble = estimation_preamble = 0
        self.data_blocks = data_blocks = 10
        self.training_data = training_data = default_block_header(subcarriers,fft_length,fbmc,estimation_preamble,[])
        self.repeated_id_bits = repeated_id_bits = subcarriers/used_id_bits
        self.data_part = data_part = data_blocks + id_blocks
        self.whitener_seed = whitener_seed = seed(1)
        self.whitener_pn = whitener_pn = [randint(0,1) for i in range(used_id_bits*repeated_id_bits)]
        self.variable_function_probe_2 = variable_function_probe_2 = 0
        self.variable_function_probe_1 = variable_function_probe_1 = 0
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.tx_hostname = tx_hostname = "localhost"
        self.samp_rate = samp_rate = 4*250000
        self.interleaver = interleaver = trellis.interleaver(2000,666)
        self.frame_length = frame_length = 2*data_part + training_data.fbmc_no_preambles
        self.filter_length = filter_length = 4
        self.disable_freq_sync = disable_freq_sync = 1
        self.coding = coding = 1
        self.chunkdivisor = chunkdivisor = int(numpy.ceil(data_blocks/5.0))
        self.ber_window = ber_window = 100000
        self.amplitude = amplitude = 1
        self.SNR = SNR = 40

        ##################################################
        # Blocks
        ##################################################
        self._amplitude_layout = Qt.QVBoxLayout()
        self._amplitude_tool_bar = Qt.QToolBar(self)
        self._amplitude_layout.addWidget(self._amplitude_tool_bar)
        self._amplitude_tool_bar.addWidget(Qt.QLabel("amplitude"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._amplitude_counter = qwt_counter_pyslot()
        self._amplitude_counter.setRange(0, 1, 0.02)
        self._amplitude_counter.setNumButtons(2)
        self._amplitude_counter.setValue(self.amplitude)
        self._amplitude_tool_bar.addWidget(self._amplitude_counter)
        self._amplitude_counter.valueChanged.connect(self.set_amplitude)
        self._amplitude_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._amplitude_slider.setRange(0, 1, 0.02)
        self._amplitude_slider.setValue(self.amplitude)
        self._amplitude_slider.setMinimumWidth(200)
        self._amplitude_slider.valueChanged.connect(self.set_amplitude)
        self._amplitude_layout.addWidget(self._amplitude_slider)
        self.top_layout.addLayout(self._amplitude_layout)
        self.tx_rpc_manager_0 = tx_rpc_manager(fft_length, subcarriers, data_blocks, frame_length, 0, 0.0, samp_rate)
        self.tigr_transmit_control_0 = tigr_transmit_control(
            subcarriers=subcarriers,
            fft_length=fft_length,
            used_id_bits=used_id_bits,
            estimation_preamble=estimation_preamble,
            filter_length=filter_length,
            fbmc=fbmc,
            data_blocks=data_blocks,
            data_part=data_part,
            repeated_id_bits=repeated_id_bits,
            coding=coding,
        )
        self.tigr_scatterplot_0 = tigr_scatterplot(
            subcarriers=subcarriers,
            fbmc=fbmc,
            fft_length=fft_length,
            estimation_preamble=estimation_preamble,
            data_blocks=data_blocks,
            data_part=11,
            frame_length=frame_length,
        )
        self.rx_rpc_manager_0 = rx_rpc_manager()
        self.rms = fbmc_rms_amplifier(amplitude, subcarriers)
        self.zeromq_pub_sink_1 = zeromq.pub_sink(gr.sizeof_float, subcarriers, "tcp://*:5559", 100)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_float, 1, "tcp://*:5557", 100)
        def _variable_function_probe_2_probe():
            while True:
                val = self.rx_rpc_manager_0.add_set_scatter_subcarrier_interface(self.tigr_scatterplot_0.ofdm_vector_element_0.set_element)
                try:
                    self.set_variable_function_probe_2(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.000000001))
        _variable_function_probe_2_thread = threading.Thread(target=_variable_function_probe_2_probe)
        _variable_function_probe_2_thread.daemon = True
        _variable_function_probe_2_thread.start()
        def _variable_function_probe_1_probe():
            while True:
                val = self.tx_rpc_manager_0.add_tx_modulation_interface(self.tigr_transmit_control_0.ofdm_allocation_src_0.set_allocation)
                try:
                    self.set_variable_function_probe_1(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.000000001))
        _variable_function_probe_1_thread = threading.Thread(target=_variable_function_probe_1_probe)
        _variable_function_probe_1_thread.daemon = True
        _variable_function_probe_1_thread.start()
        def _variable_function_probe_0_probe():
            while True:
                val = self.tx_rpc_manager_0.add_tx_ampl_interface(self.rms.set_rms_amplitude)
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.000000001))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()
        self.trellis_permutation_0 = trellis.permutation(interleaver.K(), (interleaver.DEINTER()), 1, gr.sizeof_float*1)
        self.tigr_fbmc_snr_estimator_0 = tigr_fbmc_snr_estimator(
            subcarriers=subcarriers,
            fbmc=fbmc,
            fft_length=fft_length,
            estimation_preamble=estimation_preamble,
            frame_length=frame_length,
        )
        self.tigr_fbmc_inner_receiver_0 = tigr_fbmc_inner_receiver(
            subcarriers=subcarriers,
            fft_length=fft_length,
            data_blocks=data_blocks,
            estimation_preamble=estimation_preamble,
            filter_length=filter_length,
            frame_length=frame_length,
            disable_freq_sync=disable_freq_sync,
        )
        self.tigr_ber_measurement_0 = tigr_ber_measurement(
            subcarriers=subcarriers,
            fbmc=fbmc,
            fft_length=fft_length,
            estimation_preamble=estimation_preamble,
            ber_window=ber_window,
            data_blocks=data_blocks,
        )
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.1, subcarriers)
        self.ofdm_viterbi_combined_fb_0 = ofdm.viterbi_combined_fb(ofdm.fsm(ofdm.fsm(1,2,[91,121])), subcarriers, -1, -1, 2, chunkdivisor, ([-1,-1,-1,1,1,-1,1,1]), ofdm.TRELLIS_EUCLIDEAN)
        self.ofdm_vector_sampler_0 = ofdm.vector_sampler(gr.sizeof_gr_complex*subcarriers, 1)
        self.ofdm_vector_padding_0 = ofdm.vector_padding(subcarriers, fft_length,  -1)
        self.ofdm_multiply_frame_fc_0 = ofdm.multiply_frame_fc(data_part, subcarriers)
        self.ofdm_multiply_const_ii_0 = ofdm.multiply_const_ii(1./int(numpy.ceil(data_blocks/5.0)))
        self.ofdm_generic_softdemapper_vcf_0 = ofdm.generic_softdemapper_vcf(subcarriers, data_part, 1)
        self.ofdm_fbmc_separate_vcvc_1 = ofdm.fbmc_separate_vcvc(fft_length, 2)
        self.ofdm_fbmc_polyphase_network_vcvc_1 = ofdm.fbmc_polyphase_network_vcvc(fft_length, filter_length, filter_length*fft_length-1, False)
        self.ofdm_fbmc_polyphase_network_vcvc_0 = ofdm.fbmc_polyphase_network_vcvc(fft_length, filter_length, filter_length*fft_length-1, False)
        self.ofdm_fbmc_pilot_block_inserter_0 = fbmc_pilot_block_inserter(subcarriers, data_part, training_data, 5)
        self.ofdm_fbmc_pilot_block_filter_0 = fbmc_pilot_block_filter(subcarriers, frame_length, data_part, training_data)
        self.ofdm_fbmc_overlapping_parallel_to_serial_vcc_0 = ofdm.fbmc_overlapping_parallel_to_serial_vcc(fft_length)
        self.ofdm_fbmc_oqam_preprocessing_vcvc_0 = ofdm.fbmc_oqam_preprocessing_vcvc(subcarriers, 0, 0)
        self.ofdm_fbmc_frame_sampler_0 = fbmc_frame_sampler(subcarriers, frame_length, data_part, training_data)
        self.ofdm_fbmc_beta_multiplier_vcvc_0 = ofdm.fbmc_beta_multiplier_vcvc(fft_length, filter_length, fft_length*fft_length-1, 0)
        self.ofdm_dynamic_trigger_ib_0 = ofdm.dynamic_trigger_ib(0)
        self.ofdm_depuncture_ff_0 = ofdm.depuncture_ff(subcarriers, 0)
        self.ofdm_coded_bpsk_soft_decoder_0 = ofdm.coded_bpsk_soft_decoder(subcarriers, used_id_bits, (whitener_pn))
        self.ofdm_allocation_buffer_0 = ofdm.allocation_buffer(subcarriers, data_blocks, "tcp://"+tx_hostname+":3333", 1)
        self.fft_vxx_1 = fft.fft_vcc(fft_length, False, ([]), True, 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=math.sqrt(1.0*fft_length/subcarriers)*math.sqrt(0.5)*10**(-SNR/20.0),
        	frequency_offset=0.0/fft_length,
        	epsilon=1,
        	taps=((1.0 ), ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_vector_source_x_0 = blocks.vector_source_b([1] + [0]*(data_blocks/2-1), True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*subcarriers, 20)
        self.blks2_selector_0 = grc_blks2.selector(
        	item_size=gr.sizeof_float*1,
        	num_inputs=2,
        	num_outputs=1,
        	input_index=0,
        	output_index=0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ofdm_fbmc_polyphase_network_vcvc_0, 0), (self.ofdm_fbmc_overlapping_parallel_to_serial_vcc_0, 0))
        self.connect((self.ofdm_fbmc_polyphase_network_vcvc_1, 0), (self.ofdm_fbmc_overlapping_parallel_to_serial_vcc_0, 1))
        self.connect((self.ofdm_fbmc_separate_vcvc_1, 1), (self.ofdm_fbmc_polyphase_network_vcvc_1, 0))
        self.connect((self.ofdm_fbmc_oqam_preprocessing_vcvc_0, 0), (self.ofdm_fbmc_pilot_block_inserter_0, 0))
        self.connect((self.ofdm_fbmc_pilot_block_inserter_0, 0), (self.ofdm_vector_padding_0, 0))
        self.connect((self.ofdm_fbmc_beta_multiplier_vcvc_0, 0), (self.fft_vxx_1, 0))
        self.connect((self.fft_vxx_1, 0), (self.ofdm_fbmc_separate_vcvc_1, 0))
        self.connect((self.tigr_transmit_control_0, 0), (self.ofdm_fbmc_oqam_preprocessing_vcvc_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_1, 0))
        self.connect((self.ofdm_fbmc_frame_sampler_0, 1), (self.ofdm_fbmc_pilot_block_filter_0, 1))
        self.connect((self.ofdm_fbmc_frame_sampler_0, 0), (self.ofdm_fbmc_pilot_block_filter_0, 0))
        self.connect((self.ofdm_fbmc_pilot_block_filter_0, 1), (self.ofdm_vector_sampler_0, 1))
        self.connect((self.ofdm_vector_sampler_0, 0), (self.ofdm_coded_bpsk_soft_decoder_0, 0))
        self.connect((self.ofdm_coded_bpsk_soft_decoder_0, 0), (self.ofdm_allocation_buffer_0, 0))
        self.connect((self.ofdm_allocation_buffer_0, 1), (self.ofdm_generic_softdemapper_vcf_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.ofdm_generic_softdemapper_vcf_0, 2))
        self.connect((self.ofdm_generic_softdemapper_vcf_0, 0), (self.trellis_permutation_0, 0))
        self.connect((self.ofdm_depuncture_ff_0, 0), (self.ofdm_viterbi_combined_fb_0, 0))
        self.connect((self.ofdm_allocation_buffer_0, 1), (self.ofdm_depuncture_ff_0, 1))
        self.connect((self.blocks_vector_source_x_0, 0), (self.ofdm_depuncture_ff_0, 2))
        self.connect((self.ofdm_allocation_buffer_0, 0), (self.ofdm_multiply_const_ii_0, 0))
        self.connect((self.ofdm_multiply_const_ii_0, 0), (self.ofdm_viterbi_combined_fb_0, 1))
        self.connect((self.ofdm_fbmc_separate_vcvc_1, 0), (self.ofdm_fbmc_polyphase_network_vcvc_0, 0))
        self.connect((self.ofdm_viterbi_combined_fb_0, 0), (self.tigr_ber_measurement_0, 2))
        self.connect((self.ofdm_dynamic_trigger_ib_0, 0), (self.tigr_ber_measurement_0, 3))
        self.connect((self.ofdm_fbmc_frame_sampler_0, 0), (self.tigr_fbmc_snr_estimator_0, 0))
        self.connect((self.ofdm_fbmc_frame_sampler_0, 1), (self.tigr_fbmc_snr_estimator_0, 1))
        self.connect((self.tigr_fbmc_inner_receiver_0, 1), (self.ofdm_fbmc_frame_sampler_0, 1))
        self.connect((self.tigr_fbmc_inner_receiver_0, 2), (self.ofdm_fbmc_frame_sampler_0, 0))
        self.connect((self.rms, 0), (self.blocks_throttle_0, 0))
        self.connect((self.tigr_fbmc_inner_receiver_0, 3), (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.zeromq_pub_sink_1, 0))
        self.connect((self.ofdm_vector_padding_0, 0), (self.ofdm_fbmc_beta_multiplier_vcvc_0, 0))
        self.connect((self.tigr_fbmc_inner_receiver_0, 0), (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.ofdm_fbmc_overlapping_parallel_to_serial_vcc_0, 0), (self.rms, 0))
        self.connect((self.ofdm_allocation_buffer_0, 0), (self.ofdm_dynamic_trigger_ib_0, 0))
        self.connect((self.ofdm_coded_bpsk_soft_decoder_0, 0), (self.tigr_ber_measurement_0, 0))
        self.connect((self.ofdm_allocation_buffer_0, 0), (self.tigr_ber_measurement_0, 1))
        self.connect((self.blks2_selector_0, 0), (self.ofdm_depuncture_ff_0, 0))
        self.connect((self.trellis_permutation_0, 0), (self.blks2_selector_0, 1))
        self.connect((self.ofdm_generic_softdemapper_vcf_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.tigr_fbmc_inner_receiver_0, 0))
        self.connect((self.ofdm_fbmc_pilot_block_filter_0, 0), (self.ofdm_vector_sampler_0, 0))
        self.connect((self.ofdm_allocation_buffer_0, 2), (self.ofdm_multiply_frame_fc_0, 1))
        self.connect((self.ofdm_fbmc_pilot_block_filter_0, 0), (self.ofdm_multiply_frame_fc_0, 0))
        self.connect((self.ofdm_multiply_frame_fc_0, 0), (self.tigr_scatterplot_0, 0))
        self.connect((self.ofdm_multiply_frame_fc_0, 0), (self.ofdm_generic_softdemapper_vcf_0, 0))
Пример #5
0
  def __init__(self, options):
    gr.hier_block2.__init__(self, "transmit_path",
        gr.io_signature(0,0,0),
        gr.io_signature(2,2,gr.sizeof_gr_complex))

    common_options.defaults(options)

    config = self.config = station_configuration()

    config.data_subcarriers    = options.subcarriers
    config.cp_length           = options.cp_length
    config.frame_data_blocks   = options.data_blocks
    config._verbose            = options.verbose
    config.fft_length          = options.fft_length
    config.training_data       = default_block_header(config.data_subcarriers,
                                          config.fft_length,options)
    config.tx_station_id       = options.station_id
    config.coding              = options.coding
    

    if config.tx_station_id is None:
      raise SystemError, "Station ID not set"

    config.frame_id_blocks     = 1 # FIXME

    # digital rms amplitude sent to USRP
    rms_amp                    = options.rms_amplitude
    self._options              = copy.copy(options)

    self.servants = [] # FIXME

    config.block_length = config.fft_length + config.cp_length
    config.frame_data_part = config.frame_data_blocks + config.frame_id_blocks
    config.frame_length = config.frame_data_part + \
                          config.training_data.no_pilotsyms
    config.subcarriers = config.data_subcarriers + \
                         config.training_data.pilot_subcarriers
    config.virtual_subcarriers = config.fft_length - config.subcarriers

    # default values if parameters not set
    if rms_amp is None:
      rms_amp = math.sqrt(config.subcarriers)
    config.rms_amplitude = rms_amp

    # check some bounds
    if config.fft_length < config.subcarriers:
      raise SystemError, "Subcarrier number must be less than FFT length"
    if config.fft_length < config.cp_length:
      raise SystemError, "Cyclic prefix length must be less than FFT length"

    ## shortcuts
    blen = config.block_length
    flen = config.frame_length
    dsubc = config.data_subcarriers
    vsubc = config.virtual_subcarriers


    # ------------------------------------------------------------------------ #
    # Adaptive Transmitter Concept

    used_id_bits = config.used_id_bits = 8 #TODO: no constant in source code
    rep_id_bits = config.rep_id_bits = config.data_subcarriers/used_id_bits #BPSK
    if config.data_subcarriers % used_id_bits <> 0:
      raise SystemError,"Data subcarriers need to be multiple of %d" % (used_id_bits)


    ## Control Part
    if options.debug:
      self._control = ctrl = static_tx_control(options)
      print "Statix TX Control used"
    else:
      self._control = ctrl = corba_tx_control(options)
      print "CORBA TX Control used"

    id_src = (ctrl,0)
    mux_src = (ctrl,1)
    map_src = self._map_src = (ctrl,2)
    pa_src = (ctrl,3)


    if options.log:
      id_src_f = gr.short_to_float()
      self.connect(id_src,id_src_f)
      log_to_file(self, id_src_f, "data/id_src_out.float")

      mux_src_f = gr.short_to_float()
      self.connect(mux_src,mux_src_f)
      log_to_file(self, mux_src_f, "data/mux_src_out.float")

      map_src_s = blocks.vector_to_stream(gr.sizeof_char,config.data_subcarriers)
      map_src_f = gr.char_to_float()
      self.connect(map_src,map_src_s,map_src_f)
      ##log_to_file(self, map_src_f, "data/map_src.float")

      ##log_to_file(self, pa_src, "data/pa_src_out.float")

    ## Workaround to avoid periodic structure
    seed(1)
    whitener_pn = [randint(0,1) for i in range(used_id_bits*rep_id_bits)]

    ## ID Encoder
    id_enc = self._id_encoder = repetition_encoder_sb(used_id_bits,rep_id_bits,whitener_pn)
    self.connect(id_src,id_enc)

    if options.log:
      id_enc_f = gr.char_to_float()
      self.connect(id_enc,id_enc_f)
      log_to_file(self, id_enc_f, "data/id_enc_out.float")

    ## Bitmap Update Trigger
    # TODO
    #bmaptrig_stream = concatenate([[1, 2],[0]*(config.frame_data_part-7)])
    bmaptrig_stream = concatenate([[1, 1],[0]*(config.frame_data_part-2)])
    print"bmaptrig_stream = ",bmaptrig_stream
    btrig = self._bitmap_trigger = blocks.vector_source_b(bmaptrig_stream.tolist(), True)
    if options.log:
      log_to_file(self, btrig, "data/bitmap_trig.char")
      
    ## Bitmap Update Trigger for puncturing
    # TODO
    if not options.nopunct:
        #bmaptrig_stream_puncturing = concatenate([[1],[0]*(config.frame_data_part-2)])
        bmaptrig_stream_puncturing = concatenate([[1],[0]*(config.frame_data_blocks/2-1)])
        
        btrig_puncturing = self._bitmap_trigger_puncturing = blocks.vector_source_b(bmaptrig_stream_puncturing.tolist(), True)
        bmapsrc_stream_puncturing = concatenate([[1]*dsubc,[2]*dsubc])
        bsrc_puncturing = self._bitmap_src_puncturing = blocks.vector_source_b(bmapsrc_stream_puncturing.tolist(), True, dsubc)
        
    if options.log and options.coding and not options.nopunct:
      log_to_file(self, btrig_puncturing, "data/bitmap_trig_puncturing.char")

    ## Frame Trigger
    # TODO
    ftrig_stream = concatenate([[1],[0]*(config.frame_data_part-1)])
    ftrig = self._frame_trigger = blocks.vector_source_b(ftrig_stream.tolist(),True)

    ## Data Multiplexer
    # Input 0: control stream
    # Input 1: encoded ID stream
    # Inputs 2..n: data streams
    dmux = self._data_multiplexer = stream_controlled_mux_b()
    self.connect(mux_src,(dmux,0))
    self.connect(id_enc,(dmux,1))
                      
    self._data_multiplexer_nextport = 2

    if options.log:
      dmux_f = gr.char_to_float()
      self.connect(dmux,dmux_f)
      log_to_file(self, dmux_f, "data/dmux_out.float")
      
    ## Modulator
    mod = self._modulator = generic_mapper_bcv(config.data_subcarriers,options.coding)



    self.connect(dmux,(mod,0))
    self.connect(map_src,(mod,1))
    self.connect(btrig,(mod,2))
    
    if options.log:
      log_to_file(self, mod, "data/mod_out.compl")
      modi = gr.complex_to_imag(config.data_subcarriers)
      modr = gr.complex_to_real(config.data_subcarriers)
      self.connect(mod,modi)
      self.connect(mod,modr)
      log_to_file(self, modi, "data/mod_imag_out.float")
      log_to_file(self, modr, "data/mod_real_out.float")



    ## Power allocator
    if options.debug:

      ## static
      pa = self._power_allocator = power_allocator(config.data_subcarriers)
      self.connect(mod,(pa,0))
      self.connect(pa_src,(pa,1))

    else:

      ## with CORBA control event channel
      ns_ip = ctrl.ns_ip
      ns_port = ctrl.ns_port
      evchan = ctrl.evchan
      pa = self._power_allocator = corba_power_allocator(dsubc, \
          evchan, ns_ip, ns_port, True)

      self.connect(mod,(pa,0))
      self.connect(id_src,(pa,1))
      self.connect(ftrig,(pa,2))

    if options.log:
      log_to_file(self, pa, "data/pa_out.compl")



    ## Pilot subcarriers
    psubc = self._pilot_subcarrier_inserter = pilot_subcarrier_inserter()
    self.connect( pa ,psubc )
        
    pilot_subc = config.training_data.shifted_pilot_tones;
    print "pilot_subc", pilot_subc
    stc = stc_encoder( config.subcarriers, config.frame_data_blocks,  pilot_subc )
    
    self.connect(psubc, stc)
    
    if options.log:
      log_to_file(self, psubc, "data/psubc_out.compl")
      log_to_file(self, psubc_2, "data/psubc2_out.compl")
      log_to_file(self, pa, "data/pa.compl")
      log_to_file(self, ( stc, 0 ), "data/stc_0.compl")
      log_to_file(self, ( stc, 1 ), "data/stc_1.compl")

    ## Add virtual subcarriers
    if config.fft_length > config.subcarriers:
      vsubc = self._virtual_subcarrier_extender = \
              vector_padding(config.subcarriers, config.fft_length)
      self.connect(stc,vsubc)
      vsubc_2 = self._virtual_subcarrier_extender_2 = \
              vector_padding(config.subcarriers, config.fft_length)
      self.connect((stc,1),vsubc_2)
    else:
      vsubc = self._virtual_subcarrier_extender = psubc
      vsubc_2 = self._virtual_subcarrier_extender_2 = psubc_2
      
    log_to_file(self, psubc, "data/psubc.compl")
    log_to_file(self, stc, "data/stc1.compl")
    log_to_file(self, (stc,1), "data/stc2.compl")
    if options.log:
      log_to_file(self, vsubc, "data/vsubc_out.compl")
      log_to_file(self, vsubc_2, "data/vsubc2_out.compl")

    
    ## IFFT, no window, block shift
    ifft = self._ifft = fft_blocks.fft_vcc(config.fft_length,False,[],True)
    self.connect(vsubc,ifft)
    ifft_2 = self._ifft_2 = fft_blocks.fft_vcc(config.fft_length,False,[],True)
    self.connect(vsubc_2,ifft_2)

    if options.log:
      log_to_file(self, ifft, "data/ifft_out.compl")
      log_to_file(self, ifft_2, "data/ifft2_out.compl")


    ## Pilot blocks (preambles)
    pblocks = self._pilot_block_inserter = pilot_block_inserter(1, False)
    self.connect( ifft, pblocks )
    pblocks_2 = self._pilot_block_inserter_2 = pilot_block_inserter( 2, False)
    self.connect( ifft_2, pblocks_2 )
    
    if options.log:
      log_to_file(self, pblocks, "data/pilot_block_ins_out.compl")
      log_to_file(self, pblocks_2, "data/pilot_block_ins2_out.compl")
    
    ## Cyclic Prefix
    cp = self._cyclic_prefixer = cyclic_prefixer(config.fft_length,
                                                 config.block_length)
    self.connect( pblocks, cp )
    cp_2 = self._cyclic_prefixer_2 = cyclic_prefixer(config.fft_length,
                                                 config.block_length)
    self.connect( pblocks_2, cp_2 )
    
    lastblock = cp
    lastblock_2 = cp_2

    
    if options.log:
      log_to_file(self, cp, "data/cp_out.compl")
      log_to_file(self, cp_2, "data/cp2_out.compl")


    if options.cheat:
      ## Artificial Channel
      # kept to compare with previous system
      achan_ir = concatenate([[1.0],[0.0]*(config.cp_length-1)])
      achan = self._artificial_channel = gr.fir_filter_ccc(1,achan_ir)
      self.connect( lastblock, achan )
      lastblock = achan
      achan_2 = self._artificial_channel_2 = gr.fir_filter_ccc(1,achan_ir)
      self.connect( lastblock_2, achan_2 )
      lastblock_2 = achan_2


    ## Digital Amplifier
    amp = self._amplifier = ofdm.multiply_const_ccf( 1.0/math.sqrt(2) )
    self.connect( lastblock, amp )
    amp_2 = self._amplifier_2 = ofdm.multiply_const_ccf( 1.0/math.sqrt(2) )
    self.connect( lastblock_2, amp_2 )
    self.set_rms_amplitude(rms_amp)
    
    if options.log:
      log_to_file(self, amp, "data/amp_tx_out.compl")
      log_to_file(self, amp_2, "data/amp_tx2_out.compl")

    ## Setup Output
    self.connect(amp,(self,0))
    self.connect(amp_2,(self,1))

    # ------------------------------------------------------------------------ #

    # Display some information about the setup
    if config._verbose:
      self._print_verbage()