Ejemplo n.º 1
0
def test_mod_cpm():
    tb = gr.top_block()
    precode = mlse.xor_encode_bb()
    nrz = gr.map_bb([1, -1])
    mod = gr.gmskmod_bc(1, 0.3, 4)
    #src = gr.vector_source_b([0,0,0,0,1,1,1,1,0,0])
    #src = gr.vector_source_b([1,1,0,0,1,0,0,1,1,1,0,0,0,0])
    src = gr.vector_source_b((1, ) * 1000)
    sink = gr.vector_sink_c()
    derot = mlse.derotate_cc(1, 4)
    tb.connect(src, precode, nrz, mod, derot, sink)
    precode_probe = gr.vector_sink_b()
    tb.connect(nrz, precode_probe)
    tb.run()
    d = sink.data()
    from cmath import phase, pi, rect
    real = lambda x: x.real
    import operator
    d_r = d  #list(decimate(d,5,2))
    d2 = [int(round((phase(i) / pi) * 100)) for i in d]
    derotate = [(-1j)**(i + 1) for i in range(len(d_r))]
    d3 = map(operator.mul, d_r, derotate)
    #    print "\n".join(map(str,map(real,d3)))
    print precode_probe.data()
    #    print "\n".join(map(str,map(phase,d)))
    print "\n".join([str(phase(i) / pi) for i in d])
    print len(d)
    print derotate
Ejemplo n.º 2
0
def test_mod_cpm():
    tb = gr.top_block()
    precode = mlse.xor_encode_bb()
    nrz = gr.map_bb([1,-1])
    mod = gr.gmskmod_bc(1,0.3,4)
    #src = gr.vector_source_b([0,0,0,0,1,1,1,1,0,0])
    #src = gr.vector_source_b([1,1,0,0,1,0,0,1,1,1,0,0,0,0])
    src = gr.vector_source_b((1,)*1000)
    sink = gr.vector_sink_c()
    derot = mlse.derotate_cc(1,4)
    tb.connect(src, precode, nrz, mod, derot, sink)
    precode_probe = gr.vector_sink_b()
    tb.connect(nrz, precode_probe)
    tb.run()
    d = sink.data()
    from cmath import phase, pi, rect
    real = lambda x: x.real
    import operator
    d_r = d#list(decimate(d,5,2))
    d2 = [ int(round((phase(i)/pi)*100)) for i in d ]
    derotate = [ (-1j)**(i+1) for i in range(len(d_r))]
    d3 = map(operator.mul, d_r, derotate)
#    print "\n".join(map(str,map(real,d3)))
    print precode_probe.data()
#    print "\n".join(map(str,map(phase,d)))
    print "\n".join([str(phase(i)/pi) for i in d])
    print len(d)
    print derotate
Ejemplo n.º 3
0
def test_viterbi():
    tb=gr.top_block()
    channel = [0,1,0]
    prellen = len(channel) - 1
    data = [random.randint(0,1) for i in xrange(20+prellen)]
    data.extend([0,0,0]) # tailbits
    data.extend([0]*6) # to flush modulator


    # modulate
    datasrc = gr.vector_source_b(data)
    diffcode = mlse.xor_encode_bb();
    nrz = gr.map_bb([1,-1])
    mod = gr.gmskmod_bc(1, 0.3, 12)
    derot = mlse.derotate_cc();
    modsink = gr.vector_sink_c();
    tb.connect(datasrc, diffcode, nrz, mod, derot, modsink)
    tb.run()

    samples = modsink.data()[6:]
    printvect_c(samples)


    preload = data[:prellen]
    rest = data[prellen:][:20]

    tb=gr.top_block()
    conf=mlse.make_packet_config_gsm()
    vit = mlse.viterbi_vcb(20,len(channel),3,[1,-1])#conf.get_constellation())
    chansrc = gr.vector_source_c(channel,vlen=len(channel))
    preloadsrc = gr.vector_source_b(preload,vlen=len(preload))
    samplesrc = gr.vector_source_c(samples,vlen=len(samples))
    sink = gr.vector_sink_b(20)
    tb.connect(chansrc, (vit,0))
    tb.connect(samplesrc, (vit,1))
    tb.connect(preloadsrc, (vit,2))
    tb.connect(vit, sink)
    tb.run()
    print_bitvect(preload)
    print_bitvect(rest)
    print_bitvect(sink.data())
Ejemplo n.º 4
0
def test_viterbi():
    tb = gr.top_block()
    channel = [0, 1, 0]
    prellen = len(channel) - 1
    data = [random.randint(0, 1) for i in xrange(20 + prellen)]
    data.extend([0, 0, 0])  # tailbits
    data.extend([0] * 6)  # to flush modulator

    # modulate
    datasrc = gr.vector_source_b(data)
    diffcode = mlse.xor_encode_bb()
    nrz = gr.map_bb([1, -1])
    mod = gr.gmskmod_bc(1, 0.3, 12)
    derot = mlse.derotate_cc()
    modsink = gr.vector_sink_c()
    tb.connect(datasrc, diffcode, nrz, mod, derot, modsink)
    tb.run()

    samples = modsink.data()[6:]
    printvect_c(samples)

    preload = data[:prellen]
    rest = data[prellen:][:20]

    tb = gr.top_block()
    conf = mlse.make_packet_config_gsm()
    vit = mlse.viterbi_vcb(20, len(channel), 3,
                           [1, -1])  #conf.get_constellation())
    chansrc = gr.vector_source_c(channel, vlen=len(channel))
    preloadsrc = gr.vector_source_b(preload, vlen=len(preload))
    samplesrc = gr.vector_source_c(samples, vlen=len(samples))
    sink = gr.vector_sink_b(20)
    tb.connect(chansrc, (vit, 0))
    tb.connect(samplesrc, (vit, 1))
    tb.connect(preloadsrc, (vit, 2))
    tb.connect(vit, sink)
    tb.run()
    print_bitvect(preload)
    print_bitvect(rest)
    print_bitvect(sink.data())