Ejemplo n.º 1
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = tuple(lte_test.encode_bch(mib, N_ant))
        p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
        p_scrambled = lte_test.nrz_encoding(p_scrambled)
        n_bch = tuple(lte_test.nrz_encoding(bch))

        self.src.set_data(p_scrambled[0:480])
        self.descr.set_cell_id(cell_id)

        # set up fg
        self.tb.run()
        res = self.snk.data()

        count = 0
        for i in range(len(res) / len(n_bch)):
            part = res[len(n_bch) * i : (i + 1) * len(n_bch)]
            try:
                self.assertEqual(part, n_bch, 3)
                print str(i) + "\tSUCCESS"
            except:
                print str(i)
                count = count + 1
        print "\nresult"
        print count
        print len(res) / len(n_bch)
Ejemplo n.º 2
0
    def test_003_data_gen(self):
        N_rb_dl = self.N_rb_dl
        subcarriers = self.subcarriers
        N_ofdm_symbols = self.N_ofdm_symbols
        tag_key = self.tag_key
        msg_buf_name = self.msg_buf_name
        cell_id = 124
        Ncp = 1
        N_ant = 2
        style = "tx_diversity"
        sfn = 0
        srcid = "source"

        nf = 4
        data = []
        for sfn in range(nf):
            mib = lte_test.pack_mib(N_rb_dl, 0, 1.0, sfn)
            bch = lte_test.encode_bch(mib, N_ant)
            pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)
            frame = lte_test.generate_phy_frame(cell_id, N_rb_dl, N_ant)
            for p in range(len(frame)):
                frame[p] = lte_test.map_pbch_to_frame_layer(
                    frame[p], pbch[p], cell_id, sfn, p)

            stream = frame[0].flatten().tolist()
            stream = np.add(stream, frame[1].flatten().tolist())
            data.extend(stream)
        print len(data)

        tags = lte_test.get_tag_list(140 * nf, 140, self.tag_key, srcid)

        tb2 = gr.top_block()
        src = blocks.vector_source_c(data, False, subcarriers)
        tb2.run()
Ejemplo n.º 3
0
    def test_001_t (self):
        print "Viterbi decoder test"
        test_range = 1030
        
        data = []
        my_input = []
        for sfn in range(test_range):
            mib = lte_test.pack_mib(50,0,1.0, sfn%1024 )
            mib_crc = lte_test.crc_checksum(mib, 2)
            my_input.extend(mib_crc)
            c_encoded = lte_test.convolutional_encoder(mib_crc)
            nrz_encoded = lte_test.nrz_encoding(c_encoded)
            data.extend(nrz_encoded)

        self.src.set_data(data)
        self.tb.run ()
        
        count = 0
        res = self.snk.data()
        for i in range(test_range):
            try:
                self.assertEqual(tuple(my_input[i*40:(i+1)*40]), res[i*40:(i+1)*40])
                print "SUCCESS " + str(i)
                count = count+1
            except:
                print "FAILED  " + str(i)
     
        print (float(count)/float(test_range))        
        print "Viterbi decoder test END"
Ejemplo n.º 4
0
    def test_001_t (self):
        print "Viterbi decoder test"
        test_range = 1030
        
        data = []
        my_input = []
        for sfn in range(test_range):
            mib = lte_test.pack_mib(50,0,1.0, sfn%1024 )
            mib_crc = lte_test.crc_checksum(mib, 2)
            my_input.extend(mib_crc)
            c_encoded = lte_test.convolutional_encoder(mib_crc)
            nrz_encoded = lte_test.nrz_encoding(c_encoded)
            data.extend(nrz_encoded)

        self.src.set_data(data)
        self.tb.run ()
        
        count = 0
        res = self.snk.data()
        for i in range(test_range):
            try:
                self.assertEqual(tuple(my_input[i*40:(i+1)*40]), res[i*40:(i+1)*40])
#                print "SUCCESS " + str(i)
                count = count+1
            except:
                pass
#                print "FAILED  " + str(i)
     
        rate = float(count)/float(test_range)  
        print (rate)
        if not rate == 1.0:
            self.assertEqual( [1] , [0] ) #throws always n error
        print "Viterbi decoder test END"
Ejemplo n.º 5
0
    def test_001_generated(self):
        print "\ntest_001_generated"
        cell_id = 124
        N_ant = 2
        style = "tx_diversity"
        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = lte_test.encode_bch(mib, N_ant)

        scrambled = lte_test.pbch_scrambling(bch, cell_id)
        qpsk_modulated = lte_test.qpsk_modulation(scrambled)
        #print np.shape(qpsk_modulated)
        layer_mapped = lte_test.layer_mapping(qpsk_modulated, N_ant, style)
        pre_coded = lte_test.pre_coding(layer_mapped, N_ant, style)
        #print np.shape(pre_coded)

        h0 = [complex(1, 0)] * len(pre_coded[0])
        h1 = [complex(1, 0)] * len(pre_coded[1])
        stream = [pre_coded[0][i] + pre_coded[1][i] for i in range(len(pre_coded[0]))]

        self.src1.set_data(stream)
        self.src2.set_data(h0)
        self.src3.set_data(h1)
        self.tb.run()
        res = self.snk.data()

        exp_res = []
        for i in range(len(stream) / 240):
            print i
            lay0 = layer_mapped[0][i * 120:(i + 1) * 120]
            lay1 = layer_mapped[1][i * 120:(i + 1) * 120]
            comb = [lay0, lay1]
            exp_res.extend(lte_test.prepare_for_demapper_block(comb, N_ant, style))

        print "test 001 final ASSERT!"
        print self.assertComplexTuplesAlmostEqual(res, exp_res)
Ejemplo n.º 6
0
    def test_003_data_gen(self):
        N_rb_dl = self.N_rb_dl
        subcarriers = self.subcarriers
        N_ofdm_symbols = self.N_ofdm_symbols
        tag_key = self.tag_key
        msg_buf_name = self.msg_buf_name
        cell_id = 124
        Ncp = 1
        N_ant = 2
        style= "tx_diversity"
        sfn = 0
        srcid = "source"

        nf = 4
        data = []
        for sfn in range(nf):
            mib = lte_test.pack_mib(N_rb_dl, 0, 1.0, sfn)
            bch = lte_test.encode_bch(mib, N_ant)
            pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)
            frame = lte_test.generate_phy_frame(cell_id, N_rb_dl, N_ant)
            for p in range(len(frame)):
                frame[p] = lte_test.map_pbch_to_frame_layer(frame[p], pbch[p], cell_id, sfn, p)

            stream = frame[0].flatten().tolist()
            stream = np.add(stream, frame[1].flatten().tolist() )
            data.extend(stream)
        print len(data)

        tags = lte_test.get_tag_list(140 * nf, 140, self.tag_key, srcid)

        tb2 = gr.top_block ()
        src = blocks.vector_source_c(data, False, subcarriers)
        dbg = blocks.file_sink(gr.sizeof_gr_complex * 12*N_rb_dl, "/home/johannes/tests/est_frame_data.dat")
        tb2.connect(src, dbg)
        tb2.run()
Ejemplo n.º 7
0
    def test_001_t (self):
            
        N_ant = [1,2,3,4]
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        sfn = 511
        mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, sfn)
        input_data = []
        for i in N_ant:
            mib_crc = lte_test.crc_checksum(mib, i)
            input_data.extend(mib_crc)
        
        self.src.set_data(input_data)

        # set up fg
        self.tb.run ()
        # check data
        res0 = self.snk.data()
        res0 = tuple([int(i) for i in res0]) # just to ensure data types
        res1 = self.snk2.data()
        for i in range(4):
            try:
                self.assertEqual(tuple(mib),res0[i*24:(i+1)*24])
                self.assertEqual(N_ant[i], res1[i])
            except:
                print res0[i*24:(i+1)*24]
                print "result = " + str(res1[i]) + "\tinput = " + str(N_ant[i])

            

        print "qa_crc_calculator_vbvb END"
Ejemplo n.º 8
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        tl = 1024
        data = []
        input_data = []
        for i in range(tl / 4):
            mib = lte_test.pack_mib(50, 0, 1.0, i * 4)
            bch = tuple(lte_test.encode_bch(mib, N_ant))
            p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
            input_data.extend(lte_test.nrz_encoding(p_scrambled))
            mod = lte_test.qpsk_modulation(p_scrambled)
            data.extend(mod)

        self.src.set_data(data)

        dbgs = blocks.file_sink(240 * gr.sizeof_gr_complex,
                                "/home/johannes/tests/demodulate.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run()
        # check data
        res = self.snk.data()
        exp_res = tuple(
            input_data
        )  #tuple([input_data[i]/math.sqrt(2) for i in range(len(input_data))])
        print self.assertFloatTuplesAlmostEqual(res, exp_res, 5)
Ejemplo n.º 9
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        style = "tx_diversity"
        N_rb_dl = self.N_rb_dl
        sim_frames = 4
        self.demux.set_cell_id(cell_id)
        sfn = 512
        mib = lte_test.pack_mib(N_rb_dl, 0, 1.0, sfn)
        bch = lte_test.encode_bch(mib, N_ant)
        pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)

        stream = []
        #for i in range(sim_frames):
        #    frame = lte_test.generate_frame(pbch, N_rb_dl, cell_id, i+20, N_ant)
        #    stream.extend(frame[0].flatten())
        #
        #print len(stream)
        for i in range(sim_frames):
            frame = lte_test.generate_phy_frame(cell_id, N_rb_dl, N_ant)
            for p in range(len(frame)):
                frame[p] = lte_test.map_pbch_to_frame_layer(
                    frame[p], pbch[p], cell_id, sfn + i, p)
            stream.extend(frame[0].flatten().tolist())

        key = self.key
        srcid = "source"
        tags = lte_test.get_tag_list(140 * sim_frames, 140, key, srcid)

        self.src1.set_data(stream, tuple(tags))
        self.dbg = blocks.file_sink(gr.sizeof_gr_complex * 12 * N_rb_dl,
                                    "/home/johannes/tests/pbch_frame.dat")
        self.tb.connect(self.src1, self.dbg)
        # set up fg
        self.tb.run()
        # check data
        res1 = self.snk1.data()
        #res2 = self.snk2.data()
        #res3 = self.snk3.data()

        print len(res1)
        compare = res1[0:len(pbch[0])]

        #'''
        #partl = 10
        #for i in range(len(res1)/partl):
        #    partres = compare[partl*i:partl*(i+1)]
        #    partcom = pbch[0][partl*i:partl*(i+1)]
        #    try:
        #        self.assertComplexTuplesAlmostEqual(partcom,partres)
        #        print str(i*partl) + "\tsuccess"
        #    except:
        #        #print "\n\n\n\n\n\n"
        #        print str(i*partl) + "\t" + str(partres)
        #'''

        self.assertComplexTuplesAlmostEqual(compare,
                                            tuple(pbch[0][0:len(compare)]))
Ejemplo n.º 10
0
    def test_001_t (self):
        cell_id = 124
        N_ant = 2
        style= "tx_diversity"
        N_rb_dl = self.N_rb_dl
        sim_frames = 4
        self.demux.set_cell_id(cell_id)
        sfn = 512
        mib = lte_test.pack_mib(N_rb_dl, 0, 1.0, sfn)
        bch = lte_test.encode_bch(mib, N_ant)
        pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)

        stream = []
        #for i in range(sim_frames):
        #    frame = lte_test.generate_frame(pbch, N_rb_dl, cell_id, i+20, N_ant)
        #    stream.extend(frame[0].flatten())
        #
        #print len(stream)
        for i in range(sim_frames):
            frame = lte_test.generate_phy_frame(cell_id, N_rb_dl, N_ant)
            for p in range(len(frame)):
                frame[p] = lte_test.map_pbch_to_frame_layer(frame[p], pbch[p], cell_id, sfn+i, p)
            stream.extend(frame[0].flatten().tolist() )

        key = self.key
        srcid = "source"
        tags = lte_test.get_tag_list(140 * sim_frames, 140, key, srcid)

        self.src1.set_data(stream, tuple(tags))
        self.dbg = blocks.file_sink(gr.sizeof_gr_complex * 12*N_rb_dl, "/home/johannes/tests/pbch_frame.dat")
        self.tb.connect(self.src1, self.dbg)
        # set up fg
        self.tb.run ()
        # check data
        res1 = self.snk1.data()
        #res2 = self.snk2.data()
        #res3 = self.snk3.data()

        print len(res1)
        compare = res1[0:len(pbch[0])]

        #'''
        #partl = 10
        #for i in range(len(res1)/partl):
        #    partres = compare[partl*i:partl*(i+1)]
        #    partcom = pbch[0][partl*i:partl*(i+1)]
        #    try:
        #        self.assertComplexTuplesAlmostEqual(partcom,partres)
        #        print str(i*partl) + "\tsuccess"
        #    except:
        #        #print "\n\n\n\n\n\n"
        #        print str(i*partl) + "\t" + str(partres)
        #'''

        self.assertComplexTuplesAlmostEqual(compare, tuple(pbch[0][0:len(compare)]))
Ejemplo n.º 11
0
 def test_001_t (self):
     N_ant = 4    
     mib = lte_test.pack_mib(50,0,1.0, 511)
     bch = lte_test.encode_bch(mib, N_ant)
     bch = lte_test.nrz_encoding(bch)
     self.src.set_data(bch)
     # set up fg
     self.tb.run ()
     # check data
     res0 = self.snk0.data()
     res1 = self.snk1.data()
     print self.assertEqual(res0, tuple(mib))
     print self.assertEqual(res1, tuple([N_ant]))
Ejemplo n.º 12
0
    def setUp (self):
        self.tb = gr.top_block ()
        
        mib = lte_test.pack_mib(50,0,1.0, 511)
        mib_crc = lte_test.crc_checksum(mib, 2)
        c_encoded = lte_test.convolutional_encoder(mib_crc)
        data = lte_test.nrz_encoding(c_encoded)

        self.src = gr.vector_source_f(data,False, 120)
        self.vit = lte.viterbi_vfvb()
        self.snk = gr.vector_sink_b(40)
        
        # connecting blocks
        self.tb.connect(self.src,self.vit, self.snk)
Ejemplo n.º 13
0
    def setUp (self):
        self.tb = gr.top_block ()
        
        mib = lte_test.pack_mib(50,0,1.0, 511)
        mib_crc = lte_test.crc_checksum(mib, 2)
        c_encoded = lte_test.convolutional_encoder(mib_crc)
        data = lte_test.nrz_encoding(c_encoded)

        self.src = blocks.vector_source_f(data,False, 120)
        self.vit = bch_viterbi_vfvb()
        self.snk = blocks.vector_sink_b(40)
        
        # connecting blocks
        self.tb.connect(self.src,self.vit, self.snk)
Ejemplo n.º 14
0
 def test_001_t (self):
     test_len = 1030
     N_ant = 2
     N_rb_dl = 50
     phich_dur = 0
     phich_res = 1.0
     input_data = []
     input_ant_data = []
     for sfn in range(test_len):
         input_data.extend(lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, sfn))
         input_ant_data.append(N_ant)
     
     self.src1.set_data(input_data)
     self.src2.set_data(input_ant_data)
     # set up fg
     self.tb.run ()
Ejemplo n.º 15
0
 def test_001_t (self):
     print "demodulation test"
     mib = lte_test.pack_mib(50,0,1.0, 511)   
     bch = lte_test.encode_bch(mib, 2)
     p_scrambled = lte_test.pbch_scrambling(bch, 124)
     input_data = p_scrambled#[0:480]
     qpsk_mod = lte_test.qpsk_modulation(input_data)
     input_data = lte_test.nrz_encoding(input_data)
     
     self.src.set_data(qpsk_mod)
     # set up fg
     self.tb.run ()
     # check data
     res = self.snk.data()
     exp_res = tuple(input_data)#tuple([input_data[i]/math.sqrt(2) for i in range(len(input_data))])
     print self.assertFloatTuplesAlmostEqual(res, exp_res, 5)
Ejemplo n.º 16
0
    def setUp(self):
        self.tb = gr.top_block()
        # setup some dummy data before block instatiation
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        sfn = 412
        mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, sfn)
        N_ant = range(1)
        N_ant[0] = 2
        self.src1 = blocks.vector_source_b(mib, False, 24)
        self.src2 = blocks.vector_source_b(N_ant, False, 1)

        self.mib = lte.mib_unpack_vbm()

        self.tb.connect(self.src1, (self.mib, 0))
        self.tb.connect(self.src2, (self.mib, 1))
Ejemplo n.º 17
0
    def setUp (self):
        self.tb = gr.top_block ()
        
        mib = lte_test.pack_mib(50,0,1.0, 511)
        mib_crc = lte_test.crc_checksum(mib, 2)
        c_encoded = lte_test.convolutional_encoder(mib_crc)
        data = lte_test.nrz_encoding(c_encoded)

        self.src = blocks.vector_source_f(data,False, 120)
        self.vit = bch_viterbi_vfvb()
        self.snk = blocks.vector_sink_b(40)
        
        self.dbgs = blocks.file_sink(120 * gr.sizeof_float, "/home/johannes/tests/viterbi.dat")
        self.tb.connect(self.src, self.dbgs)
        
        # connecting blocks
        self.tb.connect(self.src,self.vit, self.snk)
Ejemplo n.º 18
0
    def setUp(self):
        self.tb = gr.top_block()
        # setup some dummy data before block instatiation
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        sfn = 412
        mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, sfn)
        N_ant = range(1)
        N_ant[0] = 2
        self.src1 = gr.vector_source_b(mib, False, 24)
        self.src2 = gr.vector_source_b(N_ant, False, 1)

        self.mib = lte_swig.mib_unpack_vb()

        self.tb.connect(self.src1, (self.mib, 0))
        self.tb.connect(self.src2, (self.mib, 1))
Ejemplo n.º 19
0
    def test_001_t(self):
        test_len = 1030
        N_ant = 2
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        input_data = []
        input_ant_data = []
        for sfn in range(test_len):
            input_data.extend(
                lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, sfn))
            input_ant_data.append(N_ant)

        self.src1.set_data(input_data)
        self.src2.set_data(input_ant_data)
        # set up fg
        self.tb.run()
Ejemplo n.º 20
0
    def test_002_data(self):
        cell_id = 124
        N_ant = 2
        tl = 1024
        data = []
        for i in range(tl/4):
            mib = lte_test.pack_mib(50,0,1.0, i*4)
            bch = tuple(lte_test.encode_bch(mib, N_ant))
            p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
            p_scrambled = lte_test.nrz_encoding(p_scrambled)
            data.extend(p_scrambled)

        self.src.set_data(data)
        dbgs = blocks.file_sink(480 * gr.sizeof_float, "/home/johannes/tests/descramble.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run ()
        pass
 def test_002_t(self):
     self.tb2 = gr.top_block()
     N_rb_dl = 50
     phich_dur = 0
     phich_res = 1.0
     N_ant = 2
     data = []
     test_len = 100
     my_res = []
     for i in range(test_len):
         mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i)
         crc = lte_test.crc_checksum(mib, N_ant)
         conv = lte_test.convolutional_encoder_sorted(crc)
         convit = lte_test.convolutional_encoder(crc)
         my_res.extend(lte_test.nrz_encoding(convit) )
         rated = lte_test.rate_match(conv)
         nrz = lte_test.nrz_encoding(rated)
         data.extend(nrz)
     
     srcf = blocks.vector_source_f(data, False, 120)
     snkf = blocks.file_sink(gr.sizeof_float*120, "/home/johannes/tests/rated.dat")
     self.tb2.connect(srcf, snkf)
     
     src1 = blocks.vector_source_f(data, False, 120)
             
     vts0 = blocks.vector_to_stream(40*gr.sizeof_float, 3)
     sts0 = blocks.stream_to_streams(40*gr.sizeof_float, 3)        
     self.tb2.connect(src1, vts0, sts0)
     
     
     inter = blocks.interleave(gr.sizeof_float)
     for i in range(3):
         deint = lte.subblock_deinterleaver_vfvf(40, 1)
         vts1 = blocks.vector_to_stream(1*gr.sizeof_float, 40)
         self.tb2.connect( (sts0, i), deint, vts1, (inter, i))
     stv = blocks.stream_to_vector(1*gr.sizeof_float, 120)
     snk = blocks.vector_sink_f(120)        
     self.tb2.connect(inter, stv, snk)
     
     self.tb2.run()
     res = snk.data()
     print res[110:130]
     
     self.assertFloatTuplesAlmostEqual(tuple(my_res), res)
Ejemplo n.º 22
0
    def test_002_t(self):
        self.tb2 = gr.top_block()
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        N_ant = 2
        data = []
        test_len = 100
        my_res = []
        for i in range(test_len):
            mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i)
            crc = lte_test.crc_checksum(mib, N_ant)
            conv = lte_test.convolutional_encoder_sorted(crc)
            convit = lte_test.convolutional_encoder(crc)
            my_res.extend(lte_test.nrz_encoding(convit))
            rated = lte_test.rate_match(conv)
            nrz = lte_test.nrz_encoding(rated)
            data.extend(nrz)

        srcf = blocks.vector_source_f(data, False, 120)
        snkf = blocks.file_sink(gr.sizeof_float * 120,
                                "/home/johannes/tests/rated.dat")
        self.tb2.connect(srcf, snkf)

        src1 = blocks.vector_source_f(data, False, 120)

        vts0 = blocks.vector_to_stream(40 * gr.sizeof_float, 3)
        sts0 = blocks.stream_to_streams(40 * gr.sizeof_float, 3)
        self.tb2.connect(src1, vts0, sts0)

        inter = blocks.interleave(gr.sizeof_float)
        for i in range(3):
            deint = lte.subblock_deinterleaver_vfvf(40, 1)
            vts1 = blocks.vector_to_stream(1 * gr.sizeof_float, 40)
            self.tb2.connect((sts0, i), deint, vts1, (inter, i))
        stv = blocks.stream_to_vector(1 * gr.sizeof_float, 120)
        snk = blocks.vector_sink_f(120)
        self.tb2.connect(inter, stv, snk)

        self.tb2.run()
        res = snk.data()
        print res[110:130]

        self.assertFloatTuplesAlmostEqual(tuple(my_res), res)
Ejemplo n.º 23
0
    def test_002_data(self):
        cell_id = 124
        N_ant = 2
        tl = 1024
        data = []
        for i in range(tl / 4):
            mib = lte_test.pack_mib(50, 0, 1.0, i * 4)
            bch = tuple(lte_test.encode_bch(mib, N_ant))
            p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
            p_scrambled = lte_test.nrz_encoding(p_scrambled)
            data.extend(p_scrambled)

        self.src.set_data(data)
        dbgs = blocks.file_sink(480 * gr.sizeof_float,
                                "/home/johannes/tests/descramble.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run()
        pass
Ejemplo n.º 24
0
    def test_003_demapping(self):
        print "\ntest_003_demapping"
        N_ant = [1, 2, 4]
        cell_id = 124
        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = tuple(lte_test.encode_bch(mib, N_ant[0]))
        data = lte_test.pbch_scrambling(bch, cell_id)
        style = "tx_diversity"
        self.demapper.set_decoding_style(style)

        mapped = [[], [], []]
        mapped[0] = lte_test.layer_mapping(data, 1, style)[0]
        m2 = lte_test.layer_mapping(data, 2, style)
        m2a = []
        for i in range(len(m2[0]) / 120):
            m2a.extend(m2[0][120 * i:(i + 1) * 120])
            m2a.extend(m2[1][120 * i:(i + 1) * 120])
        mapped[1] = m2a

        m4 = lte_test.layer_mapping(data, 4, style)
        m4a = []
        for i in range(len(m4[0]) / 60):
            m4a.extend(m4[0][i * 60:(i + 1) * 60])
            m4a.extend(m4[1][i * 60:(i + 1) * 60])
            m4a.extend(m4[2][i * 60:(i + 1) * 60])
            m4a.extend(m4[3][i * 60:(i + 1) * 60])
        mapped[2] = m4a

        exp_res = [complex(data[i]) for i in range(len(data))]

        for i in range(3):
            self.demapper.set_N_ant(N_ant[i])
            print "N_ant = " + str(self.demapper.get_N_ant()), np.shape(mapped[i])
            self.src.set_data(mapped[i])
            self.snk.reset()
            self.tb.run()
            res = self.snk.data()
            try:
                self.assertComplexTuplesAlmostEqual(res, tuple(exp_res))
            except:
                print "FAILED N_ant = " + str(self.demapper.get_N_ant())
                self.assertComplexTuplesAlmostEqual(res, tuple(exp_res))
Ejemplo n.º 25
0
    def test_003_demapping (self):
        print "\ntest_003_demapping"
        N_ant = [1,2,4]
        cell_id = 124
        mib = lte_test.pack_mib(50,0,1.0, 511)
        bch = tuple(lte_test.encode_bch(mib, N_ant[0]))
        data = lte_test.pbch_scrambling(bch, cell_id)
        style = "tx_diversity"
        self.demapper.set_decoding_style(style)
        
        mapped = [[],[],[]]
        mapped[0] = lte_test.layer_mapping(data, 1 , style)
        m2 = lte_test.layer_mapping(data, 2 , style)
        m2a = []
        for i in range(len(m2[0])/120):
            m2a.extend(m2[0][120*i:(i+1)*120])
            m2a.extend(m2[1][120*i:(i+1)*120])
        mapped[1] = m2a
        
        m4 = lte_test.layer_mapping(data, 4, style)
        m4a = []
        for i in range(len(m4[0])/60):
            m4a.extend(m4[0][i*60:(i+1)*60])
            m4a.extend(m4[1][i*60:(i+1)*60])
            m4a.extend(m4[2][i*60:(i+1)*60])
            m4a.extend(m4[3][i*60:(i+1)*60])
        mapped[2] = m4a
               
        exp_res = [complex(data[i]) for i in range(len(data))]

        for i in range(3):
            self.demapper.set_N_ant(N_ant[i])
            print "N_ant = " +str(self.demapper.get_N_ant())
            self.src.set_data(mapped[i])
            self.snk.reset()
            self.tb.run()
            res = self.snk.data()
            try:
                self.assertComplexTuplesAlmostEqual(res, tuple(exp_res) )
            except:
                print "FAILED N_ant = " +str(self.demapper.get_N_ant())
                self.assertComplexTuplesAlmostEqual(res, tuple(exp_res) )
Ejemplo n.º 26
0
 def test_001_t (self):
     print "lte_rate_unmatch TEST"
     mib = lte_test.pack_mib(50,0,1.0, 511)
     mib_crc = lte_test.crc_checksum(mib, 2)
     c_enc_sorted = lte_test.convolutional_encoder_sorted(mib_crc)
     
     
     in_data = c_enc_sorted
     input_data = lte_test.rate_match(in_data)
     my_data = []
     for i in range(40):
         my_data.append(in_data[i+0])
         my_data.append(in_data[i+40])
         my_data.append(in_data[i+80])    
     in_data = my_data
     exp_res = tuple([float(in_data[i]) for i in range(len(in_data))])
     
     self.src.set_data(input_data)
     self.tb.run ()
     res=self.snk.data()
     
     self.assertEqual(res, exp_res)
Ejemplo n.º 27
0
    def test_001_t (self):
        cell_id = 124
        N_ant = 2
        style= "tx_diversity"
        N_rb_dl = self.N_rb_dl
        sim_frames = 4
        self.demux.set_cell_id(cell_id)
        sfn = 512
        mib = lte_test.pack_mib(N_rb_dl, 0, 1.0, sfn)
        bch = lte_test.encode_bch(mib, N_ant)
        pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)

        stream = []
        #for i in range(sim_frames):
        #    frame = lte_test.generate_frame(pbch, N_rb_dl, cell_id, i+20, N_ant)
        #    stream.extend(frame[0].flatten())
        #
        #print len(stream)
        for i in range(sim_frames):
            frame = lte_test.generate_phy_frame(cell_id, N_rb_dl, N_ant)
            for p in range(len(frame)):
                frame[p] = lte_test.map_pbch_to_frame_layer(frame[p], pbch[p], cell_id, sfn+i, p)
            stream.extend(frame[0].flatten().tolist() )

        key = self.key
        srcid = "source"
        tags = lte_test.get_tag_list(140 * sim_frames, 140, key, srcid)

        self.src1.set_data(stream, tuple(tags))
        # set up fg
        self.tb.run ()
        # check data
        res1 = self.snk1.data()

        print len(res1)
        compare = res1[0:len(pbch[0])]

        self.assertComplexTuplesAlmostEqual(compare, tuple(pbch[0][0:len(compare)]))
Ejemplo n.º 28
0
    def test_001_generated(self):
        print "\ntest_001_generated"
        cell_id = 124
        N_ant = 2
        style = "tx_diversity"
        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = lte_test.encode_bch(mib, N_ant)

        scrambled = lte_test.pbch_scrambling(bch, cell_id)
        qpsk_modulated = lte_test.qpsk_modulation(scrambled)
        #print np.shape(qpsk_modulated)
        layer_mapped = lte_test.layer_mapping(qpsk_modulated, N_ant, style)
        pre_coded = lte_test.pre_coding(layer_mapped, N_ant, style)
        #print np.shape(pre_coded)

        h0 = [complex(1, 0)] * len(pre_coded[0])
        h1 = [complex(1, 0)] * len(pre_coded[1])
        stream = [
            pre_coded[0][i] + pre_coded[1][i] for i in range(len(pre_coded[0]))
        ]

        self.src1.set_data(stream)
        self.src2.set_data(h0)
        self.src3.set_data(h1)
        self.tb.run()
        res = self.snk.data()

        exp_res = []
        for i in range(len(stream) / 240):
            print i
            lay0 = layer_mapped[0][i * 120:(i + 1) * 120]
            lay1 = layer_mapped[1][i * 120:(i + 1) * 120]
            comb = [lay0, lay1]
            exp_res.extend(
                lte_test.prepare_for_demapper_block(comb, N_ant, style))

        print "test 001 final ASSERT!"
        print self.assertComplexTuplesAlmostEqual(res, exp_res)
Ejemplo n.º 29
0
    def test_001_t(self):
        cell_id = 124
        srcid = "test_src"
        N_ant = 2
        style = "tx_diversity"
        N_rb_dl = self.N_rb_dl
        sfn = 0
        Ncp = 1
        cfi = 2

        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = lte_test.encode_bch(mib, N_ant)
        pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)

        exp_res = []
        for sub in range(10):
            ns = sub * 2
            pcfich = lte_test.encode_pcfich(cfi, cell_id, ns, N_ant)
            exp_res.append(pcfich[0])

        frame = lte_test.generate_frame(pbch, N_rb_dl, cell_id, sfn, N_ant)
        data = frame[0].flatten()
        taglist = lte_test.get_tag_list(len(frame[0]), 140, self.key, srcid)
        self.src0.set_data(data, taglist)

        self.demux.set_cell_id(cell_id)
        #print calculate_pcfich_pos(N_rb_dl, cell_id)
        # set up fg
        self.tb.run()
        # check data

        res = self.snk0.data()

        print "test 001 check res"
        for i in range(len(res) / len(exp_res[0])):
            part = res[i * 16:(i + 1) * 16]
            self.assertComplexTuplesAlmostEqual(part, exp_res[i])
Ejemplo n.º 30
0
    def test_001_t (self):
        cell_id = 124
        srcid = "test_src"
        N_ant = 2
        style = "tx_diversity"
        N_rb_dl = self.N_rb_dl
        sfn = 0
        Ncp = 1
        cfi = 2

        mib = lte_test.pack_mib(50,0,1.0, 511)
        bch = lte_test.encode_bch(mib, N_ant)
        pbch = lte_test.encode_pbch(bch, cell_id, N_ant, style)

        exp_res = []
        for sub in range(10):
            ns = sub * 2
            pcfich = lte_test.encode_pcfich(cfi, cell_id, ns, N_ant)
            exp_res.append(pcfich[0])

        frame = lte_test.generate_frame(pbch, N_rb_dl, cell_id, sfn, N_ant)
        data = frame[0].flatten()
        taglist = lte_test.get_tag_list(len(frame[0]), 140, self.key, srcid)
        self.src0.set_data(data, taglist)

        self.demux.set_cell_id(cell_id)
        #print calculate_pcfich_pos(N_rb_dl, cell_id)
        # set up fg
        self.tb.run()
        # check data

        res = self.snk0.data()

        print "test 001 check res"
        for i in range(len(res)/len(exp_res[0])):
            part = res[i*16:(i+1)*16]
            self.assertComplexTuplesAlmostEqual(part, exp_res[i])
Ejemplo n.º 31
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        mib = lte_test.pack_mib(50, 0, 1.0, 511)
        bch = tuple(lte_test.encode_bch(mib, N_ant))
        p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
        p_scrambled = lte_test.nrz_encoding(p_scrambled)
        n_bch = tuple(lte_test.nrz_encoding(bch))

        print len(p_scrambled)
        print p_scrambled[0:20]

        self.src.set_data(p_scrambled)  #[0:480])
        self.descr.set_cell_id(cell_id)

        #pn_seq = self.descr.pn_sequence()
        #print pn_seq[0:20]
        dbgs = blocks.file_sink(480 * gr.sizeof_float,
                                "/home/johannes/tests/descramble.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run()
        res = self.snk.data()
        print len(res)

        count = 0
        for i in range(len(res) / len(n_bch)):
            part = res[len(n_bch) * i:(i + 1) * len(n_bch)]
            try:
                self.assertEqual(part, n_bch, 3)
                print str(i) + "\tSUCCESS"
            except:
                print str(i)
                count = count + 1
        print "\nresult"
        print count
        print len(res) / len(n_bch)
Ejemplo n.º 32
0
 def test_001_t (self):
     # set up fg
     N_rb_dl = 50
     phich_dur = 0
     phich_res = 1.0
     sfn = 511
     data = []
     test_len = 20
     myinput = []
     for i in range(test_len):
         mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i*4)
         myinput.extend(mib)            
         data.extend(lte_test.crc_checksum(mib, self.N_ant) )
         
     self.src.set_data(data)        
     self.tb.run ()
     res = self.snk0.data()
     print "data bits"
     self.assertTupleEqual(tuple(res), tuple(myinput))        
     check = self.snk1.data()
     crcres = [int(check[i]) for i in range(len(check))]
     print check
     self.assertTupleEqual(tuple(crcres), tuple([1]*test_len))
     print crcres
Ejemplo n.º 33
0
    def test_001_t (self):
        cell_id = 124
        N_ant = 2
        tl = 1024
        data = []
        input_data = []
        for i in range(tl/4):
            mib = lte_test.pack_mib(50,0,1.0, i*4)
            bch = tuple(lte_test.encode_bch(mib, N_ant))
            p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
            input_data.extend(lte_test.nrz_encoding(p_scrambled))
            mod = lte_test.qpsk_modulation(p_scrambled)
            data.extend(mod)

        self.src.set_data(data)

        dbgs = blocks.file_sink(240 * gr.sizeof_gr_complex, "/home/johannes/tests/demodulate.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run ()
        # check data
        res = self.snk.data()
        exp_res = tuple(input_data)#tuple([input_data[i]/math.sqrt(2) for i in range(len(input_data))])
        print self.assertFloatTuplesAlmostEqual(res, exp_res, 5)
Ejemplo n.º 34
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        mib = lte_test.pack_mib(50,0,1.0, 511)
        bch = tuple(lte_test.encode_bch(mib, N_ant))
        p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
        p_scrambled = lte_test.nrz_encoding(p_scrambled)
        n_bch = tuple(lte_test.nrz_encoding(bch))

        print len(p_scrambled)
        print p_scrambled[0:20]

        self.src.set_data(p_scrambled)#[0:480])
        self.descr.set_cell_id(cell_id)

        #pn_seq = self.descr.pn_sequence()
        #print pn_seq[0:20]
        dbgs = blocks.file_sink(480 * gr.sizeof_float, "/home/johannes/tests/descramble.dat")
        self.tb.connect(self.src, dbgs)
        # set up fg
        self.tb.run()
        res = self.snk.data()
        print len(res)

        count = 0
        for i in range(len(res)/len(n_bch)):
            part = res[len(n_bch)*i:(i+1)*len(n_bch)]
            try:
                self.assertEqual(part, n_bch,3)
                print str(i) + "\tSUCCESS"
            except:
                print str(i)
                count = count +1
        print "\nresult"
        print count
        print len(res)/len(n_bch)
Ejemplo n.º 35
0
    def test_001_t(self):
        cell_id = 124
        N_ant = 2
        tl = 1024
        data = []
        input_data = []
        for i in range(tl / 4):
            mib = lte_test.pack_mib(50, 0, 1.0, i * 4)
            bch = tuple(lte_test.encode_bch(mib, N_ant))
            p_scrambled = lte_test.pbch_scrambling(bch, cell_id)
            input_data.extend(lte_test.nrz_encoding(p_scrambled))
            mod = lte_test.qpsk_modulation(p_scrambled)
            data.extend(mod)

        self.src.set_data(data)

        # set up fg
        self.tb.run()
        # check data
        res = self.snk.data()
        exp_res = tuple(
            input_data
        )  #tuple([input_data[i]/math.sqrt(2) for i in range(len(input_data))])
        self.assertFloatTuplesAlmostEqual(res, exp_res, 5)
Ejemplo n.º 36
0
    def test_001_t(self):
        # set up fg
        N_rb_dl = 50
        phich_dur = 0
        phich_res = 1.0
        sfn = 511
        data = []
        test_len = 20
        myinput = []
        for i in range(test_len):
            mib = lte_test.pack_mib(N_rb_dl, phich_dur, phich_res, i * 4)
            myinput.extend(mib)
            data.extend(lte_test.crc_checksum(mib, self.N_ant))

        self.src.set_data(data)
        self.tb.run()
        res = self.snk0.data()
        print "data bits"
        self.assertTupleEqual(tuple(res), tuple(myinput))
        check = self.snk1.data()
        crcres = [int(check[i]) for i in range(len(check))]
        print check
        self.assertTupleEqual(tuple(crcres), tuple([1] * test_len))
        print crcres