def test_001_t(self):
        # set up fg
        n_frames = 3
        active_subcarriers = 110
        subcarriers = 128
        timeslots = 205
        smap = np.arange(active_subcarriers) + (subcarriers -
                                                active_subcarriers) // 2

        data = get_random_qpsk(active_subcarriers * timeslots)
        ref = map_to_waveform_resources(data, active_subcarriers, subcarriers,
                                        smap, True)
        for i in range(n_frames - 1):
            d = get_random_qpsk(active_subcarriers * timeslots)
            data = np.concatenate((data, d))
            ref = np.concatenate(
                (ref,
                 map_to_waveform_resources(d, active_subcarriers, subcarriers,
                                           smap, True)))

        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(timeslots, subcarriers,
                                         active_subcarriers, smap, True)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, mapper, snk)
        self.tb.run()
        # check data
        res = snk.data()
        self.assertComplexTuplesAlmostEqual(ref, res)
Beispiel #2
0
    def test_003_demap_timeslots(self):
        timeslots = 15
        subcarriers = 32
        active_subcarriers = 24
        subcarrier_map = get_subcarrier_map(subcarriers,
                                            active_subcarriers,
                                            True)
        # subcarrier_map = np.arange(4, 28, dtype=np.int)
        mapper = Resource_mapper(timeslots, subcarriers,
                                 active_subcarriers,
                                 subcarrier_map,
                                 True)

        self.assertEqual(mapper.block_size(),
                         timeslots * active_subcarriers)
        self.assertEqual(mapper.frame_size(),
                         timeslots * subcarriers)

        d = np.arange(timeslots * active_subcarriers,
                      dtype=np.complex64) + 1

        ref = map_to_waveform_resources(d, active_subcarriers,
                                        subcarriers,
                                        subcarrier_map,
                                        True)
        f = mapper.demap_from_resources(ref)
        self.assertComplexTuplesAlmostEqual(f, d)
Beispiel #3
0
    def test_001_t(self):
        np.set_printoptions(precision=2)
        n_frames = 7
        alpha = .5
        active_subcarriers = 52
        timeslots = 9
        subcarriers = 64
        overlap = 2
        cp_len = 8
        cs_len = 4
        ramp_len = 4

        window_len = get_window_len(cp_len, timeslots, subcarriers, cs_len)
        taps = get_frequency_domain_filter('rrc', alpha, timeslots,
                                           subcarriers, overlap)
        # taps /= np.sqrt(calculate_signal_energy(taps) / time)
        window_taps = get_raised_cosine_ramp(ramp_len, window_len)
        pn_symbols = get_random_qpsk(subcarriers)
        H_preamble = get_frequency_domain_filter('rrc', alpha, 2,
                                                 subcarriers, overlap)
        preamble = get_sync_symbol(pn_symbols, H_preamble, subcarriers,
                                   overlap, cp_len, ramp_len)[0]
        smap = get_subcarrier_map(subcarriers, active_subcarriers, True)

        ref = np.array([], dtype=np.complex)
        data = np.array([], dtype=np.complex)

        for i in range(n_frames):
            d = get_random_qpsk(active_subcarriers * timeslots)
            dd = map_to_waveform_resources(d, active_subcarriers,
                                           subcarriers, smap)
            D = get_data_matrix(dd, subcarriers, group_by_subcarrier=False)
            b = gfdm_modulate_block(D, taps, timeslots, subcarriers,
                                    overlap, False)
            b = add_cyclic_starfix(b, cp_len, cs_len)
            b = pinch_block(b, window_taps)
            ref = np.concatenate((ref, preamble, b))
            data = np.concatenate((data, d))

        src = blocks.vector_source_c(data)
        dut = gfdm.transmitter_cc(timeslots, subcarriers, active_subcarriers,
                                  cp_len, cs_len, ramp_len, smap, True,
                                  overlap, taps, window_taps, preamble, "packet_len")
        dst = blocks.vector_sink_c()

        self.tb.connect(src, dut, dst)
        self.tb.run()
        res = np.array(dst.data())[0:len(ref)]
        self.assertComplexTuplesAlmostEqual(ref, res, 5)

        tags = dst.tags()
        for t in tags:
            print(t.offset, t.value)
    def test_001_t(self):
        np.set_printoptions(precision=2)
        n_frames = 3
        alpha = .5
        active = 8
        M = 8
        K = 16
        L = 2
        cp_len = 8
        cs_len = 4
        ramp_len = 4
        block_len = M * K
        window_len = get_window_len(cp_len, M, K, cs_len)
        taps = get_frequency_domain_filter('rrc', alpha, M, K, L)
        taps /= np.sqrt(calculate_signal_energy(taps) / M)
        window_taps = get_raised_cosine_ramp(ramp_len, window_len)
        pn_symbols = get_random_qpsk(K)
        H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L)
        preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len,
                                   ramp_len)[0]
        smap = get_subcarrier_map(K, active, dc_free=True)

        ref = np.array([], dtype=complex)
        data = np.array([], dtype=complex)
        frame_len = window_len + len(preamble)
        frame_gap = np.zeros(frame_len)
        for i in range(n_frames):
            d = get_random_qpsk(active * M)
            dd = map_to_waveform_resources(d, active, K, smap)
            D = get_data_matrix(dd, K, group_by_subcarrier=False)
            b = gfdm_modulate_block(D, taps, M, K, L, False)
            b = add_cyclic_starfix(b, cp_len, cs_len)
            b = pinch_block(b, window_taps)
            ref = np.concatenate((ref, frame_gap, preamble, b))
            data = np.concatenate((data, d))

        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(active, K, M, smap, True)
        mod = gfdm.simple_modulator_cc(M, K, L, taps)
        prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len,
                                           window_taps)
        preambler = blocks.vector_insert_c(preamble,
                                           window_len + len(preamble), 0)
        gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap),
                                        0)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst)
        # self.tb.connect(src, mapper, dst)
        self.tb.run()
        res = np.array(dst.data())[0:len(ref)]

        self.assertComplexTuplesAlmostEqual(ref, res, 5)
Beispiel #5
0
def generate_reference_frame(symbols, timeslots, subcarriers, active_subcarriers, subcarrier_map,
                             taps, overlap, cp_len, cs_len, window_taps, cyclic_shifts, preambles):
    dd = map_to_waveform_resources(symbols, active_subcarriers,
                                   subcarriers, subcarrier_map)
    D = get_data_matrix(dd, subcarriers, group_by_subcarrier=False)
    b = gfdm_modulate_block(D, taps, timeslots, subcarriers,
                            overlap, False)
    frame = []
    for cs, p in zip(cyclic_shifts, preambles):
        data = np.roll(b, cs)
        data = add_cyclic_starfix(data, cp_len, cs_len)
        data = pinch_block(data, window_taps)
        frame.append(np.concatenate((p, data)))
    return frame
    def test_001_t(self):
        # set up fg
        n_frames = 3
        active_subcarriers = 110
        subcarriers = 128
        timeslots = 205
        smap = np.arange(active_subcarriers) + (subcarriers - active_subcarriers) // 2

        data = get_random_qpsk(active_subcarriers * timeslots)
        ref = map_to_waveform_resources(data, active_subcarriers, subcarriers, smap, True)
        for i in range(n_frames - 1):
            d = get_random_qpsk(active_subcarriers * timeslots)
            data = np.concatenate((data, d))
            ref = np.concatenate((ref, map_to_waveform_resources(d, active_subcarriers, subcarriers, smap, True)))

        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(timeslots, subcarriers, active_subcarriers, smap, True)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, mapper, snk)
        self.tb.run()
        # check data
        res = snk.data()
        self.assertComplexTuplesAlmostEqual(ref, res)
    def test_001_t(self):
        np.set_printoptions(precision=2)
        n_frames = 3
        alpha = .5
        active = 8
        M = 8
        K = 16
        L = 2
        cp_len = 8
        cs_len = 4
        ramp_len = 4
        block_len = M * K
        window_len = get_window_len(cp_len, M, K, cs_len)
        taps = get_frequency_domain_filter('rrc', alpha, M, K, L)
        taps /= np.sqrt(calculate_signal_energy(taps) / M)
        window_taps = get_raised_cosine_ramp(ramp_len, window_len)
        pn_symbols = get_random_qpsk(K)
        H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L)
        preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len, ramp_len)[0]
        smap = get_subcarrier_map(K, active, dc_free=True)

        ref = np.array([], dtype=np.complex)
        data = np.array([], dtype=np.complex)
        frame_len = window_len + len(preamble)
        frame_gap = np.zeros(frame_len)
        for i in range(n_frames):
            d = get_random_qpsk(active * M)
            dd = map_to_waveform_resources(d, active, K, smap)
            D = get_data_matrix(dd, K, group_by_subcarrier=False)
            b = gfdm_modulate_block(D, taps, M, K, L, False)
            b = add_cyclic_starfix(b, cp_len, cs_len)
            b = pinch_block(b, window_taps)
            ref = np.concatenate((ref, frame_gap, preamble, b))
            data = np.concatenate((data, d))

        src = blocks.vector_source_c(data)
        mapper = gfdm.resource_mapper_cc(active, K, M, smap, True)
        mod = gfdm.simple_modulator_cc(M, K, L, taps)
        prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len, window_taps)
        preambler = blocks.vector_insert_c(preamble, window_len + len(preamble), 0)
        gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap), 0)
        dst = blocks.vector_sink_c()

        self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst)
        # self.tb.connect(src, mapper, dst)
        self.tb.run()
        res = np.array(dst.data())[0:len(ref)]

        self.assertComplexTuplesAlmostEqual(ref, res, 5)
Beispiel #8
0
    def test_002_map_subcarriers(self):
        timeslots = 15
        subcarriers = 32
        active_subcarriers = 24
        subcarrier_map = np.arange(4, 28, dtype=int)
        mapper = Resource_mapper(timeslots, subcarriers, active_subcarriers,
                                 subcarrier_map, False)

        self.assertEqual(mapper.block_size(), timeslots * active_subcarriers)
        self.assertEqual(mapper.frame_size(), timeslots * subcarriers)

        d = np.arange(timeslots * active_subcarriers, dtype=np.complex64) + 1
        f = mapper.map_to_resources(d)
        ref = map_to_waveform_resources(d, active_subcarriers, subcarriers,
                                        subcarrier_map, False)
        self.assertComplexTuplesAlmostEqual(f, ref)