def generate_frames(cell_id, N_rb_dl, N_ant, n_frames, start_sfn): Ncp = 1 N_g = 1 cfi = 2 #indexing: frame_n, antenna port, ofdm_nr within frame, subcarrier frames = [] for i in range(n_frames): sfn = (start_sfn + i) % 1024 mib = pack_mib(N_rb_dl, 0, 1.0, sfn) bch = encode_bch(mib, N_ant) pbch = encode_pbch(bch, cell_id, N_ant, "tx_diversity") #mainframe = lte_phy.generate_phy_frame(cell_id, N_rb_dl, N_ant) mainframe = generate_frame(pbch, N_rb_dl, cell_id, sfn, N_ant) for p in range(N_ant): mainframe[p] = map_pbch_to_frame_layer(mainframe[p], pbch[p], cell_id, sfn, p) #sync signals here only on ant port 0 mainframe[0][5] = lte_phy.map_sss_to_symbol(mainframe[0][5], N_rb_dl, cell_id, 0) mainframe[0][6] = lte_phy.map_pss_to_symbol(mainframe[0][6], N_rb_dl, cell_id % 3) mainframe[0][75] = lte_phy.map_sss_to_symbol(mainframe[0][75], N_rb_dl, cell_id, 1) mainframe[0][76] = lte_phy.map_pss_to_symbol(mainframe[0][76], N_rb_dl, cell_id % 3) frames.append(mainframe) return frames
def main(): cell_id = 124 N_ant = 2 style = "tx_diversity" mib = pack_mib(50, 0, 1.0, 511) bch = encode_bch(mib, N_ant) scrambled = pbch_scrambling(bch, cell_id) qpsk_modulated = qpsk_modulation(scrambled) layer_mapped = layer_mapping(qpsk_modulated, N_ant, style) pre_coded = pre_coding(layer_mapped, N_ant, style) pbch = encode_pbch(bch, cell_id, N_ant, style) print len(pre_coded) print len(pbch) print len(pre_coded[0]) print len(pbch[0]) for n in range(len(pbch[0])): if pbch[0][n] != pre_coded[0][n]: print "ant0 failed!" elif pbch[1][n] != pre_coded[1][n]: print "ant1 failed!" rx = [pre_coded[0][n] + pre_coded[1][n] for n in range(len(pre_coded[0]))] h = [[complex(1, 0)] * len(pre_coded[0]), [complex(1, 0)] * len(pre_coded[0])] pre_decoded = pre_decoding(rx, h, N_ant, style)
def main(): cell_id = 124 N_ant = 2 style= "tx_diversity" mib = pack_mib(50,0,1.0, 511) bch = encode_bch(mib, N_ant) scrambled = pbch_scrambling(bch, cell_id) qpsk_modulated = qpsk_modulation(scrambled) layer_mapped = layer_mapping(qpsk_modulated, N_ant, style) pre_coded = pre_coding(layer_mapped, N_ant, style) pbch = encode_pbch(bch, cell_id, N_ant, style) print len(pre_coded) print len(pbch) print len(pre_coded[0]) print len(pbch[0]) for n in range(len(pbch[0])): if pbch[0][n] != pre_coded[0][n]: print "ant0 failed!" elif pbch[1][n] != pre_coded[1][n]: print "ant1 failed!" rx = [pre_coded[0][n]+pre_coded[1][n] for n in range(len(pre_coded[0]))] h = [[complex(1,0)]*len(pre_coded[0]),[complex(1,0)]*len(pre_coded[0])] pre_decoded = pre_decoding(rx, h, N_ant, style)
def main(): cell_id = 124 N_ant = 1 style = "tx_diversity" N_rb_dl = 50 sfn = 0 Ncp = 1 N_g = 1 cfi = 2 trollframe = lte_phy.generate_phy_frame(cell_id, N_rb_dl, N_ant) for ant in [1, 2, 4]: frame = lte_phy.generate_phy_frame(cell_id, N_rb_dl, ant) print np.shape(frame) mib = pack_mib(50, 0, 1.0, 511) bch = encode_bch(mib, N_ant) pbch = encode_pbch(bch, cell_id, N_ant, style) if N_ant == 1: pbch = [pbch] pn_seq = pn_generator(220, cell_id) rs_seq = rs_generator(3, 4, cell_id, Ncp) pcfich = encode_pcfich(2, cell_id, 4, N_ant) N_CCE = get_n_cce_available(N_ant, N_rb_dl, cfi, N_g) my_pdcchs = get_all_pdcchs(N_CCE) ns = 0
def generate_frames(cell_id, N_rb_dl, N_ant, n_frames, start_sfn): Ncp = 1 N_g = 1 cfi = 2 #indexing: frame_n, antenna port, ofdm_nr within frame, subcarrier frames = [] for i in range(n_frames): sfn = (start_sfn + i) % 1024 mib = pack_mib(N_rb_dl, 0, 1.0, sfn) bch = encode_bch(mib, N_ant) pbch = encode_pbch(bch, cell_id, N_ant, "tx_diversity") #mainframe = lte_phy.generate_phy_frame(cell_id, N_rb_dl, N_ant) mainframe = generate_frame(pbch, N_rb_dl, cell_id, sfn, N_ant) for p in range(N_ant): mainframe[p] = map_pbch_to_frame_layer(mainframe[p], pbch[p], cell_id, sfn, p) #sync signals here only on ant port 0 mainframe[0][5] = lte_phy.map_sss_to_symbol(mainframe[0][5], N_rb_dl, cell_id, 0) mainframe[0][6] = lte_phy.map_pss_to_symbol(mainframe[0][6], N_rb_dl, cell_id % 3) mainframe[0][75] = lte_phy.map_sss_to_symbol(mainframe[0][75], N_rb_dl, cell_id, 1) mainframe[0][76] = lte_phy.map_pss_to_symbol(mainframe[0][76], N_rb_dl, cell_id % 3) frames.append(mainframe); return frames
def encode_pbch(bch, cell_id, N_ant, style): print "encode_pbch" scrambled = pbch_scrambling(bch, cell_id) qpsk_modulated = qpsk_modulation(scrambled) layer_mapped = layer_mapping(qpsk_modulated, N_ant, style) pre_coded = pre_coding(layer_mapped, N_ant, style) return pre_coded if __name__ == "__main__": cell_id = 124 N_ant = 2 style= "tx_diversity" mib = pack_mib(50,0,1.0, 511) bch = encode_bch(mib, N_ant) scrambled = pbch_scrambling(bch, cell_id) qpsk_modulated = qpsk_modulation(scrambled) layer_mapped = layer_mapping(qpsk_modulated, N_ant, style) pre_coded = pre_coding(layer_mapped, N_ant, style) pbch = encode_pbch(bch, cell_id, N_ant, style) print len(pre_coded) print len(pbch) print len(pre_coded[0]) print len(pbch[0]) for n in range(len(pbch[0])): if pbch[0][n] != pre_coded[0][n]:
def main(): cell_id = 124 N_ant = 1 style= "tx_diversity" N_rb_dl = 50 sfn = 0 Ncp = 1 N_g = 1 cfi = 2 trollframe = lte_phy.generate_phy_frame(cell_id, N_rb_dl, N_ant) mib = pack_mib(50,0,1.0, 511) bch = encode_bch(mib, N_ant) pbch = encode_pbch(bch, cell_id, N_ant, style) if N_ant == 1: pbch = [pbch] pn_seq = pn_generator(220, cell_id) rs_seq = rs_generator(3, 4, cell_id, Ncp) pcfich = encode_pcfich(2, cell_id, 4, N_ant) N_CCE = get_n_cce_available(N_ant, N_rb_dl, cfi, N_g) my_pdcchs = get_all_pdcchs(N_CCE) ns = 0 pdcch = encode_pdcch(my_pdcchs, N_rb_dl, N_ant, style, cfi, N_g, ns, cell_id) if N_ant == 1: pdcch = [pdcch] org_frame = generate_frame(pbch, N_rb_dl, cell_id, sfn, N_ant) cfi_reg = calculate_pcfich_reg_pos(N_rb_dl, cell_id) free_reg = get_free_reg_pos(N_rb_dl, cell_id) n_phich_groups = get_n_phich_groups(N_g, N_rb_dl) phich_pos = get_phich_pos(N_rb_dl, cell_id, N_g) symbol = [0] * 12 * N_rb_dl phich = ["PHICH"] * 12 * n_phich_groups pcfi = ["CFI"] * 16 symbol = map_pcfich_to_symbol(symbol, pcfi, N_rb_dl, cell_id, 0) symbol = map_phich_to_symbol(symbol, phich, N_rb_dl, cell_id, N_g) print "\n\noccupied" occ = get_occupied_regs(N_rb_dl, cell_id, N_g) pdcch_pos = get_pdcch_reg_pos(N_rb_dl, cell_id, N_g, cfi) symbols = org_frame[0][0:cfi] print np.shape(symbols) print np.shape(pdcch) map_pdcch_to_symbols(symbols, pdcch[0], N_rb_dl, cell_id, N_g, cfi) print "pdcch done" # for i in range(len(symbol)): # print "{0}\t{1}".format(i, symbol[i]) # n_sub = 0 # ns = 2* n_sub # print np.shape(org_frame) # stream = generate_stream_frame(org_frame, N_ant) # print np.shape(stream) frame = [] for i in range(N_ant): frame.append([]) for n_sub in range(10): N_CCE = get_n_cce_available(N_ant, N_rb_dl, cfi, N_g) pdcchs = get_all_pdcchs(N_CCE) n_groups = get_n_phich_groups(N_g, N_rb_dl) hi = [] for i in range(8*n_groups): hi.append(i%2) subframe = generate_subframe(pdcchs, hi, N_rb_dl, cell_id, N_ant, N_g, n_sub, cfi) for ant in range(N_ant): frame[ant].extend(subframe[ant]) for p in range(N_ant): frame[p] = map_pbch_to_frame_layer(frame[p], pbch[p], cell_id, sfn, p) frame[p] = frame_map_rs_symbols(frame[p], N_rb_dl, cell_id, Ncp, p) print np.shape(frame) print np.shape(org_frame) # for i in range(len(frame[0][0])): # print "{0}\t{1}\t{2}".format(i, frame[0][0][i], org_frame[0][0][i]) N_CCE = get_n_cce_available(N_ant, N_rb_dl, cfi, N_g) for i in range(len(N_rb_dl_lut)): N_rb_dl = N_rb_dl_lut[i] N_CCE = get_n_cce_available(N_ant, N_rb_dl, cfi, N_g) pos = get_pdcch_reg_pos(N_rb_dl, cell_id, N_g, cfi) print "{0}\t{1}\t{2}".format(N_CCE, N_CCE*9, np.shape(pos)) print "this is the END"