def test_002_t (self): # this models 4-QAM with 1 input stream v0 = (0,0,0,1,1,0,1,1) self.src = gr.vector_source_b(v0, False, len(v0)) self.map = drm.qam_map_vbvc(self.tables.d_QAM4, 2, len(v0)/2, 1) self.snk = gr.vector_sink_c(len(v0)/2) self.tb.connect(self.src, self.map, self.snk) self.tb.run() # check data res = self.snk.data() c = 0.7071067811 ref = ( complex(c, c), complex(c, -c), complex(-c, c), complex(-c, -c) ) self.assertComplexTuplesAlmostEqual(ref, res)
def __init__(self, vlen_in=1, vlen_out=1, n_tailbits=6, denom_mother_code_rate=6, gen_poly=(91, 121, 101, 91, 121, 101), N=1, bits_per_symbol=0, pp=0, pp_tail=0, interl_seq=range(2), map_tab=0): gr.hier_block2.__init__( self, "DRM MLC 4-QAM", gr.io_signature(1, 1, gr.sizeof_char*vlen_in), gr.io_signature(1, 1, gr.sizeof_gr_complex*vlen_out), ) ################################################## # Parameters ################################################## self.vlen_in = vlen_in self.vlen_out = vlen_out self.n_tailbits = n_tailbits self.denom_mother_code_rate = denom_mother_code_rate self.gen_poly = gen_poly self.N = N self.bits_per_symbol = bits_per_symbol self.pp = pp self.pp_tail = pp_tail self.interl_seq = interl_seq self.map_tab = map_tab ################################################## # Blocks ################################################## self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_char*1, vlen_in + n_tailbits) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_char*1, (vlen_in + n_tailbits) * denom_mother_code_rate) self.drm_qam_map_vbvc_0 = drm.qam_map_vbvc(map_tab, bits_per_symbol, vlen_out, 1) self.drm_punct_vbvb_0 = drm.punct_vbvb(pp, pp_tail, (vlen_in + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_interleaver_vbvb_0 = drm.interleaver_vbvb((interl_seq)) self.add_tailbits_vbvb_0 = drm.add_tailbits_vbvb(vlen_in, n_tailbits) ################################################## # Connections ################################################## self.connect((self, 0), (self.add_tailbits_vbvb_0, 0)) self.connect((self.add_tailbits_vbvb_0, 0), (self.gr_vector_to_stream_0, 0)) self.connect((self.gr_vector_to_stream_0, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.drm_punct_vbvb_0, 0)) self.connect((self.drm_punct_vbvb_0, 0), (self.drm_interleaver_vbvb_0, 0)) self.connect((self.drm_interleaver_vbvb_0, 0), (self.drm_qam_map_vbvc_0, 0)) self.connect((self.drm_qam_map_vbvc_0, 0), (self, 0))
def test_003_t (self): # this models 64-QAM SM (only some constellation points) with 3 input streams v0 = (0, 0, 0, 0, 1, 1, 1, 1) v1 = (1, 1, 0, 0, 1, 0, 1, 1) v2 = (1, 0, 0, 0, 0, 1, 1, 1) self.src0 = gr.vector_source_b(v0, False, len(v0)) self.src1 = gr.vector_source_b(v1, False, len(v1)) self.src2 = gr.vector_source_b(v2, False, len(v2)) self.map = drm.qam_map_vbvc(self.tables.d_QAM64SM, 6, len(v0)/2, 3) self.snk = gr.vector_sink_c(len(v0)/2) self.tb.connect(self.src0, (self.map, 0)) self.tb.connect(self.src1, (self.map, 1)) self.tb.connect(self.src2, (self.map, 2)) self.tb.connect(self.map, self.snk) self.tb.run() res = self.snk.data() c1 = 0.1543033499 c2 = 0.4629100498 c3 = 0.7715167498 c4 = 1.0801234497 ref = ( complex(-c3,c2), complex(c4,c4), complex(c1,-c2), complex(-c4,-c4) ) self.assertComplexTuplesAlmostEqual(ref, res)
def test_001_t (self): # this models 16-QAM mapping with 2 input streams v0 = (0,0,0,1,1,0,1,1) v1 = (0,1,1,1,0,0,1,0) self.src0 = gr.vector_source_b(v0, False, len(v0)) self.src1 = gr.vector_source_b(v1, False, len(v1)) self.map = drm.qam_map_vbvc(self.tables.d_QAM16, 4, len(v0)/2, 2) self.snk = gr.vector_sink_c(len(v0)/2) self.tb.connect(self.src0, (self.map, 0)) self.tb.connect(self.src1, (self.map, 1)) self.tb.connect(self.map, self.snk) self.tb.run () # check data res = self.snk.data() print res c1 = 0.9486832980 c2 = 0.3162277660 ref = ( complex(c1, -c2), \ complex(-c2, -c1), \ complex(c2, c1), \ complex(-c1, c2) ) print ref self.assertComplexTuplesAlmostEqual(ref, res)
def __init__(self, vlen_in=1, vlen_out=1, n_tailbits=6, denom_mother_code_rate=6, gen_poly=(91, 121, 101, 91, 121, 101), bits_per_symbol=0, N=1, map_tab=0, pp_0=0, pp_0_tail=0, pp_1=0, pp_1_tail=0, part_len_top=1, part_len_bot=1, M_total=0, interl_seq_0_2=range(2), interl_seq_1_2=range(2)): gr.hier_block2.__init__( self, "DRM MLC 16-QAM", gr.io_signature(1, 1, gr.sizeof_char*vlen_in), gr.io_signature(1, 1, gr.sizeof_gr_complex*vlen_out), ) ################################################## # Parameters ################################################## self.vlen_in = vlen_in self.vlen_out = vlen_out self.n_tailbits = n_tailbits self.denom_mother_code_rate = denom_mother_code_rate self.gen_poly = gen_poly self.bits_per_symbol = bits_per_symbol self.N = N self.map_tab = map_tab self.pp_0 = pp_0 self.pp_0_tail = pp_0_tail self.pp_1 = pp_1 self.pp_1_tail = pp_1_tail self.part_len_top = part_len_top self.part_len_bot = part_len_bot self.M_total = M_total self.interl_seq_0_2 = interl_seq_0_2 self.interl_seq_1_2 = interl_seq_1_2 ################################################## # Blocks ################################################## self.trellis_encoder_xx_0_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.gr_vector_to_stream_1_0 = gr.vector_to_stream(gr.sizeof_char*1, part_len_bot+ n_tailbits) self.gr_vector_to_stream_1 = gr.vector_to_stream(gr.sizeof_char*1, part_len_top + n_tailbits) self.gr_unpack_k_bits_bb_0_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_char*1, (part_len_bot + n_tailbits) * denom_mother_code_rate) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_char*1, (part_len_top + n_tailbits) * denom_mother_code_rate) self.drm_qam_map_vbvc_0 = drm.qam_map_vbvc(map_tab, bits_per_symbol, vlen_out, 2) self.drm_punct_vbvb_0_0 = drm.punct_vbvb(pp_1, pp_1_tail, (part_len_bot + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_punct_vbvb_0 = drm.punct_vbvb(pp_0, pp_0_tail, (part_len_top + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_partitioning_16_vbvb_0 = drm.partitioning_vbvb(vlen_in, M_total) self.drm_interleaver_vbvb_0_0 = drm.interleaver_vbvb((interl_seq_1_2)) self.drm_interleaver_vbvb_0 = drm.interleaver_vbvb((interl_seq_0_2)) self.add_tailbits_vbvb_0_0 = drm.add_tailbits_vbvb(part_len_bot, n_tailbits) self.add_tailbits_vbvb_0 = drm.add_tailbits_vbvb(part_len_top, n_tailbits) ################################################## # Connections ################################################## self.connect((self.drm_interleaver_vbvb_0, 0), (self.drm_qam_map_vbvc_0, 0)) self.connect((self.drm_qam_map_vbvc_0, 0), (self, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.drm_punct_vbvb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.drm_punct_vbvb_0, 0), (self.drm_interleaver_vbvb_0, 0)) self.connect((self.trellis_encoder_xx_0_0, 0), (self.gr_unpack_k_bits_bb_0_0, 0)) self.connect((self.gr_stream_to_vector_0_0, 0), (self.drm_punct_vbvb_0_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0_0, 0), (self.gr_stream_to_vector_0_0, 0)) self.connect((self.drm_punct_vbvb_0_0, 0), (self.drm_interleaver_vbvb_0_0, 0)) self.connect((self.drm_interleaver_vbvb_0_0, 0), (self.drm_qam_map_vbvc_0, 1)) self.connect((self.gr_vector_to_stream_1, 0), (self.trellis_encoder_xx_0, 0)) self.connect((self.gr_vector_to_stream_1_0, 0), (self.trellis_encoder_xx_0_0, 0)) self.connect((self, 0), (self.drm_partitioning_16_vbvb_0, 0)) self.connect((self.add_tailbits_vbvb_0, 0), (self.gr_vector_to_stream_1, 0)) self.connect((self.add_tailbits_vbvb_0_0, 0), (self.gr_vector_to_stream_1_0, 0)) self.connect((self.drm_partitioning_16_vbvb_0, 1), (self.add_tailbits_vbvb_0_0, 0)) self.connect((self.drm_partitioning_16_vbvb_0, 0), (self.add_tailbits_vbvb_0, 0))
def __init__(self, map_tab=0, n_tailbits=6, denom_mother_code_rate=6, gen_poly=(91, 121, 101, 91, 121, 101), vlen_out=1, vlen_in=1, N=1, bits_per_symbol=0, pp_0=0, pp_0_tail=0, interl_seq_0_2=range(2), part_len_top=1, M_total=0, part_len_mid=0, part_len_bot=1, pp_1=0, pp_2_tail=0, pp_2=0, pp_1_tail=0, interl_seq_1_2=range(2), interl_seq_2_2=range(2)): gr.hier_block2.__init__( self, "DRM MLC 64 QAM SM", gr.io_signature(1, 1, gr.sizeof_char*vlen_in), gr.io_signature(1, 1, gr.sizeof_gr_complex*vlen_out), ) ################################################## # Parameters ################################################## self.map_tab = map_tab self.n_tailbits = n_tailbits self.denom_mother_code_rate = denom_mother_code_rate self.gen_poly = gen_poly self.vlen_out = vlen_out self.vlen_in = vlen_in self.N = N self.bits_per_symbol = bits_per_symbol self.pp_0 = pp_0 self.pp_0_tail = pp_0_tail self.interl_seq_0_2 = interl_seq_0_2 self.part_len_top = part_len_top self.M_total = M_total self.part_len_mid = part_len_mid self.part_len_bot = part_len_bot self.pp_1 = pp_1 self.pp_2_tail = pp_2_tail self.pp_2 = pp_2 self.pp_1_tail = pp_1_tail self.interl_seq_1_2 = interl_seq_1_2 self.interl_seq_2_2 = interl_seq_2_2 ################################################## # Blocks ################################################## self.trellis_encoder_xx_0_0_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.trellis_encoder_xx_0_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.trellis_encoder_xx_0 = trellis.encoder_bb(trellis.fsm(1, denom_mother_code_rate, gen_poly), 0) self.gr_vector_to_stream_1_0_0 = gr.vector_to_stream(gr.sizeof_char*1, part_len_mid + n_tailbits) self.gr_vector_to_stream_1_0 = gr.vector_to_stream(gr.sizeof_char*1, part_len_bot+ n_tailbits) self.gr_vector_to_stream_1 = gr.vector_to_stream(gr.sizeof_char*1, part_len_top + n_tailbits) self.gr_unpack_k_bits_bb_0_0_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_unpack_k_bits_bb_0_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_unpack_k_bits_bb_0 = gr.unpack_k_bits_bb(denom_mother_code_rate) self.gr_stream_to_vector_0_0_0 = gr.stream_to_vector(gr.sizeof_char*1, (part_len_mid + n_tailbits) * denom_mother_code_rate) self.gr_stream_to_vector_0_0 = gr.stream_to_vector(gr.sizeof_char*1, (part_len_bot+ n_tailbits) * denom_mother_code_rate) self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_char*1, (part_len_top+ n_tailbits) * denom_mother_code_rate) self.drm_qam_map_vbvc_0 = drm.qam_map_vbvc(map_tab, bits_per_symbol, vlen_out, 3) self.drm_punct_vbvb_0_0_0 = drm.punct_vbvb(pp_1, pp_1_tail, (part_len_mid + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_punct_vbvb_0_0 = drm.punct_vbvb(pp_2, pp_2_tail, (part_len_bot + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_punct_vbvb_0 = drm.punct_vbvb(pp_0, pp_0_tail, (part_len_top + n_tailbits) * denom_mother_code_rate, vlen_out * 2, n_tailbits * denom_mother_code_rate) self.drm_partitioning_64sm_vbvb_0 = drm.partitioning_vbvb(vlen_in, M_total) self.drm_interleaver_vbvb_0_0_0 = drm.interleaver_vbvb((interl_seq_1_2)) self.drm_interleaver_vbvb_0_0 = drm.interleaver_vbvb((interl_seq_2_2)) self.add_tailbits_vbvb_0_0_0 = drm.add_tailbits_vbvb(part_len_mid, n_tailbits) self.add_tailbits_vbvb_0_0 = drm.add_tailbits_vbvb(part_len_bot, n_tailbits) self.add_tailbits_vbvb_0 = drm.add_tailbits_vbvb(part_len_top, n_tailbits) ################################################## # Connections ################################################## self.connect((self.add_tailbits_vbvb_0, 0), (self.gr_vector_to_stream_1, 0)) self.connect((self.trellis_encoder_xx_0, 0), (self.gr_unpack_k_bits_bb_0, 0)) self.connect((self.gr_stream_to_vector_0, 0), (self.drm_punct_vbvb_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_stream_to_vector_0, 0)) self.connect((self.drm_qam_map_vbvc_0, 0), (self, 0)) self.connect((self.drm_punct_vbvb_0, 0), (self.drm_qam_map_vbvc_0, 0)) self.connect((self, 0), (self.drm_partitioning_64sm_vbvb_0, 0)) self.connect((self.drm_partitioning_64sm_vbvb_0, 0), (self.add_tailbits_vbvb_0, 0)) self.connect((self.drm_partitioning_64sm_vbvb_0, 2), (self.add_tailbits_vbvb_0_0, 0)) self.connect((self.drm_punct_vbvb_0_0, 0), (self.drm_interleaver_vbvb_0_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0_0, 0), (self.gr_stream_to_vector_0_0, 0)) self.connect((self.gr_stream_to_vector_0_0, 0), (self.drm_punct_vbvb_0_0, 0)) self.connect((self.trellis_encoder_xx_0_0, 0), (self.gr_unpack_k_bits_bb_0_0, 0)) self.connect((self.drm_punct_vbvb_0_0_0, 0), (self.drm_interleaver_vbvb_0_0_0, 0)) self.connect((self.gr_unpack_k_bits_bb_0_0_0, 0), (self.gr_stream_to_vector_0_0_0, 0)) self.connect((self.gr_stream_to_vector_0_0_0, 0), (self.drm_punct_vbvb_0_0_0, 0)) self.connect((self.trellis_encoder_xx_0_0_0, 0), (self.gr_unpack_k_bits_bb_0_0_0, 0)) self.connect((self.add_tailbits_vbvb_0_0, 0), (self.gr_vector_to_stream_1_0, 0)) self.connect((self.add_tailbits_vbvb_0_0_0, 0), (self.gr_vector_to_stream_1_0_0, 0)) self.connect((self.drm_partitioning_64sm_vbvb_0, 1), (self.add_tailbits_vbvb_0_0_0, 0)) self.connect((self.drm_interleaver_vbvb_0_0, 0), (self.drm_qam_map_vbvc_0, 2)) self.connect((self.drm_interleaver_vbvb_0_0_0, 0), (self.drm_qam_map_vbvc_0, 1)) self.connect((self.gr_vector_to_stream_1_0_0, 0), (self.trellis_encoder_xx_0_0_0, 0)) self.connect((self.gr_vector_to_stream_1_0, 0), (self.trellis_encoder_xx_0_0, 0)) self.connect((self.gr_vector_to_stream_1, 0), (self.trellis_encoder_xx_0, 0))