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_004_pcfich(self): print "\ntest_004_pcfich" cell_id = 124 ns = 0 N_ant = 2 vlen = 16 style = "tx_diversity" self.tb2 = gr.top_block() self.src = blocks.vector_source_c([0]*vlen,False,vlen) self.demapper = lte_swig.layer_demapper_vcvc(0, vlen, style) self.snk = blocks.vector_sink_c(vlen) self.tb2.connect(self.src, self.demapper, self.snk) self.demapper.set_N_ant(N_ant) data = [] exp_res = [] for cfi in range(4): cfi_seq = lte_test.get_cfi_sequence(cfi+1) scr_cfi_seq = lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns) mod_cfi_seq = lte_test.qpsk_modulation(scr_cfi_seq) exp_res.extend(mod_cfi_seq) lay_cfi_seq = lte_test.layer_mapping(mod_cfi_seq, N_ant, style) for i in range(len(lay_cfi_seq)): data.extend(lay_cfi_seq[i]) self.src.set_data(data) self.tb2.run() res = self.snk.data() self.assertComplexTuplesAlmostEqual(res, exp_res)
def test_004_pcfich(self): print "\ntest_004_pcfich" cell_id = 124 ns = 0 N_ant = 2 vlen = 16 style = "tx_diversity" self.tb2 = gr.top_block() self.src = blocks.vector_source_c([0] * vlen, False, vlen) self.demapper = lte.layer_demapper_vcvc(0, vlen, style) self.snk = blocks.vector_sink_c(vlen) self.tb2.connect(self.src, self.demapper, self.snk) self.demapper.set_N_ant(N_ant) data = [] exp_res = [] for cfi in range(4): cfi_seq = lte_test.get_cfi_sequence(cfi + 1) scr_cfi_seq = lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns) mod_cfi_seq = lte_test.qpsk_modulation(scr_cfi_seq) exp_res.extend(mod_cfi_seq) lay_cfi_seq = lte_test.layer_mapping(mod_cfi_seq, N_ant, style) for i in range(len(lay_cfi_seq)): data.extend(lay_cfi_seq[i]) self.src.set_data(data) self.tb2.run() res = self.snk.data() self.assertComplexTuplesAlmostEqual(res, exp_res)
def test_002_pcfich(self): print "test_002_pcfich" # some constants cell_id = 124 N_ant = 2 style = "tx_diversity" vlen = 16 ns = 0 # new top_block because even the interface changes self.tb2 = gr.top_block() # generate test data together with the expected output data = [] exp_res = [] for cfi in range(4): cfi_seq = lte_test.get_cfi_sequence(cfi + 1) scr_cfi_seq = lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns) mod_cfi_seq = lte_test.qpsk_modulation(scr_cfi_seq) lay_cfi_seq = lte_test.layer_mapping(mod_cfi_seq, N_ant, style) lay_cfi_prep = lte_test.prepare_for_demapper_block( lay_cfi_seq, N_ant, style) exp_res.extend(lay_cfi_prep) pc_cfi_seq = lte_test.pre_coding(lay_cfi_seq, N_ant, style) pc_cfi_seq = [ pc_cfi_seq[0][i] + pc_cfi_seq[1][i] for i in range(len(pc_cfi_seq[0])) ] data.extend(pc_cfi_seq) # dummy channel estimates intu2 = [complex(1, 0)] * len(data) intu3 = [complex(1, 0)] * len(data) # get blocks self.src1 = blocks.vector_source_c(data, False, vlen) self.src2 = blocks.vector_source_c(intu2, False, vlen) self.src3 = blocks.vector_source_c(intu3, False, vlen) self.pd = lte.pre_decoder_vcvc(1, 1, vlen, style) self.snk = blocks.vector_sink_c(vlen) # connect all blocks self.tb2.connect(self.src1, (self.pd, 0)) self.tb2.connect(self.src2, (self.pd, 1)) self.tb2.connect(self.src3, (self.pd, 2)) self.tb2.connect(self.pd, self.snk) self.pd.set_N_ant(N_ant) # run flowgraph self.tb2.run() # compare result with expected result res = self.snk.data() self.assertComplexTuplesAlmostEqual(res, exp_res)
def test_002_pcfich(self): print "test_002_pcfich" # some constants cell_id = 124 N_ant = 2 style = "tx_diversity" vlen = 16 ns = 0 # new top_block because even the interface changes self.tb2 = gr.top_block() # generate test data together with the expected output data = [] exp_res = [] for cfi in range(4): cfi_seq = lte_test.get_cfi_sequence(cfi + 1) scr_cfi_seq = lte_test.scramble_cfi_sequence(cfi_seq, cell_id, ns) mod_cfi_seq = lte_test.qpsk_modulation(scr_cfi_seq) lay_cfi_seq = lte_test.layer_mapping(mod_cfi_seq, N_ant, style) lay_cfi_prep = lte_test.prepare_for_demapper_block(lay_cfi_seq, N_ant, style) exp_res.extend(lay_cfi_prep) pc_cfi_seq = lte_test.pre_coding(lay_cfi_seq, N_ant, style) pc_cfi_seq = [pc_cfi_seq[0][i] + pc_cfi_seq[1][i] for i in range(len(pc_cfi_seq[0]))] data.extend(pc_cfi_seq) # dummy channel estimates intu2 = [complex(1, 0)] * len(data) intu3 = [complex(1, 0)] * len(data) # get blocks self.src1 = blocks.vector_source_c(data, False, vlen) self.src2 = blocks.vector_source_c(intu2, False, vlen) self.src3 = blocks.vector_source_c(intu3, False, vlen) self.pd = lte.pre_decoder_vcvc(1, vlen, style) self.snk = blocks.vector_sink_c(vlen) # connect all blocks self.tb2.connect(self.src1, (self.pd, 0)) self.tb2.connect(self.src2, (self.pd, 1)) self.tb2.connect(self.src3, (self.pd, 2)) self.tb2.connect(self.pd, self.snk) self.pd.set_N_ant(N_ant) # run flowgraph self.tb2.run() # compare result with expected result res = self.snk.data() self.assertComplexTuplesAlmostEqual(res, exp_res)
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)