Ejemplo n.º 1
0
 def test_001_t(self):
     data = (0x05, 0x00, 0x10, 0xEA, 0x04, 0x24, 0x06, 0x02, 0xD3, 0xA6,
             0x01, 0x3F, 0x06, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x4C, 0x89)
     src = blocks.vector_source_b(data, True)
     fibout = blocks.stream_to_vector(1, 32)
     fibsink = dab.fib_sink_vb()
     self.tb.connect(src, blocks.head(gr.sizeof_char, 300), fibout, fibsink)
     self.tb.run()
     pass
Ejemplo n.º 2
0
 def test_001_t(self):
     src = dab.fib_source_b_make(1, 1, 'Galaxy_News', 'Wasteland_Radio',
                                 'Country_Mix', 0x09, [0], [8])
     fib_unpacked_to_packed = blocks.unpacked_to_packed_bb(
         1, gr.GR_MSB_FIRST)
     s2v = blocks.stream_to_vector(gr.sizeof_char, 32)
     crc16 = dab.crc16_bb(32, 0x1021, 0xffff)
     fibsink = dab.fib_sink_vb()
     self.tb.connect(src, fib_unpacked_to_packed,
                     blocks.head(gr.sizeof_char, 300), s2v, crc16, fibsink)
     self.tb.run()
     pass
Ejemplo n.º 3
0
    def __init__(self, dab_params, verbose=False, debug=False):
        """
        Hierarchical block for FIC decoding

        @param dab_params DAB parameter object (dab.parameters.dab_parameters)
        """
        gr.hier_block2.__init__(
            self, "fic",
            gr.io_signature2(2, 2,
                             gr.sizeof_float * dab_params.num_carriers * 2,
                             gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_char * 32))

        self.dp = dab_params
        self.verbose = verbose
        self.debug = debug

        # FIB selection and block partitioning
        self.select_fic_syms = dab.select_vectors(gr.sizeof_float,
                                                  self.dp.num_carriers * 2,
                                                  self.dp.num_fic_syms, 0)
        self.repartition_fic = dab.repartition_vectors(
            gr.sizeof_float, self.dp.num_carriers * 2,
            self.dp.fic_punctured_codeword_length, self.dp.num_fic_syms,
            self.dp.num_cifs)

        # unpuncturing
        self.unpuncture = dab.unpuncture_vff(
            self.dp.assembled_fic_puncturing_sequence, 0)

        # convolutional coding
        # self.fsm = trellis.fsm(self.dp.conv_code_in_bits, self.dp.conv_code_out_bits, self.dp.conv_code_generator_polynomials)
        self.fsm = trellis.fsm(
            1, 4, [0133, 0171, 0145, 0133
                   ])  # OK (dumped to text and verified partially)
        self.conv_v2s = blocks.vector_to_stream(
            gr.sizeof_float, self.dp.fic_conv_codeword_length)
        # self.conv_decode = trellis.viterbi_combined_fb(self.fsm, 20, 0, 0, 1, [1./sqrt(2),-1/sqrt(2)] , trellis.TRELLIS_EUCLIDEAN)
        table = [
            0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1,
            0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0,
            1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1
        ]
        assert (len(table) / 4 == self.fsm.O())
        table = [(1 - 2 * x) / sqrt(2) for x in table]
        self.conv_decode = trellis.viterbi_combined_fb(
            self.fsm, 774, 0, 0, 4, table, trellis.TRELLIS_EUCLIDEAN)
        #self.conv_s2v = blocks.stream_to_vector(gr.sizeof_char, 774)
        self.conv_prune = dab.prune(gr.sizeof_char,
                                    self.dp.fic_conv_codeword_length / 4, 0,
                                    self.dp.conv_code_add_bits_input)

        # energy dispersal
        self.prbs_src = blocks.vector_source_b(
            self.dp.prbs(self.dp.energy_dispersal_fic_vector_length), True)
        #self.energy_v2s = blocks.vector_to_stream(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
        self.add_mod_2 = blocks.xor_bb()
        self.energy_s2v = blocks.stream_to_vector(
            gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
        self.cut_into_fibs = dab.repartition_vectors(
            gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length,
            self.dp.fib_bits, 1, self.dp.energy_dispersal_fic_fibs_per_vector)

        # connect all
        self.nullsink = blocks.null_sink(gr.sizeof_char)
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.fibout = blocks.stream_to_vector(1, 32)
        # self.filesink = gr.file_sink(gr.sizeof_char, "debug/fic.dat")
        self.fibsink = dab.fib_sink_vb()

        # self.connect((self,0), (self.select_fic_syms,0), (self.repartition_fic,0), self.unpuncture, self.conv_v2s, self.conv_decode, self.conv_s2v, self.conv_prune, self.energy_v2s, self.add_mod_2, self.energy_s2v, (self.cut_into_fibs,0), gr.vector_to_stream(1,256), gr.unpacked_to_packed_bb(1,gr.GR_MSB_FIRST), self.filesink)
        self.connect(
            (self, 0),
            (self.select_fic_syms, 0),
            (self.repartition_fic, 0),
            self.unpuncture,
            self.conv_v2s,
            self.conv_decode,
            #self.conv_s2v,
            self.conv_prune,
            #self.energy_v2s,
            self.add_mod_2,
            self.energy_s2v,
            (self.cut_into_fibs, 0),
            blocks.vector_to_stream(1, 256),
            self.pack,
            self.fibout,
            self.fibsink)
        self.connect(self.fibout, self)
        self.connect(self.prbs_src, (self.add_mod_2, 1))
        self.connect((self, 1), (self.select_fic_syms, 1),
                     (self.repartition_fic, 1), (self.cut_into_fibs, 1),
                     self.nullsink)

        if self.debug:
            self.connect(
                (self, 0),
                blocks.file_sink(gr.sizeof_float * self.dp.num_carriers * 2,
                                 "debug/transmission_frame.dat"))
            self.connect(
                (self, 1),
                blocks.file_sink(gr.sizeof_char,
                                 "debug/transmission_frame_trigger.dat"))
            self.connect(
                self.select_fic_syms,
                blocks.file_sink(gr.sizeof_float * self.dp.num_carriers * 2,
                                 "debug/fic_select_syms.dat"))
            self.connect(
                self.repartition_fic,
                blocks.file_sink(
                    gr.sizeof_float * self.dp.fic_punctured_codeword_length,
                    "debug/fic_repartitioned.dat"))
            self.connect(
                self.unpuncture,
                blocks.file_sink(
                    gr.sizeof_float * self.dp.fic_conv_codeword_length,
                    "debug/fic_unpunctured.dat"))
            self.connect(
                self.conv_decode,
                blocks.file_sink(gr.sizeof_char, "debug/fic_decoded.dat"))
            self.connect(
                self.conv_prune,
                blocks.file_sink(gr.sizeof_char,
                                 "debug/fic_decoded_pruned.dat"))
            #self.connect(self.conv_decode, blocks.file_sink(gr.sizeof_char * self.dp.energy_dispersal_fic_vector_length, "debug/fic_energy_dispersal_undone.dat"))
            self.connect(
                self.pack,
                blocks.file_sink(gr.sizeof_char,
                                 "debug/fic_energy_undone.dat"))
Ejemplo n.º 4
0
	def __init__(self, dab_params, verbose=True, debug=False):
		"""
		Hierarchical block for FIC decoding
		
		@param dab_params DAB parameter object (dab.parameters.dab_parameters)
		"""
		gr.hier_block2.__init__(self,"fic",
					gr.io_signature2(2, 2, gr.sizeof_float*dab_params.num_carriers*2, gr.sizeof_char), # input
					gr.io_signature(1, 1, gr.sizeof_char*32)) # output signature

		self.dp = dab_params
		self.verbose = verbose
		self.debug = debug
		
		
		# FIB selection and block partitioning
		self.select_fic_syms = dab.select_vectors(gr.sizeof_float, self.dp.num_carriers*2, self.dp.num_fic_syms, 0)
		self.repartition_fic = dab.repartition_vectors(gr.sizeof_float, self.dp.num_carriers*2, self.dp.fic_punctured_codeword_length, self.dp.num_fic_syms, self.dp.num_cifs)

		# unpuncturing
		self.unpuncture = dab.unpuncture_vff(self.dp.assembled_fic_puncturing_sequence,0)

		# convolutional coding
		# self.fsm = trellis.fsm(self.dp.conv_code_in_bits, self.dp.conv_code_out_bits, self.dp.conv_code_generator_polynomials)
		self.fsm = trellis.fsm(1, 4, [0133, 0171, 0145, 0133]) # OK (dumped to text and verified partially)
		self.conv_v2s = blocks.vector_to_stream(gr.sizeof_float, self.dp.fic_conv_codeword_length)
		# self.conv_decode = trellis.viterbi_combined_fb(self.fsm, 20, 0, 0, 1, [1./sqrt(2),-1/sqrt(2)] , trellis.TRELLIS_EUCLIDEAN)
		table = [ 
			  0,0,0,0,
			  0,0,0,1,
			  0,0,1,0,
			  0,0,1,1,
			  0,1,0,0,
			  0,1,0,1,
			  0,1,1,0,
			  0,1,1,1,
			  1,0,0,0,
			  1,0,0,1,
			  1,0,1,0,
			  1,0,1,1,
			  1,1,0,0,
			  1,1,0,1,
			  1,1,1,0,
			  1,1,1,1
			]
		assert(len(table)/4==self.fsm.O())
		table = [(1-2*x)/sqrt(2) for x in table]
		self.conv_decode = trellis.viterbi_combined_fb(self.fsm, 774, 0, 0, 4, table, trellis.TRELLIS_EUCLIDEAN)
		self.conv_s2v = blocks.stream_to_vector(gr.sizeof_char, 774)
		self.conv_prune = dab.prune_vectors(gr.sizeof_char, self.dp.fic_conv_codeword_length/4, 0, self.dp.conv_code_add_bits_input)

		# energy dispersal
		self.prbs_src   = blocks.vector_source_b(self.dp.prbs(self.dp.energy_dispersal_fic_vector_length), True)
		self.energy_v2s = blocks.vector_to_stream(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
		self.add_mod_2  = blocks.xor_bb()
		self.energy_s2v = blocks.stream_to_vector(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length)
		self.cut_into_fibs = dab.repartition_vectors(gr.sizeof_char, self.dp.energy_dispersal_fic_vector_length, self.dp.fib_bits, 1, self.dp.energy_dispersal_fic_fibs_per_vector)
		
		# connect all
		self.nullsink = blocks.null_sink(gr.sizeof_char)
                self.fibout = blocks.stream_to_vector(1,32)
		# self.filesink = gr.file_sink(gr.sizeof_char, "debug/fic.dat")
		self.fibsink = dab.fib_sink_vb()
		
		# self.connect((self,0), (self.select_fic_syms,0), (self.repartition_fic,0), self.unpuncture, self.conv_v2s, self.conv_decode, self.conv_s2v, self.conv_prune, self.energy_v2s, self.add_mod_2, self.energy_s2v, (self.cut_into_fibs,0), gr.vector_to_stream(1,256), gr.unpacked_to_packed_bb(1,gr.GR_MSB_FIRST), self.filesink)
		self.connect((self,0),
                             (self.select_fic_syms,0),
                             (self.repartition_fic,0),
                             self.unpuncture,
                             self.conv_v2s,
                             self.conv_decode,
                             self.conv_s2v,
                             self.conv_prune,
                             self.energy_v2s,
                             self.add_mod_2,
                             self.energy_s2v,
                             (self.cut_into_fibs,0),
                             blocks.vector_to_stream(1,256),
                             blocks.unpacked_to_packed_bb(1,gr.GR_MSB_FIRST),
                             self.fibout,
                             self.fibsink)
                self.connect(self.fibout, self)
		self.connect(self.prbs_src, (self.add_mod_2,1))
		self.connect((self,1), (self.select_fic_syms,1), (self.repartition_fic,1), (self.cut_into_fibs,1), self.nullsink)

		if self.debug:
			self.connect(self.select_fic_syms, blocks.file_sink(gr.sizeof_float*self.dp.num_carriers*2, "debug/fic_select_syms.dat"))
			self.connect(self.repartition_fic, blocks.file_sink(gr.sizeof_float*self.dp.fic_punctured_codeword_length, "debug/fic_repartitioned.dat"))
			self.connect(self.unpuncture, blocks.file_sink(gr.sizeof_float*self.dp.fic_conv_codeword_length, "debug/fic_unpunctured.dat"))
			self.connect(self.conv_decode, blocks.file_sink(gr.sizeof_char, "debug/fic_decoded.dat"))
			self.connect(self.energy_s2v, blocks.file_sink(gr.sizeof_char*self.dp.energy_dispersal_fic_vector_length, "debug/fic_energy_dispersal_undone.dat"))