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)
def test_002_data(self): cell_id = 124 N_ant = 2 tl = 1024 data = [] ref_bch = [] 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) bch = tuple(lte_test.nrz_encoding(bch)) ref_bch.extend(bch) self.src.set_data(data) self.descr.set_cell_id(cell_id) self.tb.run() res = self.snk.data() print len(res) count = 0 for i in range(len(res) / len(ref_bch)): part = res[len(ref_bch) * i:(i + 1) * len(ref_bch)] try: self.assertEqual(part, ref_bch, 3) print str(i) + "\tSUCCESS" except: print str(i) count = count + 1 print "\nresult" print count print len(res) / len(ref_bch)
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) # 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)
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"
def setUp(self): self.tb = gr.top_block() key = "subframe" msg_buf_name = "cfi" print "setup test" data = [] self.cfi_list = [] for i in range(3): val = i + 1 self.cfi_list.append(val) cfi = lte_test.get_cfi_sequence(val) data.extend(lte_test.nrz_encoding(cfi)) reps = 5 self.cfi_list *= reps srcid = "src" taglist = lte_test.get_tag_list(3 * reps, 10, key, srcid) data = [float(data[i]) for i in range(len(data))] ext_data = [] for i in range(reps): ext_data.extend(data) data = ext_data self.src = blocks.vector_source_f(data, False, 32, taglist) self.cfi = lte.pcfich_unpack_vfm(key, msg_buf_name) self.cfi.activate_debug_mode(True) self.tb.connect(self.src, self.cfi) print "setup finished"
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)
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"
def test_002_pcfich(self): print "pcfich test" cfi = 2 cell_id = 387 vlen = 32 # Generate descrambling sequences. seqs = [] for ns in range(10): #scr = lte_test.scramble_cfi_sequence([0] * 32, cell_id, ns) scr = lte_test.get_pcfich_scrambling_sequence(cell_id, ns) seqs.append(lte_test.nrz_encoding(scr)) # Generate a CFI sequence cfi_seq = lte_test.get_cfi_sequence(cfi) nrz_cfi_seq = lte_test.nrz_encoding(cfi_seq) # Generate scrambled sequences nvecs = 100 scr_cfi_seqs = [] expres = [] for ns in range(nvecs): scr_cfi_seqs.extend( lte_test.nrz_encoding( lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns % 10))) expres.extend(nrz_cfi_seq) # Get tags tags = lte_test.get_tag_list(nvecs, 10, self.tag_key, "test_src") # Get blocks for test flowgraph src = blocks.vector_source_f(scr_cfi_seqs, False, vlen) src.set_data(scr_cfi_seqs, tags) descr = lte.descrambler_vfvf(self.tag_key, "cfi_seqs", vlen) descr.set_descr_seqs(seqs) snk = blocks.vector_sink_f(vlen) # Create, connect, run fg tb = gr.top_block() tb.connect(src, descr, snk) tb.run() # Get result res = snk.data() # Check results! self.assertFloatTuplesAlmostEqual(res, expres)
def test_002_pcfich(self): print "pcfich test" cfi = 2 cell_id = 387 vlen =32 # Generate descrambling sequences. seqs = [] for ns in range(10): #scr = lte_test.scramble_cfi_sequence([0] * 32, cell_id, ns) scr = lte_test.get_pcfich_scrambling_sequence(cell_id, ns) seqs.append(lte_test.nrz_encoding(scr)) # Generate a CFI sequence cfi_seq = lte_test.get_cfi_sequence(cfi) nrz_cfi_seq = lte_test.nrz_encoding(cfi_seq) # Generate scrambled sequences nvecs = 100 scr_cfi_seqs = [] expres = [] for ns in range(nvecs): scr_cfi_seqs.extend(lte_test.nrz_encoding(lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns%10))) expres.extend(nrz_cfi_seq) # Get tags tags = lte_test.get_tag_list(nvecs, 10, self.tag_key, "test_src") # Get blocks for test flowgraph src = blocks.vector_source_f(scr_cfi_seqs, False, vlen) src.set_data(scr_cfi_seqs, tags) descr = lte.descrambler_vfvf(self.tag_key, "cfi_seqs", vlen) descr.set_descr_seqs(seqs) snk = blocks.vector_sink_f(vlen) # Create, connect, run fg tb = gr.top_block() tb.connect(src, descr, snk) tb.run() # Get result res = snk.data() # Check results! self.assertFloatTuplesAlmostEqual(res, expres)
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)
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)
def test_001_t(self): print "test_001_t" # set up fg cell_id = 124 max_len = 84 * self.cce_len n_cce = 20 pdcch_format = 3 # set up descrambling block seqs = [] for sub in range(10): seq = lte_test.get_pdcch_scrambling_sequence( max_len, cell_id, 2 * sub) seqs.append(lte_test.nrz_encoding(seq)) self.descr.set_descr_seqs(seqs) # generate test data data = [] exp_res = [] for i in range(n_cce): pdcch = lte_test.get_pdcch(pdcch_format) exp_res.extend(lte_test.nrz_encoding(pdcch)) scr = lte_test.scramble_pdcch(pdcch, 2 * (i % 10), cell_id) data.extend(lte_test.nrz_encoding(scr)) #data = [0] * self.cce_len * n_cce tag_list = lte_test.get_tag_list(n_cce, 10, self.tag_key, "source") for i in range(len(tag_list)): tag_list[i].offset *= (2**pdcch_format) self.src.set_data(data, tag_list) self.tb.run() # check data res = self.snk.data() # self.assertFloatTuplesAlmostEqual(res, exp_res) for i in range(self.cce_len * n_cce): # print i resp = res[i * n_cce:(i + 1) * n_cce] expp = exp_res[i * n_cce:(i + 1) * n_cce] self.assertFloatTuplesAlmostEqual(resp, expp)
def test_001_t(self): print "test_001_t" # set up fg cell_id = 124 max_len = 84 * self.cce_len n_cce = 20 pdcch_format = 3 # set up descrambling block seqs = [] for sub in range(10): seq = lte_test.get_pdcch_scrambling_sequence(max_len, cell_id, 2 * sub) seqs.append(lte_test.nrz_encoding(seq)) self.descr.set_descr_seqs(seqs) # generate test data data = [] exp_res = [] for i in range(n_cce): pdcch = lte_test.get_pdcch(pdcch_format) exp_res.extend(lte_test.nrz_encoding(pdcch)) scr = lte_test.scramble_pdcch(pdcch, 2 * (i % 10), cell_id) data.extend(lte_test.nrz_encoding(scr)) #data = [0] * self.cce_len * n_cce tag_list = lte_test.get_tag_list(n_cce, 10, self.tag_key, "source") for i in range(len(tag_list)): tag_list[i].offset *= (2 ** pdcch_format) self.src.set_data(data, tag_list) self.tb.run() # check data res = self.snk.data() # self.assertFloatTuplesAlmostEqual(res, exp_res) for i in range(self.cce_len * n_cce): # print i resp = res[i * n_cce:(i + 1) * n_cce] expp = exp_res[i * n_cce:(i + 1) * n_cce] self.assertFloatTuplesAlmostEqual(resp, expp)
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]))
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)
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)
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)
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)
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)
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)
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_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_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)
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)