コード例 #1
0
ファイル: schmidl.py プロジェクト: WindyCitySDR/gr-ofdm
 def __init__ ( self, fft_length ):
   gr.hier_block2.__init__(self, "recursive_timing_metric",
       gr.io_signature(1,1,gr.sizeof_gr_complex),
       gr.io_signature(1,1,gr.sizeof_float))
   
   self.input = gr.kludge_copy(gr.sizeof_gr_complex)
   self.connect(self, self.input)
   
   # P(d) = sum(0 to L-1, conj(delayed(r)) * r)
   conj = gr.conjugate_cc()
   mixer = gr.multiply_cc()
   mix_delay = delay(gr.sizeof_gr_complex,fft_length/2+1)
   mix_diff = gr.sub_cc()
   nominator = accumulator_cc()
   inpdelay = delay(gr.sizeof_gr_complex,fft_length/2)
   
   self.connect(self.input, inpdelay, 
                conj, (mixer,0))
   self.connect(self.input, (mixer,1))
   self.connect(mixer,(mix_diff,0))
   self.connect(mixer, mix_delay, (mix_diff,1))
   self.connect(mix_diff,nominator)
   
   rmagsqrd = gr.complex_to_mag_squared()
   rm_delay = delay(gr.sizeof_float,fft_length+1)
   rm_diff = gr.sub_ff()
   denom = accumulator_ff()
   self.connect(self.input,rmagsqrd,rm_diff,gr.multiply_const_ff(0.5),denom)
   self.connect(rmagsqrd,rm_delay,(rm_diff,1))
   
   
   ps = gr.complex_to_mag_squared()
   rs = gr.multiply_ff()
   self.connect(nominator,ps)
   self.connect(denom,rs)
   self.connect(denom,(rs,1))
   
   div = gr.divide_ff()
   self.connect(ps,div)
   self.connect(rs,(div,1))
   
   self.connect(div,self)
コード例 #2
0
    def __init__(self, fft_length):
        gr.hier_block2.__init__(self, "recursive_timing_metric",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(1, 1, gr.sizeof_float))

        self.input = gr.kludge_copy(gr.sizeof_gr_complex)
        self.connect(self, self.input)

        # P(d) = sum(0 to L-1, conj(delayed(r)) * r)
        conj = gr.conjugate_cc()
        mixer = gr.multiply_cc()
        mix_delay = delay(gr.sizeof_gr_complex, fft_length / 2 + 1)
        mix_diff = gr.sub_cc()
        nominator = accumulator_cc()
        inpdelay = delay(gr.sizeof_gr_complex, fft_length / 2)

        self.connect(self.input, inpdelay, conj, (mixer, 0))
        self.connect(self.input, (mixer, 1))
        self.connect(mixer, (mix_diff, 0))
        self.connect(mixer, mix_delay, (mix_diff, 1))
        self.connect(mix_diff, nominator)

        rmagsqrd = gr.complex_to_mag_squared()
        rm_delay = delay(gr.sizeof_float, fft_length + 1)
        rm_diff = gr.sub_ff()
        denom = accumulator_ff()
        self.connect(self.input, rmagsqrd, rm_diff, gr.multiply_const_ff(0.5),
                     denom)
        self.connect(rmagsqrd, rm_delay, (rm_diff, 1))

        ps = gr.complex_to_mag_squared()
        rs = gr.multiply_ff()
        self.connect(nominator, ps)
        self.connect(denom, rs)
        self.connect(denom, (rs, 1))

        div = gr.divide_ff()
        self.connect(ps, div)
        self.connect(rs, (div, 1))

        self.connect(div, self)
コード例 #3
0
ファイル: test_demapper.py プロジェクト: luwangg/gr-ofdm-1
 def test_symbol_src ( self, arity ):
   vlen = 1
   N = int( 1e7 )
   
   demapper = ofdm.generic_demapper_vcb( vlen )
   const = demapper.get_constellation( arity )
   assert( len( const ) == 2**arity )
   
   symsrc = ofdm.symbol_random_src( const, vlen )
   # tx = transmitter_hier_bc(M=M,K=K,qam_size=qam_size,syms_per_frame=syms_per_frame,theta_sel=theta_sel,exclude_preamble=exclude_preamble,sel_preamble=None)
   acc = ofdm.accumulator_cc()
   skiphead = blocks.skiphead( gr.sizeof_gr_complex, N-1 )
   limit = blocks.head( gr.sizeof_gr_complex, 1 )
   dst = blocks.vector_sink_c()
   
   c2mag = blocks.complex_to_mag_squared()
   acc_c2m = ofdm.accumulator_ff()
   skiphead_c2m = blocks.skiphead( gr.sizeof_float, N-1 )
   limit_c2m = blocks.head( gr.sizeof_float, 1 )
   dst_c2m = blocks.vector_sink_f()
   
   tb = gr.top_block ( "test__block" )
   tb.connect( symsrc, acc, skiphead, limit, dst )
   tb.connect( symsrc, c2mag, acc_c2m, skiphead_c2m, limit_c2m, dst_c2m )
   tb.run()
   
   data = numpy.array( dst.data() )
   data_c2m = numpy.array( dst_c2m.data() )
   
   m = data / N
   av_pow = data_c2m / N
   
   assert( abs( m ) < 0.01 )
   assert( abs( 1.0 - av_pow ) < 0.5  )
   
   print "Uniform distributed random symbol source has"
   print "\tno offset for N=%d, relative error: %f" % (arity, abs( m ) )
   print "\tAverage signal power equal 1.0, relative error: %f\t\tOK" \
          % ( abs( 1.0 - av_pow ) )