def _handle_sources(self): """ Sort out sources and eqs for them :return: """ assert len(self.fhosts) > 0 _feng_cfg = self.configd['fengine'] source_names = _feng_cfg['source_names'].strip().split(',') source_mcast = _feng_cfg['source_mcast_ips'].strip().split(',') assert len(source_mcast) == len(source_names), ( 'Source names (%d) must be paired with multicast source ' 'addresses (%d)' % (len(source_names), len(source_mcast))) # match eq polys to source names eq_polys = {} for src_name in source_names: eq_polys[src_name] = utils.process_new_eq( _feng_cfg['eq_poly_%s' % src_name]) # assemble the sources given into a list _fengine_sources = [] for source_ctr, address in enumerate(source_mcast): new_source = DataSource.from_mcast_string(address) new_source.name = source_names[source_ctr] assert new_source.ip_range == self.ports_per_fengine, ( 'F-engines should be receiving from %d streams.' % self.ports_per_fengine) _fengine_sources.append(new_source) # assign sources and eqs to fhosts self.logger.info('Assigning DataSources, EQs and DelayTrackers to ' 'f-engines...') source_ctr = 0 self.fengine_sources = [] for fhost in self.fhosts: self.logger.info('\t%s:' % fhost.host) _eq_dict = {} for fengnum in range(0, self.f_per_fpga): _source = _fengine_sources[source_ctr] _eq_dict[_source.name] = {'eq': eq_polys[_source.name], 'bram_num': fengnum} assert _source.ip_range == _fengine_sources[0].ip_range, ( 'All f-engines should be receiving from %d streams.' % self.ports_per_fengine) self.fengine_sources.append({'source': _source, 'source_num': source_ctr, 'host': fhost, 'numonhost': fengnum}) fhost.add_source(_source) self.logger.info('\t\t%s' % _source) source_ctr += 1 fhost.eqs = _eq_dict if source_ctr != len(self.fhosts) * self.f_per_fpga: raise RuntimeError('We have different numbers of sources (%d) and ' 'f-engines (%d). Problem.', source_ctr, len(self.fhosts) * self.f_per_fpga) self.logger.info('done.')
def initialise_pre_gbe(self): """ Set up f-engines on this device. This is done after programming the devices in the instrument. :return: """ if 'x_setup' in self.hosts[0].registers.names(): self.logger.info('Found num_x independent f-engines') # set up the x-engine information in the f-engine hosts num_x_hosts = len(self.corr.xhosts) num_x = num_x_hosts * int(self.corr.configd['xengine']['x_per_fpga']) f_per_x = self.corr.n_chans / num_x ip_per_x = 1.0 THREADED_FPGA_OP( self.hosts, timeout=10, target_function=( lambda fpga_: fpga_.registers.x_setup.write(f_per_x=f_per_x, ip_per_x=ip_per_x, num_x=num_x,),)) time.sleep(1) else: self.logger.info('Found FIXED num_x f-engines') # set eq and shift self.eq_write_all() self.set_fft_shift_all() # set up the fpga comms self.tx_disable() THREADED_FPGA_OP( self.hosts, timeout=10, target_function=( lambda fpga_: fpga_.registers.control.write(gbe_rst=True),)) self.clear_status_all() # where does the f-engine data go? self.corr.fengine_output = DataSource.from_mcast_string( self.corr.configd['fengine']['destination_mcast_ips']) self.corr.fengine_output.name = 'fengine_destination' fdest_ip = int(self.corr.fengine_output.ip_address) THREADED_FPGA_OP(self.hosts, timeout=5, target_function=( lambda fpga_: fpga_.registers.iptx_base.write_int(fdest_ip),)) # set the sample rate on the Fhosts for host in self.hosts: host.rx_data_sample_rate_hz = self.corr.sample_rate_hz
def parse_sources(name_string, ip_string): """ Parse lists of source name and IPs into a list of DataSource objects. :return: """ source_names = name_string.strip().split(',') source_mcast = ip_string.strip().split(',') assert len(source_mcast) == len(source_names), ( 'Source names (%i) must be paired with multicast source ' 'addresses (%i)' % (len(source_names), len(source_mcast))) _sources = [] source_ctr = 0 for counter, address in enumerate(source_mcast): new_source = DataSource.from_mcast_string(address) new_source.name = source_names[counter] new_source.source_number = source_ctr _sources.append(new_source) if source_ctr > 0: assert new_source.ip_range == _sources[0].ip_range,\ 'DataSources have to offer the same IP range.' source_ctr += 1 return _sources