def __init__(self, N_rb_dl):
        """
        This is the documentation for the LTE OFDM linear Estimator block!
	    """
        gr.hier_block2.__init__(self, "linear_OFDM_estimator_hier_vcvc",
				gr.io_signature(1,1, gr.sizeof_gr_complex*12*N_rb_dl),  # Input signature
				gr.io_signature(3,3, gr.sizeof_gr_complex*12*N_rb_dl))  # Output signature

        print "message define"
        self.message_port_register_hier_out("cell_id")
        
        # Define blocks
        
        self.eq   = lte.linear_OFDM_estimator_vcvc(N_rb_dl)
        self.sh1  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        self.sh2  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        self.sh3  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        
        print "msg connnect!"
        self.msg_connect(self, "cell_id", self.eq, "cell_id")
        
        self.connect(self, self.eq)
        self.connect( (self.eq,0),self.sh1, (self,0) )
        self.connect( (self.eq,1),self.sh2, (self,1) )
        self.connect( (self.eq,2),self.sh3, (self,2) )
Exemplo n.º 2
0
	def setup_flowgraph(self, mode, ber_skipbytes=0):
		# parameters
		self.dp.set_mode(mode)
		self.rp.set_mode(mode)
		self.vlen = self.dp.num_carriers/4
		self.ber_skipbytes = ber_skipbytes

		# trigger signals
		frame_trigger = [1]+[0]*(self.dp.symbols_per_frame-2)
		self.frame_start = frame_trigger*(len(self.random_bytes)/(self.vlen*(self.dp.symbols_per_frame-1)))+frame_trigger[0:(len(self.random_bytes)/self.vlen)%(self.dp.symbols_per_frame-1)]

		# sources/sinks
		self.source    = gr.vector_source_b(self.random_bytes, False)
		self.trig      = gr.vector_source_b(self.frame_start, False)
		if self.ber_sink:
			self.sink = dab.blocks.measure_ber_b()
		else:
			self.sink = gr.vector_sink_b()
		self.trig_sink = gr.null_sink(gr.sizeof_char)

		# self.noise_start      = gr.noise_source_c(gr.GR_GAUSSIAN, math.sqrt(2), random.randint(0,10000))
		# self.noise_start_head = gr.head(gr.sizeof_gr_complex, NOISE_SAMPLES_AT_START)
		# self.noise_end        = gr.noise_source_c(gr.GR_GAUSSIAN, math.sqrt(2), random.randint(0,10000))
		# self.noise_end_head   = gr.head(gr.sizeof_gr_complex, NOISE_SAMPLES_AT_END)
		
		# blocks
		self.s2v       = gr.stream_to_vector(gr.sizeof_char, self.vlen)
		self.v2s       = gr.vector_to_stream(gr.sizeof_char, self.vlen)
		if self.ber_sink:
			self.ber_skipbytes0 = gr.skiphead(gr.sizeof_char, self.ber_skipbytes)
			self.ber_skipbytes1 = gr.skiphead(gr.sizeof_char, self.ber_skipbytes+self.dp.bytes_per_frame)
		
		# more blocks (they have state, so better reinitialise them)
		self.mod       = dab.ofdm_mod(self.dp, debug = False)
		self.rescale   = gr.multiply_const_cc(1)
		self.amp       = gr.multiply_const_cc(1)
		self.channel   = blks2.channel_model(noise_voltage=0, noise_seed=random.randint(0,10000))
		# self.cat       = dab.concatenate_signals(gr.sizeof_gr_complex)
		self.demod     = dab.ofdm_demod(self.dp, self.rp, debug = False, verbose = True)

		# connect it all
		if self.ber_sink:
			self.connect(self.source, self.s2v, (self.mod,0), self.rescale, self.amp, self.channel, (self.demod,0), self.v2s, self.ber_skipbytes0, self.sink)
			self.connect(self.source, self.ber_skipbytes1, (self.sink,1))
		else:
			self.connect(self.source, self.s2v, (self.mod,0), self.rescale, self.amp, self.channel, (self.demod,0), self.v2s, self.sink)
		self.connect(self.trig, (self.mod,1))
		self.connect((self.demod, 1), self.trig_sink)

		# SNR calculation and prober
		self.probe_signal = gr.probe_avg_mag_sqrd_c(0,0.00001)
		self.probe_total  = gr.probe_avg_mag_sqrd_c(0,0.00001)
		self.connect(self.amp, self.probe_signal)
		self.connect(self.channel, self.probe_total)
Exemplo n.º 3
0
 def _get_gauss_rand_proc_c(self):
     """ Returns the Gaussian random process.
     """
     spec_getter = getattr(self.model, 'get_' + self.spec_type)
     if self.spec_type in self.model.specs_odd:
         from winelo.channel import spec2soc
         soc = spec2soc(spec_getter(), method=self.method, N=self.N)
         sources = []
         adder = gr.add_cc()
         for idx, (freq, ampl) in enumerate(soc.get_soc()):
             sources.append(gr.sig_source_c(self.sample_rate,
                                            gr.GR_COS_WAVE, freq, ampl))
             self.connect(sources[idx],
                          gr.skiphead(gr.sizeof_gr_complex,
                                      randint(low=0, high=self.sample_rate)),
                          (adder, idx))
         return adder
     elif self.spec_type in self.model.specs_even:
         from winelo.channel import spec2sos
         # real part of the gaussian random process
         sos_real = spec2sos(spec_getter(), method=self.method, N=self.N)
         sources_real = []
         adder_real = gr.add_ff()
         for idx, (freq, ampl) in enumerate(sos_real.get_sos()):
             sources_real.append(gr.sig_source_f(self.sample_rate,
                                                 gr.GR_COS_WAVE, freq,
                                                 ampl))
             self.connect(sources_real[idx],
                          gr.skiphead(gr.sizeof_float,
                                      randint(low=0, high=self.sample_rate)),
                          (adder_real, idx))
         # imaginary part of the gaussian random process
         sos_imaginary = spec2sos(spec_getter(), method=self.method,
                                  N=self.N + 1)
         sources_imag = []
         adder_imag = gr.add_ff()
         for idx, (freq, ampl) in enumerate(sos_imaginary.get_sos()):
             sources_imag.append(gr.sig_source_f(self.sample_rate,
                                                 gr.GR_COS_WAVE, freq,
                                                 ampl))
             self.connect(sources_imag[idx],
                          gr.skiphead(gr.sizeof_float,
                                      randint(low=0, high=self.sample_rate)),
                          (adder_imag, idx))
         float2complex = gr.float_to_complex()
         self.connect(adder_real, (float2complex, 0))
         self.connect(adder_imag, (float2complex, 1))
         return float2complex
     else:
         print 'You picked a non-existant Doppler spectrum'
         print 'Pick one of the following: ', \
               self.model.specs_even + self.model.specs_odd
         return None
Exemplo n.º 4
0
	def __init__(self, decim=16, N_id_1=134, N_id_2=0):
		grc_wxgui.top_block_gui.__init__(self, title="Sss Corr Gui")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Parameters
		##################################################
		self.decim = decim
		self.N_id_1 = N_id_1
		self.N_id_2 = N_id_2

		##################################################
		# Variables
		##################################################
		self.sss_start_ts = sss_start_ts = 10608 - 2048 - 144
		self.samp_rate = samp_rate = 30720e3/decim

		##################################################
		# Blocks
		##################################################
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=200,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.gr_vector_to_stream_0 = gr.vector_to_stream(gr.sizeof_gr_complex*1, 2048/decim)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate*decim)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 2048/decim)
		self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, sss_start_ts)
		self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((gen_sss_fd(N_id_1, N_id_2, 2048/decim).get_sss_conj_rev()))
		self.gr_integrate_xx_0 = gr.integrate_cc(2048/decim)
		self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/home/user/git/gr-lte/gr-lte/test/traces/lte_02_796m_30720k_frame.cfile", True)
		self.gr_fft_vxx_0 = gr.fft_vcc(2048/decim, True, (window.blackmanharris(1024)), True, 1)
		self.gr_complex_to_mag_0 = gr.complex_to_mag(1)
		self.fir_filter_xxx_0 = filter.fir_filter_ccc(decim, (firdes.low_pass(1, decim*samp_rate, 550e3, 100e3)))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_file_source_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_stream_to_vector_0, 0), (self.gr_fft_vxx_0, 0))
		self.connect((self.gr_fft_vxx_0, 0), (self.gr_multiply_const_vxx_0, 0))
		self.connect((self.gr_multiply_const_vxx_0, 0), (self.gr_vector_to_stream_0, 0))
		self.connect((self.gr_vector_to_stream_0, 0), (self.gr_integrate_xx_0, 0))
		self.connect((self.gr_integrate_xx_0, 0), (self.gr_complex_to_mag_0, 0))
		self.connect((self.gr_complex_to_mag_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_skiphead_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.fir_filter_xxx_0, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.gr_stream_to_vector_0, 0))
Exemplo n.º 5
0
 def test_skip_all(self):
     skip_cnt = len(self.src_data)
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = gr.vector_source_i (self.src_data)
     op = gr.skiphead (gr.sizeof_int, skip_cnt)
     dst1 = gr.vector_sink_i ()
     self.tb.connect (src1, op, dst1)
     self.tb.run ()
     dst_data = dst1.data ()
     self.assertEqual (expected_result, dst_data)
Exemplo n.º 6
0
 def test_skip_6339(self):
     skip_cnt = 6339
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = gr.vector_source_c (self.src_data)
     op = gr.skiphead (gr.sizeof_gr_complex, skip_cnt)
     dst1 = gr.vector_sink_c ()
     self.tb.connect (src1, op, dst1)
     self.tb.run ()
     dst_data = dst1.data ()
     self.assertEqual (expected_result, dst_data)
Exemplo n.º 7
0
 def test_skip_12678(self):
     skip_cnt = 12678
     expected_result = tuple(self.src_data[skip_cnt:])
     src1 = gr.vector_source_b (self.src_data)
     op = gr.skiphead (gr.sizeof_char, skip_cnt)
     dst1 = gr.vector_sink_b ()
     self.tb.connect (src1, op, dst1)
     self.tb.run ()
     dst_data = dst1.data ()
     self.assertEqual (expected_result, dst_data)
 def setUp (self):
     print os.getpid()
     raw_input("Press the ANY key to continue")
 
     self.tb = gr.top_block ()
     
     print "\nqa_lte_linear_OFDM_estimator_vcvc START"
     
     
     # Input 1, PBCH frame
     mod=scipy.io.loadmat('/home/demel/exchange/matlab_frame.mat') 
     mat_u1=tuple(mod['frame_mat'].flatten())
     mat_d=range(len(mat_u1))
     for idx, val in enumerate(mat_u1):
         mat_d[idx]=val
     intu1o=tuple(mat_d)
     intu1=intu1o[0:140*72]
     #intu1=intu1[72*126:140*72]
     self.intu1=intu1
     print "len(intu1) = " + str(len(intu1))
     
     self.src = gr.vector_source_c( intu1, True, 72)
     
     cell_id = 124
     N_rb_dl = 6
     self.eq = lte_swig.linear_OFDM_estimator_vcvc(N_rb_dl) #cell_id,
     self.eq.set_cell_id(cell_id)
     
     self.sh1 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
     self.sh2 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
     self.sh3 = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
     self.hd1 = gr.head(gr.sizeof_gr_complex*12*N_rb_dl,280)
     self.hd2 = gr.head(gr.sizeof_gr_complex*12*N_rb_dl,280)
     self.hd3 = gr.head(gr.sizeof_gr_complex*12*N_rb_dl,280)
     
     self.snk1 = gr.vector_sink_c(72)
     self.snk2 = gr.vector_sink_c(72)
     self.snk3 = gr.vector_sink_c(72)
     
     self.tb.connect(self.src,self.eq)
     self.tb.connect( (self.eq,0) ,self.sh1,self.hd1,self.snk1)
     self.tb.connect( (self.eq,1) ,self.sh2,self.hd2,self.snk2)
     self.tb.connect( (self.eq,2) ,self.sh3,self.hd3,self.snk3)
    def __init__(self, N_rb_dl):
        """
        docstring
	    """
        gr.hier_block2.__init__(self, "linear_OFDM_equalizer_hier_vcvc",
				gr.io_signature(1,1, gr.sizeof_gr_complex*12*N_rb_dl),  # Input signature
				gr.io_signature(3,3, gr.sizeof_gr_complex*12*N_rb_dl)) # Output signature

        # Define blocks
        
        self.eq   = lte.linear_OFDM_equalizer_vcvc(N_rb_dl)
        #self.eq.set_cell_id(cell_id)
        self.sh1  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        self.sh2  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        self.sh3  = gr.skiphead(gr.sizeof_gr_complex*12*N_rb_dl,7)
        
        self.connect(self, self.eq)
        self.connect( (self.eq,0),self.sh1, (self,0) )
        self.connect( (self.eq,1),self.sh2, (self,1) )
        self.connect( (self.eq,2),self.sh3, (self,2) )
    def __init__( self, filename, skip=0 ):
        gr.hier_block2.__init__( self,
                "file_source",
                gr.io_signature(0,0,0),
                gr.io_signature( 1,1,gr.sizeof_gr_complex ))

        src =  gr.file_source( gr.sizeof_gr_complex, filename )

        if skip>0:
            skip_head =  gr.skiphead( gr.sizeof_gr_complex, skip )
            self.connect( src, skip_head, self )
        else:
            self.connect(src, self)
Exemplo n.º 11
0
  def build_blocks(self, streamsize, N ):
    self.skip = gr.skiphead( streamsize, N-1 )
    self.limit = gr.head( streamsize, 1 )

    if self.sink is None:
      if streamsize == gr.sizeof_char:
        self.dst = gr.vector_sink_b()
      if streamsize == gr.sizeof_float:
        self.dst = gr.vector_sink_f()
      if streamsize == gr.sizeof_short:
        self.dst = gr.vector_sink_s()
      if streamsize == gr.sizeof_gr_complex:
        self.dst = gr.vector_sink_c()
    else:
      self.dst = self.sink
Exemplo n.º 12
0
  def __init__( self, vlen, startup, window ):
    gr.hier_block2.__init__( self,
          "vector_acc_se2",
          gr.io_signature( 1, 1, gr.sizeof_gr_complex * vlen ),
          gr.io_signature( 1, 1, gr.sizeof_float ) )

    mse = ofdm.mean_squared_error( vlen, window, False, float(window) )

    if startup > 0:
      startup_skip = gr.skiphead( gr.sizeof_gr_complex * vlen, startup )
      self.connect( self, startup_skip, mse, self )
    else:
      self.connect( self, mse, self )

    self.mse = mse
    self.startup = startup
def run_test (f,Kb,bitspersymbol,K,channel,modulation,dimensionality,tot_constellation,N0,seed):
    fg = gr.flow_graph ()
    L = len(channel)

    # TX
    # this for loop is TOO slow in python!!!
    packet = [0]*(K+2*L)
    random.seed(seed)
    for i in range(len(packet)):
        packet[i] = random.randint(0, 2**bitspersymbol - 1) # random symbols
    for i in range(L): # first/last L symbols set to 0
        packet[i] = 0
        packet[len(packet)-i-1] = 0
    src = gr.vector_source_s(packet,False)
    mod = gr.chunks_to_symbols_sf(modulation[1],modulation[0])

    # CHANNEL
    isi = gr.fir_filter_fff(1,channel)
    add = gr.add_ff()
    noise = gr.noise_source_f(gr.GR_GAUSSIAN,math.sqrt(N0/2),seed)
    
    # RX
    skip = gr.skiphead(gr.sizeof_float, L) # skip the first L samples since you know they are coming from the L zero symbols
    #metrics = trellis.metrics_f(f.O(),dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # data preprocessing to generate metrics for Viterbi
    #va = trellis.viterbi_s(f,K+L,-1,0) # Put -1 if the Initial/Final states are not set.
    va = trellis.viterbi_combined_fs(f,K+L,0,0,dimensionality,tot_constellation,trellis.TRELLIS_EUCLIDEAN) # using viterbi_combined_fs instead of metrics_f/viterbi_s allows larger packet lengths because metrics_f is complaining for not being able to allocate large buffers. This is due to the large f.O() in this application...
    dst = gr.vector_sink_s()

    fg.connect (src,mod)
    fg.connect (mod,isi,(add,0))
    fg.connect (noise,(add,1))
    #fg.connect (add,metrics)
    #fg.connect (metrics,va,dst)
    fg.connect (add,skip,va,dst)

    fg.run()

    data = dst.data() 
    ntotal = len(data) - L
    nright=0
    for i in range(ntotal):
        if packet[i+L]==data[i]:
            nright=nright+1
        #else:
            #print "Error in ", i
    
    return (ntotal,ntotal-nright)
Exemplo n.º 14
0
  def __init__( self, vlen, startup ):
    gr.hier_block2.__init__( self,
          "vector_acc_se",
          gr.io_signature( 1, 1, gr.sizeof_gr_complex * vlen ),
          gr.io_signature( 1, 1, gr.sizeof_float ) )

    squared_error_subc = gr.complex_to_mag_squared( vlen )
    squared_error_block = ofdm.vector_sum_vff( vlen )
    accumulated_squared_error = ofdm.accumulator_ff()

    if startup > 0:
      startup_skip = gr.skiphead( gr.sizeof_gr_complex * vlen, startup )
      self.connect( self, startup_skip, squared_error_subc, squared_error_block,
                    accumulated_squared_error, self )
    else:
      self.connect( self, squared_error_subc, squared_error_block,
                    accumulated_squared_error, self )
Exemplo n.º 15
0
  def __init__( self, startup, window ):
    gr.hier_block2.__init__( self,
          "vector_acc_se2",
          gr.io_signature( 1, 1, gr.sizeof_float),
          gr.io_signature( 1, 1, gr.sizeof_float ) )

    #mse = ofdm.mean_squared_error( vlen, window, False, float(window) )

    if startup > 0:
      startup_skip = gr.skiphead( gr.sizeof_float, startup )
      self.connect( self, startup_skip,self )
    else:
      self.odd= gr.add_const_ff(0.0)
      self.connect( self, self.odd,self )

    #self.mse = mse
    self.startup = startup
Exemplo n.º 16
0
    def __init__(self, samples_per_symbol = 1):
        gr.hier_block2.__init__(self, 'gsm_modulate_burst',
                gr.io_signature2(2,2,58*2,1),
                gr.io_signature(1, 1, gr.sizeof_gr_complex))
        
        # take care of the packetizer
        conf = mlse.make_packet_config_gsm()
        self.packetbuilder = mlse.packetbuilder_midamble_vbb(conf)
        self.connect(self, self.packetbuilder)
        self.connect((self,1), (self.packetbuilder,1)) # tsc_index

        # append 8 1-bits to the packet for the idle-time between bursts.
        # This is necessary among others to flush the gmsk-modulator which is causal.
        # (We use 1-bits because that's what the gsm-standard says)
        # (we also only use 8 bits, because the specified value of 8.25 only works 
        # properly with samplerates that are a multiple of 4.)
        self.guardbits = gr.vector_source_b((1,)*8,True,8)
        self.guard_cat = mlse.vector_concat_vv(148,8)
        self.connect(self.packetbuilder, self.guard_cat)
        self.connect(self.guardbits, (self.guard_cat,1))

        # we now have a vector of bits, transform that into a stream
        self.tostream = gr.vector_to_stream(1, 148+8)
        # do the precoding:
        self.diffcode = gr.diff_decoder_bb(2);
        self.nrz = gr.map_bb([1,-1])
        self.connect(self.guard_cat, self.tostream, self.diffcode, self.nrz)

        # modulate
        #self.mod = gr.gmskmod_bc(samples_per_symbol, 0.3, 8)
        self.mod = digital.gmskmod_bc(samples_per_symbol, 0.3, 8)

        # skip the first gmsk_length*samplerate/2 samples to make this block
        # acausal.
        self.skiphead = gr.skiphead(gr.sizeof_gr_complex, samples_per_symbol*8/2);
        self.connect(self.nrz, self.mod, self.skiphead, self)
    def __init__(self, options, hostname):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        window_size = options.window_size
        sync_length = options.sync_length
        gain = options.gain
        freq = options.freq
        samp_rate = options.bandwidth
        self.uhd_usrp_source_0 = uhd.usrp_source(device_addr="", stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1)))

        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.ieee802_1_ofdm_sync_short_0 = gr_ieee802_11.ofdm_sync_short(0.8, 80 * 80, 2, False)
        self.ieee802_1_ofdm_sync_long_0 = gr_ieee802_11.ofdm_sync_long(sync_length, 100, False)
        self.ieee802_1_ofdm_equalize_symbols_0 = gr_ieee802_11.ofdm_equalize_symbols(False)
        self.ieee802_1_ofdm_decode_signal_0 = gr_ieee802_11.ofdm_decode_signal(False)
        self.ieee802_1_ofdm_decode_mac_0 = gr_ieee802_11.ofdm_decode_mac(False)
        self.ieee802_11_ofdm_parse_mac_0 = gr_ieee802_11.ofdm_parse_mac(True)
        self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 64)
        self.gr_socket_pdu_0 = gr.socket_pdu("TCP_SERVER", hostname, str(options.PHYRXport), 10000)
        self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, 20000000)
        self.gr_multiply_xx_0 = gr.multiply_vcc(1)
        self.gr_divide_xx_0 = gr.divide_ff(1)
        self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, sync_length)
        self.gr_delay_0 = gr.delay(gr.sizeof_gr_complex*1, 16)
        self.gr_conjugate_cc_0 = gr.conjugate_cc()
        self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1)
        self.gr_complex_to_mag_0 = gr.complex_to_mag(1)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(1, ([1]*window_size))
        self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1]*window_size))
        self.fft_vxx_0 = fft.fft_vcc(64, True, (), True, 1)
        self.message_debug = gr.message_debug()
        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.gr_skiphead_0, 0))
        self.connect((self.gr_skiphead_0, 0), (self.gr_complex_to_mag_squared_0, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.gr_divide_xx_0, 1))
        self.connect((self.gr_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.gr_skiphead_0, 0), (self.gr_multiply_xx_0, 0))
        self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_xx_0, 1))
        self.connect((self.gr_complex_to_mag_0, 0), (self.gr_divide_xx_0, 0))
        self.connect((self.gr_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0), (self.gr_complex_to_mag_0, 0))
        self.connect((self.gr_skiphead_0, 0), (self.gr_delay_0, 0))
        self.connect((self.gr_delay_0, 0), (self.gr_conjugate_cc_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.ieee802_1_ofdm_equalize_symbols_0, 0))
        self.connect((self.ieee802_1_ofdm_equalize_symbols_0, 0), (self.ieee802_1_ofdm_decode_signal_0, 0))
        self.connect((self.ieee802_1_ofdm_decode_signal_0, 0), (self.ieee802_1_ofdm_decode_mac_0, 0))
        self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.gr_delay_0_0, 0))
        self.connect((self.gr_delay_0, 0), (self.ieee802_1_ofdm_sync_short_0, 0))
        self.connect((self.gr_divide_xx_0, 0), (self.ieee802_1_ofdm_sync_short_0, 1))
        self.connect((self.gr_delay_0_0, 0), (self.ieee802_1_ofdm_sync_long_0, 1))
        self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.ieee802_1_ofdm_sync_long_0, 0))
        self.connect((self.ieee802_1_ofdm_sync_long_0, 0), (self.gr_stream_to_vector_0, 0))
        self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.ieee802_1_ofdm_decode_mac_0, "out", self.ieee802_11_ofdm_parse_mac_0, "in")
        self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "out", self.gr_socket_pdu_0, "pdus")
Exemplo n.º 18
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Ofdm Rx")

		##################################################
		# Variables
		##################################################
		self.window_size = window_size = 48
		self.sync_length = sync_length = 320 - 64
		self.samp_rate = samp_rate = 10e6
		self.gain = gain = 0
		self.freq = freq = 5.825e9

		##################################################
		# Blocks
		##################################################
		self._samp_rate_chooser = forms.radio_buttons(
			parent=self.GetWin(),
			value=self.samp_rate,
			callback=self.set_samp_rate,
			label="Sample Rate",
			choices=[10e6, 20e6],
			labels=["10 Mhz", "20 Mhz"],
			style=wx.RA_HORIZONTAL,
		)
		self.Add(self._samp_rate_chooser)
		_gain_sizer = wx.BoxSizer(wx.VERTICAL)
		self._gain_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			label='gain',
			converter=forms.float_converter(),
			proportion=0,
		)
		self._gain_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_gain_sizer,
			value=self.gain,
			callback=self.set_gain,
			minimum=0,
			maximum=100,
			num_steps=100,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_gain_sizer)
		self._freq_chooser = forms.drop_down(
			parent=self.GetWin(),
			value=self.freq,
			callback=self.set_freq,
			label="Channel",
			choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
			labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
		)
		self.Add(self._freq_chooser)
		self.uhd_usrp_source_0 = uhd.usrp_source(
			device_addr="",
			stream_args=uhd.stream_args(
				cpu_format="fc32",
				channels=range(1),
			),
		)
		self.uhd_usrp_source_0.set_samp_rate(samp_rate)
		self.uhd_usrp_source_0.set_center_freq(freq, 0)
		self.uhd_usrp_source_0.set_gain(gain, 0)
		self.ieee802_1_ofdm_sync_short_0 = gr_ieee802_11.ofdm_sync_short(0.8, 80 * 80, 2, False)
		self.ieee802_1_ofdm_sync_long_0 = gr_ieee802_11.ofdm_sync_long(sync_length, 100, False)
		self.ieee802_1_ofdm_equalize_symbols_0 = gr_ieee802_11.ofdm_equalize_symbols(False)
		self.ieee802_1_ofdm_decode_signal_0 = gr_ieee802_11.ofdm_decode_signal(False)
		self.ieee802_1_ofdm_decode_mac_0 = gr_ieee802_11.ofdm_decode_mac(False)
		self.ieee802_11_ofdm_parse_mac_0 = gr_ieee802_11.ofdm_parse_mac(True)
		self.gr_stream_to_vector_0 = gr.stream_to_vector(gr.sizeof_gr_complex*1, 64)
		self.gr_socket_pdu_0 = gr.socket_pdu("UDP_SERVER", "", "12345", 10000)
		self.gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, 20000000)
		self.gr_multiply_xx_0 = gr.multiply_vcc(1)
		self.gr_divide_xx_0 = gr.divide_ff(1)
		self.gr_delay_0_0 = gr.delay(gr.sizeof_gr_complex*1, sync_length)
		self.gr_delay_0 = gr.delay(gr.sizeof_gr_complex*1, 16)
		self.gr_conjugate_cc_0 = gr.conjugate_cc()
		self.gr_complex_to_mag_squared_0 = gr.complex_to_mag_squared(1)
		self.gr_complex_to_mag_0 = gr.complex_to_mag(1)
		self.fir_filter_xxx_0_0 = filter.fir_filter_ccf(1, ([1]*window_size))
		self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1]*window_size))
		self.fft_vxx_0 = fft.fft_vcc(64, True, (), True, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.uhd_usrp_source_0, 0), (self.gr_skiphead_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_complex_to_mag_squared_0, 0))
		self.connect((self.fir_filter_xxx_0, 0), (self.gr_divide_xx_0, 1))
		self.connect((self.gr_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_multiply_xx_0, 0))
		self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_xx_0, 1))
		self.connect((self.gr_complex_to_mag_0, 0), (self.gr_divide_xx_0, 0))
		self.connect((self.gr_multiply_xx_0, 0), (self.fir_filter_xxx_0_0, 0))
		self.connect((self.fir_filter_xxx_0_0, 0), (self.gr_complex_to_mag_0, 0))
		self.connect((self.gr_skiphead_0, 0), (self.gr_delay_0, 0))
		self.connect((self.gr_delay_0, 0), (self.gr_conjugate_cc_0, 0))
		self.connect((self.fft_vxx_0, 0), (self.ieee802_1_ofdm_equalize_symbols_0, 0))
		self.connect((self.ieee802_1_ofdm_equalize_symbols_0, 0), (self.ieee802_1_ofdm_decode_signal_0, 0))
		self.connect((self.ieee802_1_ofdm_decode_signal_0, 0), (self.ieee802_1_ofdm_decode_mac_0, 0))
		self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.gr_delay_0_0, 0))
		self.connect((self.gr_delay_0, 0), (self.ieee802_1_ofdm_sync_short_0, 0))
		self.connect((self.gr_divide_xx_0, 0), (self.ieee802_1_ofdm_sync_short_0, 1))
		self.connect((self.gr_delay_0_0, 0), (self.ieee802_1_ofdm_sync_long_0, 1))
		self.connect((self.ieee802_1_ofdm_sync_short_0, 0), (self.ieee802_1_ofdm_sync_long_0, 0))
		self.connect((self.ieee802_1_ofdm_sync_long_0, 0), (self.gr_stream_to_vector_0, 0))
		self.connect((self.gr_stream_to_vector_0, 0), (self.fft_vxx_0, 0))

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.ieee802_1_ofdm_decode_mac_0, "out", self.ieee802_11_ofdm_parse_mac_0, "in")
		self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "out", self.gr_socket_pdu_0, "pdus")
Exemplo n.º 19
0
	def __init__(self, file_name, decim=16, avg_frames=1, file_decim=1, freq_corr=0, sstart=0, dump=None):
		##################################################
		# Parameters
		##################################################
		self.decim = decim
		self.avg_frames = avg_frames
		self.freq_corr = freq_corr
		self.file_name = file_name
		self.dump = dump
		self.sstart = sstart

		##################################################
		# Variables
		##################################################
		self.N_id_2s = range(0,3)
		self.N_id_1s = range(0,168)
		self.slot_0_10s = range(0,2)
		#self.N_id_2s = [0] #range(0,3)
		#self.N_id_1s = [134] #range(0,168)
		#self.slot_0_10s = [0] #range(0,2)
		self.vec_half_frame = vec_half_frame = 30720*5/decim
		self.samp_rate = samp_rate = 30720e3/decim
		self.cutoff_freq = cutoff_freq = 550e3
		self.transition_width = transition_width = 100e3
		self.fft_size = 2048/self.decim
		self.N_re = 62
		self.snum = (self.avg_frames+1)*307200/file_decim

		##################################################
		# Generate input vector source
		##################################################
		if None != file_name:
			logging.debug("Reading from file: " + file_name)
			file_source = gr.file_source(gr.sizeof_gr_complex*1, file_name, False)
		else:
			N_id_1=134
			N_id_2=0
			logging.debug("Generating DL sync signals for cell ID {}".format(3*N_id_1+N_id_2))
			file_source = lte_dl_ss_source(decim=file_decim,N_id_1=N_id_1,N_id_2=N_id_2,frames=self.avg_frames)
		skiphead_0 = gr.skiphead(gr.sizeof_gr_complex, self.sstart)
		head_0 = gr.head(gr.sizeof_gr_complex, self.snum)
		decim_lowpass = filter.fir_filter_ccc(decim/file_decim, (firdes.low_pass(1, decim/file_decim*samp_rate, cutoff_freq, transition_width)))
		sink = gr.vector_sink_c();
		top = gr.top_block("input reader graph")
		top.connect(file_source, skiphead_0, head_0, decim_lowpass, sink)
		if dump != None:
			top.connect(decim_lowpass, gr.file_sink(gr.sizeof_gr_complex, self.dump + "_input.cfile"))
		top.run()
		self.buffer = sink.data()
		
		logging.debug("No. samples to process: {}".format(len(self.buffer))) 
		if -1 == self.avg_frames:
			self.avg_frames = int(floor(len(self.buffer) / vec_half_frame / 2))
		logging.debug("Config: decim {}, avg_frames {}, freq_corr {}".format(self.decim, self.avg_frames, self.freq_corr)) 
		self.source = gr.vector_source_c(self.buffer)

		# create pss flow graph		
		self.pss_top = gr.top_block("pss corr graph")
		self.pss_corr = pss_corr(0, self.decim, self.avg_frames*2, self.freq_corr, self.dump)
		self.pss_sink = gr.vector_sink_f()
		self.pss_top.connect(self.source, self.pss_corr, self.pss_sink)
		
		# create sss flow graphs
		self.sss_corr = sss_corr2(self.decim, self.fft_size, self.N_re, self.avg_frames, self.dump, self.N_id_1s, self.slot_0_10s)
Exemplo n.º 20
0
def run_test(seed,blocksize):
        tb = gr.top_block()

	##################################################
	# Variables
	##################################################
	M = 2
	K = 1
	P = 2
	h = (1.0*K)/P
	L = 3
	Q = 4
        frac = 0.99
        f = trellis.fsm(P,M,L)

        # CPFSK signals
        #p = numpy.ones(Q)/(2.0)
        #q = numpy.cumsum(p)/(1.0*Q)

        # GMSK signals
        BT=0.3;
        tt=numpy.arange(0,L*Q)/(1.0*Q)-L/2.0;
        #print tt
        p=(0.5*scipy.stats.erfc(2*math.pi*BT*(tt-0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0))-0.5*scipy.stats.erfc(2*math.pi*BT*(tt+0.5)/math.sqrt(math.log(2.0))/math.sqrt(2.0)))/2.0;
        p=p/sum(p)*Q/2.0;
        #print p
        q=numpy.cumsum(p)/Q;
        q=q/q[-1]/2.0;
        #print q

        (f0T,SS,S,F,Sf,Ff,N) = fsm_utils.make_cpm_signals(K,P,M,L,q,frac)
        #print N
        #print Ff
        Ffa = numpy.insert(Ff,Q,numpy.zeros(N),axis=0)
        #print Ffa
        MF = numpy.fliplr(numpy.transpose(Ffa))
        #print MF
        E = numpy.sum(numpy.abs(Sf)**2,axis=0)
        Es = numpy.sum(E)/f.O()
        #print Es

        constellation = numpy.reshape(numpy.transpose(Sf),N*f.O())
        #print Ff
        #print Sf
        #print constellation
        #print numpy.max(numpy.abs(SS - numpy.dot(Ff , Sf)))

	EsN0_db = 10.0
        N0 =  Es * 10.0**(-(1.0*EsN0_db)/10.0)
        #N0 = 0.0
        #print N0
        head = 4
        tail = 4
        numpy.random.seed(seed*666)
        data = numpy.random.randint(0, M, head+blocksize+tail+1)
        #data = numpy.zeros(blocksize+1+head+tail,'int')
        for i in range(head):
            data[i]=0
        for i in range(tail+1):
            data[-i]=0
      


	##################################################
	# Blocks
	##################################################
	random_source_x_0 = gr.vector_source_b(data, False)
	gr_chunks_to_symbols_xx_0 = gr.chunks_to_symbols_bf((-1, 1), 1)
	gr_interp_fir_filter_xxx_0 = gr.interp_fir_filter_fff(Q, p)
	gr_frequency_modulator_fc_0 = gr.frequency_modulator_fc(2*math.pi*h*(1.0/Q))

	gr_add_vxx_0 = gr.add_vcc(1)
	gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, (N0/2.0)**0.5, -long(seed))

	gr_multiply_vxx_0 = gr.multiply_vcc(1)
	gr_sig_source_x_0 = gr.sig_source_c(Q, gr.GR_COS_WAVE, -f0T, 1, 0)
        # only works for N=2, do it manually for N>2...
	gr_fir_filter_xxx_0_0 = gr.fir_filter_ccc(Q, MF[0].conjugate())
	gr_fir_filter_xxx_0_0_0 = gr.fir_filter_ccc(Q, MF[1].conjugate())
	gr_streams_to_stream_0 = gr.streams_to_stream(gr.sizeof_gr_complex*1, N)
	gr_skiphead_0 = gr.skiphead(gr.sizeof_gr_complex*1, N*(1+0))
	viterbi = trellis.viterbi_combined_cb(f, head+blocksize+tail, 0, -1, N, constellation, trellis.TRELLIS_EUCLIDEAN)

        gr_vector_sink_x_0 = gr.vector_sink_b()

	##################################################
	# Connections
	##################################################
	tb.connect((random_source_x_0, 0), (gr_chunks_to_symbols_xx_0, 0))
	tb.connect((gr_chunks_to_symbols_xx_0, 0), (gr_interp_fir_filter_xxx_0, 0))
	tb.connect((gr_interp_fir_filter_xxx_0, 0), (gr_frequency_modulator_fc_0, 0))
	tb.connect((gr_frequency_modulator_fc_0, 0), (gr_add_vxx_0, 0))
	tb.connect((gr_noise_source_x_0, 0), (gr_add_vxx_0, 1))
	tb.connect((gr_add_vxx_0, 0), (gr_multiply_vxx_0, 0))
	tb.connect((gr_sig_source_x_0, 0), (gr_multiply_vxx_0, 1))
	tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0, 0))
	tb.connect((gr_multiply_vxx_0, 0), (gr_fir_filter_xxx_0_0_0, 0))
	tb.connect((gr_fir_filter_xxx_0_0, 0), (gr_streams_to_stream_0, 0))
	tb.connect((gr_fir_filter_xxx_0_0_0, 0), (gr_streams_to_stream_0, 1))
	tb.connect((gr_streams_to_stream_0, 0), (gr_skiphead_0, 0))
	tb.connect((gr_skiphead_0, 0), (viterbi, 0))
	tb.connect((viterbi, 0), (gr_vector_sink_x_0, 0))
        

        tb.run()
        dataest = gr_vector_sink_x_0.data()
        #print data
        #print numpy.array(dataest)
        perr = 0
        err = 0
        for i in range(blocksize):
          if data[head+i] != dataest[head+i]:
            #print i
            err += 1
        if err != 0 :
          perr = 1
        return (err,perr)
Exemplo n.º 21
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel
        
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-w", "--which", type="int", default=0,
                          help="select which USRP (0, 1, ...) default is %default",
			  metavar="NUM")
        parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select USRP Rx side A or B (default=first one with a daughterboard)")
        parser.add_option("-A", "--antenna", default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-d", "--decim", type="int", default=16,
                          help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=None,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB [default is midpoint]")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option( "--no-hb", action="store_true", default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
	parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
			  help="Set fftsink averaging factor, [default=%default]")
	parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
			  help="Set dBFS=0dB input value, [default=%default]")
        parser.add_option("", "--fft-size", type="int", default=512,
                          help="Set FFT frame size, [default=%default]");
	parser.add_option("-e", "--order", type="int", default=4,
                	  help="order of the AR filter for burg estimator")
	parser.add_option("", "--shift-fft", action="store_true", default=True,
                	  help="shift the DC carrier to the middle.")
        parser.add_option("-W", "--waterfall", action="store_true", default=False,
                          help="Enable waterfall display")

        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
	self.options = options
        self.show_debug_info = True
        
        # build the graph
        if options.no_hb or (options.decim<8):
          #Min decimation of this firmware is 4. 
          #contains 4 Rx paths without halfbands and 0 tx paths.
          self.fpga_filename="std_4rx_0tx.rbf"
          self.u = usrp.source_c(which=options.which, decim_rate=options.decim, fpga_filename=self.fpga_filename)
        else:
          #Min decimation of standard firmware is 8. 
          #standard fpga firmware "std_2rxhb_2tx.rbf" 
          #contains 2 Rx paths with halfband filters and 2 tx paths (the default)
          self.u = usrp.source_c(which=options.which, decim_rate=options.decim)

        if options.rx_subdev_spec is None:
            options.rx_subdev_spec = pick_subdevice(self.u)
        self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        if options.width_8:
            width = 8
            shift = 8
            format = self.u.make_format(width, shift)
            print "format =", hex(format)
            r = self.u.set_format(format)
            print "set_format =", r
            
        # determine the daughterboard subdevice we're using
        self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)

        input_rate = self.u.adc_freq() / self.u.decim_rate()

        self.scope = fftsink2.fft_sink_c (panel, fft_size=options.fft_size, sample_rate=input_rate, 
					      ref_scale=options.ref_scale, ref_level=80, y_divs = 20,
					      avg_alpha=options.avg_alpha)


	toskip = 1

	self.head = gr.head(gr.sizeof_gr_complex, (toskip+1)*options.fft_size)
	self.skip = gr.skiphead(gr.sizeof_gr_complex, toskip*options.fft_size)
	mywindow1 = window.hamming(options.fft_size)
	ma_len = 200
	overlap = 100
	self.welch = specest.welch (options.fft_size, overlap, ma_len, True, mywindow1)
	self.f2c = gr.float_to_complex(options.fft_size)
	mywindow2 = window.rectangular(options.fft_size)
	self.ifft = gr.fft_vcc(options.fft_size, False, mywindow2, True)
	self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, options.fft_size)
        self.connect(self.u, self.welch, self.f2c, self.ifft, self.v2s, self.scope)

        self._build_gui(vbox)
	self._setup_events()
	
        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            g = self.subdev.gain_range()
            options.gain = float(g[0]+g[1])/2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            r = self.subdev.freq_range()
            options.freq = float(r[0]+r[1])/2

        self.set_gain(options.gain)

	if options.antenna is not None:
            print "Selecting antenna %s" % (options.antenna,)
            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['[email protected]'].set_value(self.u.adc_freq() / self.u.decim_rate())
            self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
Exemplo n.º 22
0
  def test_001(self):
    vlen = 256
    subc = 208
    L = 8
    cplen = 12
    blocklen = vlen + cplen
    framelength = 11
    bits_per_subc = [2]*vlen
    data_blocks = 10
    
    N = int( 1e8 )
    
    profiling = False

    pre0,fd = morellimengali_designer.create( subc, vlen, L )

    
    ofdm_frames = \
      ofdm_frame_src( vlen, data_blocks, pre0, cplen, framelength, 
                      bits_per_subc )
    
    uut = autocorrelator( vlen/2, vlen/2 )
    
    ref = recursive_timing_metric( vlen )
    
    
    limit_stream = gr.head( gr.sizeof_float, N )
    
    self.tb.connect( ofdm_frames, uut, limit_stream, 
                     gr.null_sink( gr.sizeof_float ) )
    
#    limit_stream.enable_detailed_profiling( profiling )
#    uut.s2.enable_detailed_profiling( profiling )
    
    
    if not profiling:
      limit_stream2 = gr.head( gr.sizeof_float, N )
      
      compare = gr.sub_ff()
      err_acc = ofdm.accumulator_ff()
      skip_err = gr.skiphead( gr.sizeof_float, N-1 )
      last_err_val = gr.head( gr.sizeof_float, 1 )
      err_sink = gr.vector_sink_f()
      
      self.tb.connect( ofdm_frames, ref, limit_stream2, 
                       gr.null_sink( gr.sizeof_float ) )
    
    
      self.tb.connect( uut, ( compare, 0 ) )
      self.tb.connect( ref, ( compare, 1 ) )
      self.tb.connect( compare, err_acc )
      self.tb.connect( err_acc, skip_err )
      self.tb.connect( skip_err, last_err_val )
      self.tb.connect( last_err_val, err_sink )
    
    
#    log_to_file( self.tb, limit_stream, "data/autocorr_uut.float" )
#    log_to_file( self.tb, limit_stream2, "data/autocorr_ref.float" )
    
#    r = time_it( self.tb )
    self.tb.run()
    
#    print "Expected throughput:  %s Samples/s" % ( eng_notation.num_to_str( float(N) / r ) )
    
    if not profiling:
      e = numpy.array( err_sink.data() )[0]
      print "Err: %.7f" % ( e )