Esempio n. 1
0
/**
 * @ingroup dac_sink
 *
 * \param freq_samp Sets DA converter sampling frequency
 */
int initialize() {
	buffer = rtdal_uhd_buffer(1);
	freq_id = param_id("freq_samp");
	if (!freq_id) {
		moderror("Parameter freq_samp not found\n");
		return -1;
	}
	gain_id = param_id("gain");

	if (param_get_int_name("data_type", &data_type)) {
		data_type = 1;
	}
	switch(data_type) {
	case 0:
		input_sample_sz = sizeof(float);
		break;
	case 1:
		input_sample_sz = sizeof(_Complex float);
		break;
	case 2:
		input_sample_sz = sizeof(_Complex short);
		break;
	}

	return 0;
}
Esempio n. 2
0
/**@ingroup gen_remcyclic
 *
 * \param dft_size Size of the OFDM symbol (in samples). This parameter is mandatory.
 * \param cyclic_prefix_sz Size of the cyclic prefix to add to each received symbol (in samples)
 * This parameter is mandatory.
 * \param first_cyclic_prefix_sz Size of the cyclic prefix to add to the first received symbol
 * (in samples). Optional parameter, default is cyclic_prefix_sz
 */
int initialize() {

	dft_size_id = param_id("dft_size");
	if (!dft_size_id) {
		/*moderror("Parameter dft_size undefined\n");
		return -1;*/
		modinfo("Parameter dft_size not defined. Assuming "
		"dft_size = number of input samples on interface 0 - cyclic_prefix_sz.\n");
	}

	cyclic_prefix_sz_id = param_id("cyclic_prefix_sz");
	if (!cyclic_prefix_sz_id) {
		moderror("Parameter cyclic_prefix_sz undefined\n");
		return -1;
	}

	first_cyclic_prefix_sz_id = param_id("first_cyclic_prefix_sz");

	if (NOF_INPUT_ITF != NOF_OUTPUT_ITF) {
		moderror_msg("Fatal error, the number of input interfaces (%d) must be equal to the "
				"number of output interfaces (%d)\n",NOF_INPUT_ITF,NOF_OUTPUT_ITF);
		return -1;
	}

	return 0;
}
Esempio n. 3
0
/**
 * @ingroup Lte Rate Matching of convolutionally encoded information
 * Applied for PDCCH
 * Initialization function
 *
 * \param direction Transmitter mode if 0 and receiver mode otherwise
 * \param E Number of output bits of rate matching in transmitter mode
 * \param S Number of output bits of rate matching in receiver mode
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	if (param_get_int_name("direction", &direction)) {
		moderror_msg("Parameter 'direction' not specified. Assuming "
		  "transmission mode (%d).\n", 0);
		direction = 0;
	}
	if (direction) {
		/* Reception mode */
		S_id = param_id("S");
		if (!S_id) {
			moderror("Parameter S not found\n");
			return -1;
		}

		input_sample_sz=sizeof(float);
		output_sample_sz=sizeof(float);
	} else {
		/* Transmission mode */
		E_id = param_id("E");
		if (!E_id) {
			moderror("Parameter E not found\n");
			return -1;
		}
		input_sample_sz=sizeof(char);
		output_sample_sz=sizeof(char);
	}
	return 0;
}
Esempio n. 4
0
File: source.c Progetto: alring/aloe
/**@ingroup source
 *
 * The available generators are defined in generators.h
 * \param block_length Number of items (bits or samples) to generate
 * \param generator Integer indicating the generator (see generators.h)
 *
 */
int initialize() {
	int size;
	int block_length;

	blen_id = param_id("block_length");
	if (!blen_id) {
		moderror("Parameter block_length not found\n");
		return -1;
	}

	if (param_get_int(blen_id,&block_length) != 1) {
		moderror("Getting integer parameter block_length\n");
		return -1;
	}

	period=1;
	param_get_int_name("period",&period);
	period_cnt=period;

	generator_init_random();

	moddebug("Parameter block_length is %d\n",block_length);

	gen_id = param_id("generator");
	if (!gen_id) {
		moderror("Parameter type not found\n");
		return -1;
	}

	last_type = -1;

	return 0;
}
Esempio n. 5
0
/**
 * @ingroup dac_source
 *
 * \param rate Sets DA converter sampling rateuency
 */
int initialize() {
	var_t pm;
	pm = oesr_var_param_get(ctx, "board");
	if (!pm) {
		moderror("Parameter board undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, board, 128) == -1) {
		moderror("Error getting board value\n");
		return -1;
	}
	pm = oesr_var_param_get(ctx, "args");
	if (pm) {
		if (oesr_var_param_get_value(ctx, pm, args, 128) == -1) {
			moderror("Error getting board value\n");
			return -1;
		}
	} else {
		bzero(args,128);
	}

	blocking=0;
	param_get_int_name("blocking",&blocking);

	wait_packets=0;
	param_get_int_name("wait_packets",&wait_packets);

	nsamples_id = param_id("nsamples");
	if (!nsamples_id) {
		moderror("Parameter nsamples not found\n");
		return -1;
	}

	rate_id = param_id("rate");
	if (!rate_id) {
		moderror("Parameter rate not found\n");
		return -1;
	}
	freq_id = param_id("freq");
	if (!freq_id) {
		moderror("Parameter freq not found\n");
		return -1;
	}
	gain_id = param_id("gain");

	dac = rtdal_dac_open(board,args);
	if (!dac) {
		moderror_msg("Initiating DAC %s (args=%s)\n",board,args);
		return -1;
	}
	if (process_params()) {
		moderror("Setting parameters\n");
		return -1;
	}
	return 0;
}
Esempio n. 6
0
optional<name> get_undef_param(level const & l, level_param_names const & ps) {
    optional<name> r;
    for_each(l, [&](level const & l) {
            if (!has_param(l) || r)
                return false;
            if (is_param(l) && std::find(ps.begin(), ps.end(), param_id(l)) == ps.end())
                r = param_id(l);
            return true;
        });
    return r;
}
Esempio n. 7
0
/**
 * @ingroup dac_sink
 *
 * \param rate Sets DA converter sampling rateuency
 */
int initialize() {
	var_t pm;
	pm = oesr_var_param_get(ctx, "board");
	if (!pm) {
		moderror("Parameter board undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, board, 128) == -1) {
		moderror("Error getting board value\n");
		return -1;
	}
	pm = oesr_var_param_get(ctx, "args");
	if (pm) {
		if (oesr_var_param_get_value(ctx, pm, args, 128) == -1) {
			moderror("Error getting board value\n");
			return -1;
		}
	} else {
		bzero(args,128);
	}

	check_blen=0;
	param_get_int_name("check_blen",&check_blen);
	enable_dac=1;
	param_get_int_name("enable_dac",&enable_dac);

	rate_id = param_id("rate");
	if (!rate_id) {
		moderror("Parameter rate not found\n");
		return -1;
	}
	freq_id = param_id("freq");
	if (!freq_id) {
		moderror("Parameter freq not found\n");
		return -1;
	}
	gain_id = param_id("gain");
	amp_id = param_id("amplitude");

	blocking=0;
	param_get_int_name("blocking",&blocking);

	if (!enable_dac) {
		modinfo("Warning: DAC is disabled\n");
	}

	dac = rtdal_dac_open(board,args);
	return process_params();
}
Esempio n. 8
0
/** @ingroup gen_convcoderr
 * \param padding (Optional) Default 0. Number of zero bits to add to the output after encoding the data.
 * \param constraint_length
 * \param tail_bit 1 for tail-bitting, 0 for none
 * \param rate
 * \param generator_i polynomy of the i-th generator
 */
int initialize() {
	int i;
	char tmp[64];

	padding_id = param_id("padding");
	if (!padding_id) {
		padding = 0;
		moddebug("Parameter padding not configured. Setting to %d\n",padding);
	}
	if (param_get_int_name("constraint_length",&constraint_length)) {
		moderror("Parameter constraint_length not specified\n");
		return -1;
	}
	if (param_get_int_name("tail_bit",&tail_bit)) {
		moderror("Parameter tail_bit not specified\n");
		return -1;
	}
	if (param_get_int_name("rate",&rate)) {
		moderror("Parameter rate not specified\n");
		return -1;
	}
	if (rate<0 || rate > MAX_RATE) {
		moderror_msg("Invalid rate %d\n",rate);
		return -1;
	}
	for (i=0;i<rate;i++) {
		snprintf(tmp,64,"generator_%d",i);
		if (param_get_int_name(tmp,&g[i])) {
			moderror_msg("Parameter %s not specified\n",tmp);
			return -1;
		}
	}

	return 0;
}
Esempio n. 9
0
/** Stores in the address of the second parameter the scalar float value of the
 * parameter name.
 * Tries to parse the parameter as an float. Read param_addr() for supported formats.
 * \returns 0 on success or -1 on error.
 */
int param_get_float_name(char *name, float *value) {
	pmid_t id = param_id(name);
	if (id == NULL) {
		return -1;
	}
	return (param_get_float(id,value)==-1)?-1:0;
}
Esempio n. 10
0
/**
 * @ingroup udp_sink
 *
 * \param address IP address to connect
 * \param port	Port to connect
 */
int initialize() {
	char address[64];
	var_t pm;
	int i;
	int port;

	blen_id = param_id("nof_pkts");

	if (param_get_int_name("port",&port)) {
		moderror("Port undefined\n");
		return -1;
	}

#ifdef _COMPILE_ALOE
	pm = oesr_var_param_get(ctx, "address");
	if (!pm) {
		moderror("Parameter file_name undefined\n");
		return -1;
	}

	if (oesr_var_param_get_value(ctx, pm, address, 64) == -1) {
		moderror("Error getting file_name value\n");
		return -1;
	}
#endif

	fd = create_client_upd(address,port,&servaddr);
	if (fd == -1) {
		moderror("Creating socket\n");
		return -1;
	}
	modinfo_msg("sock=%d\n",fd);

	return 0;
}
Esempio n. 11
0
/**
 * Generates input signal. VERY IMPORTANT to fill length vector with the number of
 * samples that have been generated.
 * @param inp Input interface buffers. Data from other interfaces is stacked in the buffer.
 * Use in(ptr,idx) to access the address.
 *
 * @param lengths Save on n-th position the number of samples generated for the n-th interface
 */
int generate_input_signal(void *in, int *lengths)
{
	int i;
	input_t *input = in;
	int block_length;
	pmid_t blen_id;

	blen_id = param_id("block_length");
	if (!blen_id) {
		moderror("Parameter block_length not found\n");
		return -1;
	}
	if (!param_get_int(blen_id,&block_length)) {
		moderror("Getting integer parameter block_length\n");
		return -1;
	}

	modinfo_msg("Parameter block_length is %d\n",block_length);


	/** HERE INDICATE THE LENGTH OF THE SIGNAL */
	lengths[0] = block_length;

	for (i=0;i<block_length;i++) {
		input[i] = 0.7 + 0.7*_Complex_I;
	}
	return 0;
}
Esempio n. 12
0
/**
 * @ingroup gen_hard_demod
 * Initializes parameters.
 *
 * Modulation types: BPSK, QPSK, QAM16, QAM64.
 *
 * \param modulation Modulation index (0: BPSK, 1: QPSK, 2: QAM16, 3: QAM64).
 * Default: 1 (QPSK).
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	/* obtains a handler for fast access to the parameter */
	modulation_id = param_id("modulation");

	return 0;
}
Esempio n. 13
0
unsigned level_cases_on(vm_obj const & o, buffer<vm_obj> & data) {
    level const & l = to_level(o);
    switch (l.kind()) {
    case level_kind::Zero:
        break;
    case level_kind::Succ:
        data.push_back(to_obj(succ_of(l)));
        break;
    case level_kind::Max:
        data.push_back(to_obj(max_lhs(l)));
        data.push_back(to_obj(max_rhs(l)));
        break;
    case level_kind::IMax:
        data.push_back(to_obj(imax_lhs(l)));
        data.push_back(to_obj(imax_rhs(l)));
        break;
    case level_kind::Param:
        data.push_back(to_obj(param_id(l)));
        break;
    case level_kind::Global:
        data.push_back(to_obj(global_id(l)));
        break;
    case level_kind::Meta:
        data.push_back(to_obj(meta_id(l)));
        break;
    }
    return static_cast<unsigned>(l.kind());
}
Esempio n. 14
0
/**
 *  Generates input signal. VERY IMPORTANT to fill length vector with the number of
 * samples that have been generated.
 * @param inp Input interface buffers. Data from other interfaces is stacked in the buffer.
 * Use in(ptr,idx) to access the address.
 *
 * @param lengths Save on n-th position the number of samples generated for the n-th interface
 */
int generate_input_signal(void *in, int *lengths)
{
  int i;
  input_t *input = in;
  int block_length;
  pmid_t blen_id;

  blen_id = param_id("block_length");
  if (!blen_id) {
    moderror("Parameter block_length not found\n");
    return -1;
  }
  if (!param_get_int(blen_id,&block_length)) {
    moderror("Getting integer parameter block_length\n");
    return -1;
  }

  modinfo_msg("Parameter block_length is %d\n",block_length);


  /** HERE INDICATE THE LENGTH OF THE SIGNAL */
  lengths[0] = block_length;

  for (i=0;i<block_length;i++) {
#ifdef GENESRSLTE_TCOD_RATE_COMPLEX
    __real__ input[i] = (float) ((i+offset)%(block_length));
    __imag__ input[i] = (float) ((block_length-i-1+offset)%(block_length));
#else
    input[i] = (i+offset)%(block_length);
#endif
  }
  offset++;
  return 0;
}
Esempio n. 15
0
 level collect(level const & l) {
     return replace(l, [&](level const & l) {
             if (is_meta(l)) {
                 name const & id = meta_id(l);
                 if (auto r = m_univ_meta_to_param.find(id)) {
                     return some_level(*r);
                 } else {
                     name n      = m_prefix.append_after(m_next_idx);
                     m_next_idx++;
                     level new_r = mk_param_univ(n);
                     m_univ_meta_to_param.insert(id, new_r);
                     m_univ_meta_to_param_inv.insert(n, l);
                     m_level_params.push_back(n);
                     return some_level(new_r);
                 }
             } else if (is_param(l)) {
                 name const & id = param_id(l);
                 if (!m_found_univ_params.contains(id)) {
                     m_found_univ_params.insert(id);
                     m_level_params.push_back(id);
                 }
             }
             return none_level();
         });
 }
Esempio n. 16
0
void collect_univ_params_core(level const & l, name_set & r) {
    for_each(l, [&](level const & l) {
            if (!has_param(l))
                return false;
            if (is_param(l))
                r.insert(param_id(l));
            return true;
        });
}
Esempio n. 17
0
int initialize() {
	int tslen;

	if (param_get_int_name("direction",&mode)) {
		mode = MODE_ADD;
	}

	if (param_get_int_name("print_nof_pkts",&print_nof_pkts)) {
		print_nof_pkts = 0;
	} else {
		print_nof_pkts_cnt = 0;
	}

	long_crc_id = param_id("long_crc");
	if (param_get_int(long_crc_id,&long_crc) != 1) {
		modinfo_msg("Parameter long_crc not configured. Set to %d\n",
				DEFAULT_LONG_CRC);
		long_crc = DEFAULT_LONG_CRC;
		long_crc_id = NULL;
	}

	poly_id = param_id("poly");
	if (param_get_int(poly_id,&poly) != 1) {
		poly = DEFAULT_POLY;
		poly_id = NULL;
	}


#ifdef _COMPILE_ALOE
	tslen = oesr_tslot_length(ctx);
	if (tslen > EXEC_MIN_INTERVAL_MS*1000) {
		interval_ts = 1;
	} else {
		interval_ts = (EXEC_MIN_INTERVAL_MS*1000)/tslen;
		modinfo_msg("Timeslot is %d usec, refresh interval set to %d tslots\n",tslen,interval_ts);
	}
#endif
	total_errors=0;
	total_pkts=0;
	tscnt=0;
	return 0;
}
Esempio n. 18
0
/**
 * @ingroup channel
 *
 * \param variance Gaussian noise variance
 * \param gain Channel gain
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	gain_re_id = param_id("gain_re");
	gain_im_id = param_id("gain_im");
	variance_id = param_id("variance");
	scale_id = param_id("noise_scale");

	if (!param_get_float_name("snr_min",&snr_min)
			&& !param_get_float_name("snr_max",&snr_max)
			&& !param_get_float_name("snr_step",&snr_step)
			&& !param_get_int_name("num_realizations",&num_realizations)) {
		auto_mode=1;
		snr_current=snr_min;
		cnt_realizations=0;
	} else {
		auto_mode=0;
	}

	return 0;
}
Esempio n. 19
0
/**
 * @ingroup gen_hard_demod
 * Initializes parameters.
 *
 * Modulation types: BPSK, QPSK, QAM16, QAM64.
 *
 * \param modulation Modulation index (1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64).
 * Default: 1 (BPSK).
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	/* obtains a handler for fast access to the parameter */
	modulation_id = param_id("modulation");

	param_get_int_name("in_real",&in_real);
	if (in_real == 1) {
		input_sample_sz=sizeof(float);
	}

	return 0;
}
Esempio n. 20
0
/**
 * @ingroup Zero padding/unpadding
 * This module has two operational modes.
 * Zero-padding mode (direction = 0): Pads pre_padding and post_padding zeros
 * to each of the nof_packets data packets
 * Sample-unpadding mode (direction != 0): Eliminates pre_padding and
 * post_padding samples from each of the nof_packets data packets
 *
 * \param data_type Specify data type: 0 for _Complex float, 1 for real, 2 for
 * char (default: 0)
 * \param direction Padding if 0 and unpadding otherwise (default: 0)
 * \param pre_padding Number of samples to be added to/ eliminated from the
 * beginning of the packet
 * \param post_padding Number of samples to be added to/ eliminated from the
 * end of the packet
 * \param nof_packets Number of data packets that the input stream contains
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int data_type;

	if (param_get_int(param_id("data_type"),&data_type) != 1) {
		modinfo("Parameter data_type undefined. Using complex data type\n");
		data_type = DATA_TYPE_COMPLEX;
	}

	input_sample_sz = get_input_sample_sz(data_type);
	output_sample_sz = input_sample_sz;
	moddebug("Chosen data type %d sample_sz=%d\n",data_type, input_sample_sz);

	if (param_get_int(param_id("direction"),&direction) != 1) {
		modinfo("Parameter direction undefined. Assuming padding mode.\n");
		direction = 0;
	}

	pre_padding_id = param_id("pre_padding");
	if (!pre_padding_id) {
		modinfo("Parameter pre_padding undefined. Adding 0 bits.\n");
		pre_padding = 0;
	}

	post_padding_id = param_id("post_padding");
	if (!post_padding_id) {
		modinfo("Parameter post_padding undefined. Adding 0 bits.\n");
		post_padding = 0;
	}

	nof_packets_id = param_id("nof_packets");
	if (!nof_packets_id) {
		modinfo("Parameter nof_packets undefined. Assuming 1 packet.\n");
		nof_packets = 1;
	}

	return 0;
}
Esempio n. 21
0
/**@ingroup gen_modulator
 *
 * \param modulation Choose between 0: BPŜK, 1: QPSK, 2: QAM16 or 3: QAM64. Default is BPSK.
 */
int initialize() {

	modulation_id = param_id("modulation");
	if (!modulation_id) {
		modinfo("Parameter modulation not configured. Setting to BPSK\n");
		modulation = BPSK;
	}

	set_BPSKtable();
	set_QPSKtable();
	set_16QAMtable();
	set_64QAMtable();

	return 0;
}
Esempio n. 22
0
int initialize() {

	/* Initialization Parameters */
	if (param_get_int_name("cache_seq_nbits", &binsource.init.cache_seq_nbits)) {
		binsource.init.cache_seq_nbits = 2;
	}
	if (param_get_int_name("seed", &binsource.init.seed)) {
		binsource.init.seed = 0;
	}

	/* Input Control Parameters */
	nbits_id = param_id("nbits");

	/* Initialization function */
	return binsource_initialize(&binsource);
}
Esempio n. 23
0
/**@ingroup gen_dft
 * \param direction Direction of the dft: 0 computes a dft and 1 computes an idft (default is 0)
 * \param mirror 0 computes a normal dft, 1 swaps the two halfes of the input signal before computing
 * the dft (used in LTE) (default is 0)
 * \param psd Set to 1 to compute the power spectral density (untested) (default is 0)
 * \param out_db Set to 1 to produce the output results in dB (untested) (default is 0)
 * \param dft_size Number of DFT points. This parameter is mandatory.
 */
int initialize() {
	int tmp;
	int i;

	memset(plans,0,sizeof(dft_plan_t)*NOF_PRECOMPUTED_DFT);
	memset(extra_plans,0,sizeof(dft_plan_t)*MAX_EXTRA_PLANS);

	if (param_get_int(param_id("direction"),&direction) != 1) {
		modinfo("Parameter direction not defined. Setting to FORWARD\n");
		direction = 0;
	}

	options = 0;
	if (param_get_int(param_id("mirror"),&tmp) != 1) {
		modinfo("Parameter mirror not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_MIRROR;
	}
	if (param_get_int(param_id("psd"),&tmp) != 1) {
		modinfo("Parameter psd not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_PSD;
	}
	if (param_get_int(param_id("out_db"),&tmp) != 1) {
		modinfo("Parameter out_db not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_OUT_DB;
	}
	if (param_get_int(param_id("normalize"),&tmp) != 1) {
		modinfo("Parameter normalize not defined. Disabling. \n");
	} else {
		if (tmp) options |= DFT_NORMALIZE;
	}

	dft_size_id = param_id("dft_size");
	if (!dft_size_id) {
		moderror("Parameter dft_size not defined\n");
		return -1;
	}

	if (dft_plan_multi_c2c(precomputed_dft_len, (!direction)?FORWARD:BACKWARD, NOF_PRECOMPUTED_DFT,
			plans)) {
		moderror("Precomputing plans\n");
		return -1;
	}
	for (i=0;i<NOF_PRECOMPUTED_DFT;i++) {
		plans[i].options = options;
	}

	return 0;
}
Esempio n. 24
0
/**
 * @ingroup lte_ratematching
 *  Rate adapter for LTE DL/UL. Code rate is out_len/in_len
 *
 *  There are two ways to configure this module:
 *    - Automatic: Choose tslot_idx, modulation and fft_size to let the module
 *    automatically determine the required output length at each slot, according to the
 *    LTE slotting
 *    - Manual: Set out_len variable to the desired output length.
 *
 *  Automatic mode is selected when parameter out_len is not defined.
 *
 * \param tslot_idx In automatic mode, indicates the tslot index
 * \param mcs In automatic mode, indicates the Modulation and Coding Scheme (MCS)
 * \param nrb In automatic mode, indicates the Number of allocated Resource Blocs
 * \param fft_size In automatic mode, indicates the length of the fft
 * \param cp_is_long In automatic mode, non-null selects long cyclic prefix
 * \param lteslots_x_timeslot In automatic mode, number of lte slots per execution time slot
 * \param out_len Output length
 * \param rv_idx Document this parameter
 * \param direction 0 for the transmitter, 1 for the receiver
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int size;

	out_len_id = param_id("out_len");
	if (!out_len_id) {
		tslot_idx_id = param_id("tslot_idx");
		tslot_idx = 0;

		if (!(fft_size_id = param_id("fft_size"))) {
			moderror("In automatic mode, parameter fft_size must be specified\n");
		}

		if (!(mcs_id = param_id("mcs"))) {
			moderror("In automatic mode, parameter mcs must be specified\n");
		}
		if (!(nrb_id = param_id("nrb"))) {
			moderror("In automatic mode, parameter nrb must be specified\n");
		}
		if (!(cp_long_id = param_id("cp_is_long"))) {
			moderror("In automatic mode, parameter cp_is_long must be specified\n");
		}
		if (param_get_int_name("lteslots_x_timeslot",&lteslots_x_timeslot)) {
			moderror("In automatic mode, parameter lteslots_x_timeslot must be specified\n");
		}
	}

	rvidx_id = param_id("rvidx");

	if (param_get_int_name("direction",&direction)) {
		moderror("Error getting parameter direction\n");
		return -1;
	}

	if (direction) {
		input_sample_sz=sizeof(float);
		output_sample_sz=sizeof(float);
	} else {
		input_sample_sz=sizeof(char);
		output_sample_sz=sizeof(char);
	}

	tslot_idx=0;

	return 0;
}
Esempio n. 25
0
/**
 * @ingroup template
 *  Document here the module's initialization parameters
 *
 * The documentation should explain which are the possible parameters, what they do and if they are
 * mandatory or optional (indicating the default value in such case).
 *
 * \param gain Document paramater gain
 * \param block_length Document parameter block_length
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {

	/* obtains a handler for fast access to the parameter */
	gain_id = param_id("gain");
	/* In this case, we are obtaining the parameter value directly */
	if (param_get_int_name("block_length", &block_length)) {
		block_length = 0;
	}
	/* use this function to print formatted messages */modinfo_msg("Parameter block_length is %d\n",block_length);

	/* Verify control parameters */
	if (block_length > input_max_samples || block_length < 0) {
		moderror_msg("Invalid block length %d\n", block_length);
		return -1;
	}

	/* here you may do some other initialization stuff */

	return 0;
}
Esempio n. 26
0
/**
 * @ingroup lte_resource_mapper
 *
 *	See lte_ctrl_tx for grid params.
 *
 * \param nof_channels Number of channels to extract
 * \param channel_id_n Id of the n-th channel to extract (configured in channel_setup.h)
 * \param (optional) subframe_idx, if not provided, subframe_idx is counted automatically starting at zero
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int i;
	char tmp[64];
	int max_out_port;

	max_out_port = read_channels();

	grid.fft_size = 128;
	grid.nof_prb = 6;
	grid.nof_osymb_x_subf = 14;
	grid.nof_ports = 1;
	grid.cell_id = 0;
	grid.cfi = -1;
	grid.nof_pdsch = 0;
	grid.nof_pdcch = 0;

	subframe_idx_id = param_id("subframe_idx");
	if (!subframe_idx_id) {
		subframe_idx = 0;
	}

	if (param_get_int_name("nof_channels",&nof_channels)) {
		nof_channels = 1;
	}
	if (nof_channels > MAX_CHANNELS) {
		moderror_msg("Maximum allowed channels is %d (%d)\n",nof_channels,MAX_CHANNELS);
		return -1;
	}
	for (i=0;i<nof_channels;i++) {
		snprintf(tmp,64,"channel_id_%d",i);
		if (param_get_int_name(tmp,&channel_ids[i])) {
			channel_ids[i] = i;
		}
	}

	nof_output_itf = max_out_port+1;
	nof_input_itf = 1;


	return 0;
}
Esempio n. 27
0
level instantiate(level const & l, level_param_names const & ps, levels const & ls) {
    lean_assert(length(ps) == length(ls));
    return replace(l, [=](level const & l) {
            if (!has_param(l)) {
                return some_level(l);
            } else if (is_param(l)) {
                name const & id = param_id(l);
                list<name> const *it1 = &ps;
                list<level> const * it2 = &ls;
                while (!is_nil(*it1)) {
                    if (head(*it1) == id)
                        return some_level(head(*it2));
                    it1 = &tail(*it1);
                    it2 = &tail(*it2);
                }
                return some_level(l);
            } else {
                return none_level();
            }
        });
}
Esempio n. 28
0
/**
 * @ingroup lte_resource_mapper
 *
 *	See lte_ctrl_tx for grid params.
 *
 * \param (optional) subframe_idx, if not provided, subframe_idx is counted automatically starting at zero
 *
 * \returns This function returns 0 on success or -1 on error
 */
int initialize() {
	int max_in_port;

	max_in_port = read_channels();

	grid.fft_size = 128;
	grid.nof_prb = 6;
	grid.nof_osymb_x_subf = 14;
	grid.nof_ports = 1;
	grid.cell_id = 0;
	grid.cfi = 1;
	grid.nof_pdcch = 1;
	grid.pdcch[0].nof_cce = 2;
	grid.nof_pdsch = 1;
	grid.pdsch[0].rbg_mask=0xFFFF;
	grid.verbose = 0;

	if (lte_grid_init(&grid)) {
		moderror("Initiating channels grid\n");
		return -1;
	}

	nof_output_itf = 1;
	nof_input_itf = max_in_port+1;

	if (init_refsinc_signals()) {
		return -1;
	}

	subframe_idx_id = param_id("subframe_idx");
	if (!subframe_idx_id) {
		subframe_idx = 0;
	}

	return 0;
}
Esempio n. 29
0
/**
 * Generates input signal. VERY IMPORTANT to fill length vector with the number of
 * samples that have been generated.
 * @param inp Input interface buffers. Data from other interfaces is stacked in the buffer.
 * Use in(ptr,idx) to access the address.
 *
 * @param lengths Save on n-th position the number of samples generated for the n-th interface
 */
int generate_input_signal(void *in, int *lengths)
{
	int i;
	input_t *input = in;
	int block_length;
	pmid_t blen_id;
	int size;

	blen_id = param_id("block_length");
	if (!blen_id) {
		moderror("Parameter block_length not found\n");
		return -1;
	}
	if (!param_get_int(blen_id,&block_length)) {
		moderror("Getting integer parameter block_length\n");
		return -1;
	}

	modinfo_msg("Parameter block_length is %d\n",block_length);


	/** HERE INDICATE THE LENGTH OF THE SIGNAL */
	lengths[0] = block_length;

	for (i=0;i<block_length;i++) {
		input[i] = 0x1;
	}
	/* UL: test*/
	input[10] = 'x';
	input[11] = 'x';
	input[12] = 'x';
	input[13] = 'x';
	input[14] = 'y';

	return 0;
}
Esempio n. 30
0
static environment mk_below(environment const & env, name const & n, bool ibelow) {
    if (!is_recursive_datatype(env, n))
        return env;
    if (is_inductive_predicate(env, n))
        return env;
    inductive::inductive_decls decls = *inductive::is_inductive_decl(env, n);
    type_checker tc(env);
    name_generator ngen;
    unsigned nparams       = std::get<1>(decls);
    declaration ind_decl   = env.get(n);
    declaration rec_decl   = env.get(inductive::get_elim_name(n));
    unsigned nindices      = *inductive::get_num_indices(env, n);
    unsigned nminors       = *inductive::get_num_minor_premises(env, n);
    unsigned ntypeformers  = length(std::get<2>(decls));
    level_param_names lps  = rec_decl.get_univ_params();
    bool is_reflexive      = is_reflexive_datatype(tc, n);
    level  lvl             = mk_param_univ(head(lps));
    levels lvls            = param_names_to_levels(tail(lps));
    level_param_names blvls; // universe level parameters of ibelow/below
    level  rlvl;  // universe level of the resultant type
    // The arguments of below (ibelow) are the ones in the recursor - minor premises.
    // The universe we map to is also different (l+1 for below of reflexive types) and (0 fo ibelow).
    expr ref_type;
    expr Type_result;
    if (ibelow) {
        // we are eliminating to Prop
        blvls      = tail(lps);
        rlvl       = mk_level_zero();
        ref_type   = instantiate_univ_param(rec_decl.get_type(), param_id(lvl), mk_level_zero());
    } else if (is_reflexive) {
        blvls = lps;
        rlvl  = get_datatype_level(ind_decl.get_type());
        // if rlvl is of the form (max 1 l), then rlvl <- l
        if (is_max(rlvl) && is_one(max_lhs(rlvl)))
            rlvl = max_rhs(rlvl);
        rlvl       = mk_max(mk_succ(lvl), rlvl);
        ref_type   = instantiate_univ_param(rec_decl.get_type(), param_id(lvl), mk_succ(lvl));
    } else {
        // we can simplify the universe levels for non-reflexive datatypes
        blvls       = lps;
        rlvl        = mk_max(mk_level_one(), lvl);
        ref_type    = rec_decl.get_type();
    }
    Type_result        = mk_sort(rlvl);
    buffer<expr> ref_args;
    to_telescope(ngen, ref_type, ref_args);
    if (ref_args.size() != nparams + ntypeformers + nminors + nindices + 1)
        throw_corrupted(n);

    // args contains the below/ibelow arguments
    buffer<expr> args;
    buffer<name> typeformer_names;
    // add parameters and typeformers
    for (unsigned i = 0; i < nparams; i++)
        args.push_back(ref_args[i]);
    for (unsigned i = nparams; i < nparams + ntypeformers; i++) {
        args.push_back(ref_args[i]);
        typeformer_names.push_back(mlocal_name(ref_args[i]));
    }
    // we ignore minor premises in below/ibelow
    for (unsigned i = nparams + ntypeformers + nminors; i < ref_args.size(); i++)
        args.push_back(ref_args[i]);

    // We define below/ibelow using the recursor for this type
    levels rec_lvls       = cons(mk_succ(rlvl), lvls);
    expr rec              = mk_constant(rec_decl.get_name(), rec_lvls);
    for (unsigned i = 0; i < nparams; i++)
        rec = mk_app(rec, args[i]);
    // add type formers
    for (unsigned i = nparams; i < nparams + ntypeformers; i++) {
        buffer<expr> targs;
        to_telescope(ngen, mlocal_type(args[i]), targs);
        rec = mk_app(rec, Fun(targs, Type_result));
    }
    // add minor premises
    for (unsigned i = nparams + ntypeformers; i < nparams + ntypeformers + nminors; i++) {
        expr minor = ref_args[i];
        expr minor_type = mlocal_type(minor);
        buffer<expr> minor_args;
        minor_type = to_telescope(ngen, minor_type, minor_args);
        buffer<expr> prod_pairs;
        for (expr & minor_arg : minor_args) {
            buffer<expr> minor_arg_args;
            expr minor_arg_type = to_telescope(tc, mlocal_type(minor_arg), minor_arg_args);
            if (is_typeformer_app(typeformer_names, minor_arg_type)) {
                expr fst  = mlocal_type(minor_arg);
                minor_arg = update_mlocal(minor_arg, Pi(minor_arg_args, Type_result));
                expr snd = Pi(minor_arg_args, mk_app(minor_arg, minor_arg_args));
                prod_pairs.push_back(mk_prod(tc, fst, snd, ibelow));
            }
        }
        expr new_arg = foldr([&](expr const & a, expr const & b) { return mk_prod(tc, a, b, ibelow); },
                             [&]() { return mk_unit(rlvl, ibelow); },
                             prod_pairs.size(), prod_pairs.data());
        rec = mk_app(rec, Fun(minor_args, new_arg));
    }

    // add indices and major premise
    for (unsigned i = nparams + ntypeformers; i < args.size(); i++) {
        rec = mk_app(rec, args[i]);
    }

    name below_name  = ibelow ? name{n, "ibelow"} : name{n, "below"};
    expr below_type  = Pi(args, Type_result);
    expr below_value = Fun(args, rec);

    bool use_conv_opt = true;
    declaration new_d = mk_definition(env, below_name, blvls, below_type, below_value,
                                      use_conv_opt);
    environment new_env = module::add(env, check(env, new_d));
    new_env = set_reducible(new_env, below_name, reducible_status::Reducible);
    if (!ibelow)
        new_env = add_unfold_hint(new_env, below_name, nparams + nindices + ntypeformers);
    return add_protected(new_env, below_name);
}