def __init__(self, constellation, differential, rotation): if constellation.arity() > 256: # If this becomes limiting some of the blocks should be generalised so # that they can work with shorts and ints as well as chars. raise ValueError("Constellation cannot contain more than 256 points.") gr.hier_block2.__init__( self, "mod_demod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_char), ) # Output signature arity = constellation.arity() # TX self.constellation = constellation self.differential = differential self.blocks = [self] # We expect a stream of unpacked bits. # First step is to pack them. self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)) # Second step we unpack them such that we have k bits in each byte where # each constellation symbol hold k bits. self.blocks.append(blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(), gr.GR_MSB_FIRST)) # Apply any pre-differential coding # Gray-coding is done here if we're also using differential coding. if self.constellation.apply_pre_diff_code(): self.blocks.append(digital.map_bb(self.constellation.pre_diff_code())) # Differential encoding. if self.differential: self.blocks.append(digital.diff_encoder_bb(arity)) # Convert to constellation symbols. self.blocks.append( digital.chunks_to_symbols_bc(self.constellation.points(), self.constellation.dimensionality()) ) # CHANNEL # Channel just consists of a rotation to check differential coding. if rotation is not None: self.blocks.append(blocks.multiply_const_cc(rotation)) # RX # Convert the constellation symbols back to binary values. self.blocks.append(digital.constellation_decoder_cb(self.constellation.base())) # Differential decoding. if self.differential: self.blocks.append(digital.diff_decoder_bb(arity)) # Decode any pre-differential coding. if self.constellation.apply_pre_diff_code(): self.blocks.append(digital.map_bb(mod_codes.invert_code(self.constellation.pre_diff_code()))) # unpack the k bit vector into a stream of bits self.blocks.append(blocks.unpack_k_bits_bb(self.constellation.bits_per_symbol())) # connect to block output check_index = len(self.blocks) self.blocks = self.blocks[:check_index] self.blocks.append(self) self.connect(*self.blocks)
def __init__(self, constellation, differential, rotation): if constellation.arity() > 256: # If this becomes limiting some of the blocks should be generalised so # that they can work with shorts and ints as well as chars. raise ValueError( "Constellation cannot contain more than 256 points.") gr.hier_block2.__init__( self, "mod_demod", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature arity = constellation.arity() # TX self.constellation = constellation self.differential = differential self.blocks = [self] # We expect a stream of unpacked bits. # First step is to pack them. self.blocks.append(blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)) # Second step we unpack them such that we have k bits in each byte where # each constellation symbol hold k bits. self.blocks.append( blocks.packed_to_unpacked_bb(self.constellation.bits_per_symbol(), gr.GR_MSB_FIRST)) # Apply any pre-differential coding # Gray-coding is done here if we're also using differential coding. if self.constellation.apply_pre_diff_code(): self.blocks.append( digital.map_bb(self.constellation.pre_diff_code())) # Differential encoding. if self.differential: self.blocks.append(digital.diff_encoder_bb(arity)) # Convert to constellation symbols. self.blocks.append( digital.chunks_to_symbols_bc(self.constellation.points(), self.constellation.dimensionality())) # CHANNEL # Channel just consists of a rotation to check differential coding. if rotation is not None: self.blocks.append(blocks.multiply_const_cc(rotation)) # RX # Convert the constellation symbols back to binary values. self.blocks.append( digital.constellation_decoder_cb(self.constellation.base())) # Differential decoding. if self.differential: self.blocks.append(digital.diff_decoder_bb(arity)) # Decode any pre-differential coding. if self.constellation.apply_pre_diff_code(): self.blocks.append( digital.map_bb( mod_codes.invert_code(self.constellation.pre_diff_code()))) # unpack the k bit vector into a stream of bits self.blocks.append( blocks.unpack_k_bits_bb(self.constellation.bits_per_symbol())) # connect to block output check_index = len(self.blocks) self.blocks = self.blocks[:check_index] self.blocks.append(self) self.connect(*self.blocks)
def test_multiply_const_cc2(self): src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) expected_result = (-3-7j, 0+0j, 3+7j, 6+14j, 9+21j) op = blocks_swig.multiply_const_cc(5+2j) self.help_cc((src_data,), expected_result, op)
def test_multiply_const_cc(self): src_data = (-1-1j, 0+0j, 1+1j, 2+2j, 3+3j) expected_result = (-5-5j, 0+0j, 5+5j, 10+10j, 15+15j) op = blocks_swig.multiply_const_cc(5) self.help_cc((src_data,), expected_result, op)
def test_multiply_const_cc2(self): src_data = (-1 - 1j, 0 + 0j, 1 + 1j, 2 + 2j, 3 + 3j) expected_result = (-3 - 7j, 0 + 0j, 3 + 7j, 6 + 14j, 9 + 21j) op = blocks_swig.multiply_const_cc(5 + 2j) self.help_cc((src_data, ), expected_result, op)
def test_multiply_const_cc(self): src_data = (-1 - 1j, 0 + 0j, 1 + 1j, 2 + 2j, 3 + 3j) expected_result = (-5 - 5j, 0 + 0j, 5 + 5j, 10 + 10j, 15 + 15j) op = blocks_swig.multiply_const_cc(5) self.help_cc((src_data, ), expected_result, op)