def test_001_t (self): log = gr.logger("log") if os.path.exists("debug/rs_encoded.dat") and os.path.exists("debug/rs_encoded.dat"): self.dp = dab.parameters.dab_parameters(1, 208.064e6, True) # sources self.fib_src = dab.fib_source_b_make(1, 1, 'Galaxy_News', 'Wasteland_Radio', 'Country_Mix01', 0x09, [2], [14]) self.fib_pack = blocks.unpacked_to_packed_bb_make(1, gr.GR_MSB_FIRST) self.subch_src01 = blocks.file_source_make(gr.sizeof_char, "debug/rs_encoded.dat", True) self.subch_src02 = blocks.file_source_make(gr.sizeof_char, "debug/rs_encoded_2.dat", True) # encoder self.fib_enc = dab.fic_encode(self.dp) self.msc_encoder = dab.msc_encode(self.dp, 14, 2) self.msc_encoder2 = dab.msc_encode(self.dp, 14, 2) # multiplexer self.mux = dab.dab_transmission_frame_mux_bb_make(1, 2, [84, 84]) # mapper self.unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) self.map = dab.mapper_bc_make(self.dp.num_carriers) # demapper self.s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, self.dp.num_carriers) self.soft_interleaver = dab.complex_to_interleaved_float_vcf_make(self.dp.num_carriers) # decode self.fic_decoder = dab.fic_decode(self.dp) self.msc_dec = dab.dabplus_audio_decoder_ff(self.dp, 112, 0, 84, 2, True) # audio sink self.audio = audio.sink_make(32000) # control stream self.trigger_src = blocks.vector_source_b([1] + [0] * 74, True) # connect everything self.tb.connect(self.fib_src, self.fib_enc, (self.mux, 0)) self.tb.connect(self.subch_src01, self.msc_encoder, (self.mux, 1)) self.tb.connect(self.subch_src02, self.msc_encoder2, (self.mux, 2)) self.tb.connect((self.mux, 0), self.unpack, self.map, self.s2v, self.soft_interleaver, (self.msc_dec, 0)) self.tb.connect(self.soft_interleaver, (self.fic_decoder, 0)) self.tb.connect(self.trigger_src, (self.fic_decoder, 1)) self.tb.connect(self.trigger_src, (self.msc_dec, 1)) self.tb.connect((self.msc_dec, 0), (self.audio, 0)) self.tb.connect((self.msc_dec, 1), (self.audio, 1)) self.tb.run () pass else: log.debug("debug file not found - skipped test") log.set_level("WARN") pass
def test_001_t (self): self.symbol_length = 32*4 self.dab_params = dab_parameters(1, 208.064e6, True) # source self.dp = dab_parameters(1, 208.064e6, True) self.fib_src = dab.fib_source_b_make(1, 1, 1, "ensemble1", "service1 ", "musicmix", 4, [2], [15], [1]) # encoder self.fib_enc = fic_encode(self.dab_params) self.unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) # mapper self.map = dab.mapper_bc_make(self.dp.num_carriers) # demapper self.s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, self.dp.num_carriers) self.soft_interleaver = dab.complex_to_interleaved_float_vcf_make(self.dp.num_carriers) # decode self.fic_decoder = fic_decode(self.dab_params) # control stream self.trigger_src = blocks.vector_source_b([1] + [0]*74, True) self.tb.connect(self.fib_src, blocks.head_make(gr.sizeof_char, 100000), self.fib_enc, self.unpack, self.map, self.s2v, self.soft_interleaver, self.fic_decoder ) self.tb.connect(self.trigger_src, (self.fic_decoder, 1)) self.tb.run () pass
def __init__(self, dab_params, data_rate_n, protection): gr.hier_block2.__init__(self, "msc_encode", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature self.dp = dab_params self.n = data_rate_n self.msc_I = self.n * 192 self.protect = protection # unpack self.unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) # energy dispersal self.prbs_src = blocks.vector_source_b(self.dp.prbs(self.msc_I), True) self.add_mod_2 = blocks.xor_bb() # convolutional encoder self.conv_pack = blocks.unpacked_to_packed_bb_make(1, gr.GR_MSB_FIRST) self.conv_encoder = dab.conv_encoder_bb_make(self.msc_I / 8) self.conv_unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) # calculate puncturing factors (EEP, table 33, 34) if (self.n > 1 or self.protect != 1): self.puncturing_L1 = [6 * self.n - 3, 2 * self.n - 3, 6 * self.n - 3, 4 * self.n - 3] self.puncturing_L2 = [3, 4 * self.n + 3, 3, 2 * self.n + 3] self.puncturing_PI1 = [24, 14, 8, 3] self.puncturing_PI2 = [23, 13, 7, 2] # calculate length of punctured codeword (11.3.2) self.msc_punctured_codeword_length = self.puncturing_L1[self.protect] * 4 * self.dp.puncturing_vectors_ones[ self.puncturing_PI1[self.protect]] + self.puncturing_L2[self.protect] * 4 * \ self.dp.puncturing_vectors_ones[ self.puncturing_PI2[self.protect]] + 12 self.assembled_msc_puncturing_sequence = self.puncturing_L1[self.protect] * 4 * self.dp.puncturing_vectors[ self.puncturing_PI1[self.protect]] + self.puncturing_L2[self.protect] * 4 * self.dp.puncturing_vectors[ self.puncturing_PI2[self.protect]] + self.dp.puncturing_tail_vector self.msc_conv_codeword_length = 4 * self.msc_I + 24 # 4*I + 24 () # exception in table else: self.msc_punctured_codeword_length = 5 * 4 * self.dp.puncturing_vectors_ones[13] + 1 * 4 * \ self.dp.puncturing_vectors_ones[ 12] + 12 # sanity check assert (6 * self.n == self.puncturing_L1[self.protect] + self.puncturing_L2[self.protect]) # puncturing self.puncture = dab.puncture_bb_make(self.assembled_msc_puncturing_sequence) # time interleaving self.s2v_time_interleave = blocks.stream_to_vector_make(gr.sizeof_char, self.msc_punctured_codeword_length) self.time_interleaver = dab.time_interleave_bb_make(self.msc_punctured_codeword_length, self.dp.scrambling_vector) self.v2s_time_interleave = blocks.vector_to_stream_make(gr.sizeof_char, self.msc_punctured_codeword_length) # pack bits self.unpacked_to_packed_encoded = blocks.unpacked_to_packed_bb_make(1, gr.GR_MSB_FIRST) # connect everything self.connect(self, self.unpack, self.add_mod_2, self.conv_pack, self.conv_encoder, self.conv_unpack, self.puncture, self.s2v_time_interleave, self.time_interleaver, self.v2s_time_interleave, self.unpacked_to_packed_encoded, self) # connect prbs self.connect(self.prbs_src, (self.add_mod_2, 1))
def __init__(self, dab_params, verbose=False, debug=False): """ Hierarchical block for OFDM modulation @param dab_params DAB parameter object (grdab.parameters.dab_parameters) @param debug enables debug output to files """ dp = dab_params gr.hier_block2.__init__( self, "ofdm_mod", gr.io_signature2(2, 2, gr.sizeof_char * dp.num_carriers / 4, gr.sizeof_char), # input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # output signature # symbol mapping self.mapper_v2s = blocks.vector_to_stream_make(gr.sizeof_char, 384) self.mapper_unpack = blocks.packed_to_unpacked_bb_make( 1, gr.GR_MSB_FIRST) self.mapper = grdab.mapper_bc_make(dp.num_carriers) self.mapper_s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, 1536) # add pilot symbol self.insert_pilot = grdab.ofdm_insert_pilot_vcc(dp.prn) # phase sum self.sum_phase = grdab.sum_phasor_trig_vcc(dp.num_carriers) # frequency interleaving self.interleave = grdab.frequency_interleaver_vcc( dp.frequency_interleaving_sequence_array) # add central carrier & move to middle self.move_and_insert_carrier = grdab.ofdm_move_and_insert_zero( dp.fft_length, dp.num_carriers) # ifft self.ifft = fft.fft_vcc(dp.fft_length, False, [], True) # cyclic prefixer self.prefixer = digital.ofdm_cyclic_prefixer(dp.fft_length, dp.symbol_length) # convert back to vectors self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, dp.symbol_length) # add null symbol self.insert_null = grdab.insert_null_symbol(dp.ns_length, dp.symbol_length) # # connect it all # # data self.connect((self, 0), self.mapper_v2s, self.mapper_unpack, self.mapper, self.mapper_s2v, (self.insert_pilot, 0), (self.sum_phase, 0), self.interleave, self.move_and_insert_carrier, self.ifft, self.prefixer, self.s2v, (self.insert_null, 0)) self.connect(self.insert_null, self) # control signal (frame start) self.connect((self, 1), (self.insert_pilot, 1), (self.sum_phase, 1), (self.insert_null, 1)) if debug: #self.connect(self.mapper, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_mapper.dat")) self.connect( self.insert_pilot, blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers, "debug/generated_signal_insert_pilot.dat")) self.connect( self.sum_phase, blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers, "debug/generated_signal_sum_phase.dat")) self.connect( self.interleave, blocks.file_sink(gr.sizeof_gr_complex * dp.num_carriers, "debug/generated_signal_interleave.dat")) self.connect( self.move_and_insert_carrier, blocks.file_sink( gr.sizeof_gr_complex * dp.fft_length, "debug/generated_signal_move_and_insert_carrier.dat")) self.connect( self.ifft, blocks.file_sink(gr.sizeof_gr_complex * dp.fft_length, "debug/generated_signal_ifft.dat")) self.connect( self.prefixer, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal_prefixer.dat")) self.connect( self.insert_null, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal.dat"))
def __init__(self, dab_params, verbose=False, debug=False): """ Hierarchical block for OFDM modulation @param dab_params DAB parameter object (grdab.parameters.dab_parameters) @param debug enables debug output to files """ dp = dab_params gr.hier_block2.__init__(self,"ofdm_mod", gr.io_signature2(2, 2, gr.sizeof_char*dp.num_carriers/4, gr.sizeof_char), # input signature gr.io_signature (1, 1, gr.sizeof_gr_complex)) # output signature # symbol mapping self.mapper_v2s = blocks.vector_to_stream_make(gr.sizeof_char, 384) self.mapper_unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) self.mapper = grdab.mapper_bc_make(dp.num_carriers) self.mapper_s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, 1536) # add pilot symbol self.insert_pilot = grdab.ofdm_insert_pilot_vcc(dp.prn) # phase sum self.sum_phase = grdab.sum_phasor_trig_vcc(dp.num_carriers) # frequency interleaving self.interleave = grdab.frequency_interleaver_vcc(dp.frequency_interleaving_sequence_array) # add central carrier & move to middle self.move_and_insert_carrier = grdab.ofdm_move_and_insert_zero(dp.fft_length, dp.num_carriers) # ifft self.ifft = fft.fft_vcc(dp.fft_length, False, [], True) # cyclic prefixer self.prefixer = digital.ofdm_cyclic_prefixer(dp.fft_length, dp.symbol_length) # convert back to vectors self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, dp.symbol_length) # add null symbol self.insert_null = grdab.insert_null_symbol(dp.ns_length, dp.symbol_length) # # connect it all # # data self.connect((self,0), self.mapper_v2s, self.mapper_unpack, self.mapper, self.mapper_s2v, (self.insert_pilot,0), (self.sum_phase,0), self.interleave, self.move_and_insert_carrier, self.ifft, self.prefixer, self.s2v, (self.insert_null,0)) self.connect(self.insert_null, self) # control signal (frame start) self.connect((self,1), (self.insert_pilot,1), (self.sum_phase,1), (self.insert_null,1)) if debug: #self.connect(self.mapper, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_mapper.dat")) self.connect(self.insert_pilot, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_insert_pilot.dat")) self.connect(self.sum_phase, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_sum_phase.dat")) self.connect(self.interleave, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_interleave.dat")) self.connect(self.move_and_insert_carrier, blocks.file_sink(gr.sizeof_gr_complex*dp.fft_length, "debug/generated_signal_move_and_insert_carrier.dat")) self.connect(self.ifft, blocks.file_sink(gr.sizeof_gr_complex*dp.fft_length, "debug/generated_signal_ifft.dat")) self.connect(self.prefixer, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal_prefixer.dat")) self.connect(self.insert_null, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal.dat"))