def test_multiply_cc(self):
     src1_data = (1+1j,  2+2j, 3+3j, 4+4j, 5+5j)
     src2_data = (8, -3, 4, 8, 2)
     expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j)
     op = blocks_swig.multiply_cc()
     self.help_cc((src1_data, src2_data),
                   expected_result, op)
Beispiel #2
0
 def test_multiply_cc(self):
     src1_data = (1+1j,  2+2j, 3+3j, 4+4j, 5+5j)
     src2_data = (8, -3, 4, 8, 2)
     expected_result = (8+8j, -6-6j, 12+12j, 32+32j, 10+10j)
     op = blocks.multiply_cc()
     self.help_cc((src1_data, src2_data),
                   expected_result, op)
Beispiel #3
0
    def test_multiply_vcc_five(self):
	src1_data = (1.0+2.0j, 3.0+4.0j, 5.0+6.0j, 7.0+8.0j, 9.0+10.0j)
	src2_data = (11.0+12.0j, 13.0+14.0j, 15.0+16.0j, 17.0+18.0j, 19.0+20.0j)
	src3_data = (21.0+22.0j, 23.0+24.0j, 25.0+26.0j, 27.0+28.0j, 29.0+30.0j)
	expected_result = (-1021.0+428.0j, -2647.0+1754.0j, -4945.0+3704.0j, -8011.0+6374.0j, -11941.0+9860.0j)
	op = blocks.multiply_cc(5)
	self.help_cc(5, (src1_data, src2_data, src3_data), expected_result, op)
Beispiel #4
0
    def test_multiply_vcc_one(self):
	src1_data = (1.0+2.0j,)
	src2_data = (3.0+4.0j,)
	src3_data = (5.0+6.0j,)
	expected_result = (-85+20j,)
	op = blocks.multiply_cc(1)
	self.help_cc(1, (src1_data, src2_data, src3_data), expected_result, op)
Beispiel #5
0
 def test_004_connect (self):
     """
     Advanced test:
     - Allocator -> IFFT -> Frequency offset -> FFT -> Serializer
     - FFT does shift (moves DC to middle)
     - Make sure input == output
     - Frequency offset is -2 carriers
     """
     fft_len = 8
     n_syms = 1
     carr_offset = -2
     freq_offset = 1.0 / fft_len * carr_offset # Normalized frequency
     occupied_carriers = ((-2, -1, 1, 2),)
     pilot_carriers = ((-3,),(3,))
     pilot_symbols = ((1j,),(-1j,))
     tx_data = (1, 2, 3, 4)
     tag_name = "len"
     tag = gr.tag_t()
     tag.offset = 0
     tag.key = pmt.string_to_symbol(tag_name)
     tag.value = pmt.from_long(len(tx_data))
     offsettag = gr.tag_t()
     offsettag.offset = 0
     offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset")
     offsettag.value = pmt.from_long(carr_offset)
     src = blocks.vector_source_c(tx_data, False, 1, (tag, offsettag))
     alloc = digital.ofdm_carrier_allocator_cvc(fft_len,
                    occupied_carriers,
                    pilot_carriers,
                    pilot_symbols, (),
                    tag_name)
     tx_ifft = fft.fft_vcc(fft_len, False, (1.0/fft_len,)*fft_len, True)
     oscillator = analog.sig_source_c(1.0, analog.GR_COS_WAVE, freq_offset, 1.0/fft_len)
     mixer = blocks.multiply_cc()
     rx_fft  = fft.fft_vcc(fft_len, True, (), True)
     sink2 = blocks.vector_sink_c(fft_len)
     self.tb.connect(rx_fft, sink2)
     serializer = digital.ofdm_serializer_vcc(
             alloc, "", 0, "ofdm_sync_carr_offset", True
     )
     sink = blocks.vector_sink_c()
     self.tb.connect(
             src, alloc, tx_ifft,
             blocks.vector_to_stream(gr.sizeof_gr_complex, fft_len),
             (mixer, 0),
             blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len),
             rx_fft, serializer, sink
     )
     self.tb.connect(oscillator, (mixer, 1))
     self.tb.run ()
     self.assertComplexTuplesAlmostEqual(sink.data()[-len(occupied_carriers[0]):], tx_data, places=4)
Beispiel #6
0
    def test01(self):
        sps = 4
        rolloff = 0.35
        bw = 2 * math.pi / 100.0
        ntaps = 45

        # Create pulse shape filter
        rrc_taps = filter.firdes.root_raised_cosine(sps, sps, 1.0, rolloff,
                                                    ntaps)

        # The frequency offset to correct
        foffset = 0.2 / (2.0 * math.pi)

        # Create a set of 1's and -1's, pulse shape and interpolate to sps
        random.seed(0)
        data = [2.0 * random.randint(0, 2) - 1.0 for i in xrange(200)]
        self.src = blocks.vector_source_c(data, False)
        self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)

        # Mix symbols with a complex sinusoid to spin them
        self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1)
        self.mix = blocks.multiply_cc()

        # FLL will despin the symbols to an arbitrary phase
        self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw)

        # Create sinks for all outputs of the FLL
        # we will only care about the freq and error outputs
        self.vsnk_frq = blocks.vector_sink_f()
        self.nsnk_fll = blocks.null_sink(gr.sizeof_gr_complex)
        self.nsnk_phs = blocks.null_sink(gr.sizeof_float)
        self.nsnk_err = blocks.null_sink(gr.sizeof_float)

        # Connect the blocks
        self.tb.connect(self.nco, (self.mix, 1))
        self.tb.connect(self.src, self.rrc, (self.mix, 0))
        self.tb.connect(self.mix, self.fll, self.nsnk_fll)
        self.tb.connect((self.fll, 1), self.vsnk_frq)
        self.tb.connect((self.fll, 2), self.nsnk_phs)
        self.tb.connect((self.fll, 3), self.nsnk_err)
        self.tb.run()

        N = 700
        dst_data = self.vsnk_frq.data()[N:]

        expected_result = len(dst_data) * [
            -0.20,
        ]
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
    def test01(self):
        sps = 4
        rolloff = 0.35
        bw = 2 * math.pi / 100.0
        ntaps = 45

        # Create pulse shape filter
        rrc_taps = filter.firdes.root_raised_cosine(sps, sps, 1.0, rolloff, ntaps)

        # The frequency offset to correct
        foffset = 0.2 / (2.0 * math.pi)

        # Create a set of 1's and -1's, pulse shape and interpolate to sps
        random.seed(0)
        data = [2.0 * random.randint(0, 2) - 1.0 for i in xrange(200)]
        self.src = blocks.vector_source_c(data, False)
        self.rrc = filter.interp_fir_filter_ccf(sps, rrc_taps)

        # Mix symbols with a complex sinusoid to spin them
        self.nco = analog.sig_source_c(1, analog.GR_SIN_WAVE, foffset, 1)
        self.mix = blocks.multiply_cc()

        # FLL will despin the symbols to an arbitrary phase
        self.fll = digital.fll_band_edge_cc(sps, rolloff, ntaps, bw)

        # Create sinks for all outputs of the FLL
        # we will only care about the freq and error outputs
        self.vsnk_frq = blocks.vector_sink_f()
        self.nsnk_fll = blocks.null_sink(gr.sizeof_gr_complex)
        self.nsnk_phs = blocks.null_sink(gr.sizeof_float)
        self.nsnk_err = blocks.null_sink(gr.sizeof_float)

        # Connect the blocks
        self.tb.connect(self.nco, (self.mix, 1))
        self.tb.connect(self.src, self.rrc, (self.mix, 0))
        self.tb.connect(self.mix, self.fll, self.nsnk_fll)
        self.tb.connect((self.fll, 1), self.vsnk_frq)
        self.tb.connect((self.fll, 2), self.nsnk_phs)
        self.tb.connect((self.fll, 3), self.nsnk_err)
        self.tb.run()

        N = 700
        dst_data = self.vsnk_frq.data()[N:]

        expected_result = len(dst_data) * [-0.20]
        self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 4)
Beispiel #8
0
    def __init__(self, noise_voltage, freq, timing):
        gr.hier_block2.__init__(self, "channel_model",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        timing_offset = filter.fractional_resampler_cc(0, timing)
        noise_adder = blocks.add_cc()
        noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_voltage, 0)
        freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE, freq, 1.0,
                                          0.0)
        mixer_offset = blocks.multiply_cc()

        self.connect(self, timing_offset)
        self.connect(timing_offset, (mixer_offset, 0))
        self.connect(freq_offset, (mixer_offset, 1))
        self.connect(mixer_offset, (noise_adder, 1))
        self.connect(noise, (noise_adder, 0))
        self.connect(noise_adder, self)
    def __init__(self, noise_voltage, freq, timing):
        gr.hier_block2.__init__(
            self,
            "channel_model",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
        )

        timing_offset = filter.fractional_interpolator_cc(0, timing)
        noise_adder = blocks.add_cc()
        noise = analog.noise_source_c(analog.GR_GAUSSIAN, noise_voltage, 0)
        freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE, freq, 1.0, 0.0)
        mixer_offset = blocks.multiply_cc()

        self.connect(self, timing_offset)
        self.connect(timing_offset, (mixer_offset, 0))
        self.connect(freq_offset, (mixer_offset, 1))
        self.connect(mixer_offset, (noise_adder, 1))
        self.connect(noise, (noise_adder, 0))
        self.connect(noise_adder, self)