Exemplo n.º 1
0
int chest_init_LTEDL(chest_t *q, lte_cell_t cell) {
  int ret; 
  ret = chest_init(q, cell.nof_prb * RE_X_RB, CP_NSYMB(cell.cp), cell.nof_ports);
  if (ret != LIBLTE_SUCCESS) {
    return ret;
  } else {
    return chest_ref_LTEDL(q, cell);    
  }
}
Exemplo n.º 2
0
/** High-level API
*/
int chest_initialize(chest_hl* h) {

	if (!h->init.nof_symbols) {
		h->init.nof_symbols = CPNORM_NSYMB; // Normal CP
	}
	if (!h->init.nof_prb) {
		h->init.nof_prb = 6;
	}

	if (chest_init(&h->obj, LINEAR, (h->init.nof_symbols==CPNORM_NSYMB)?CPNORM:CPEXT,
			h->init.nof_prb, h->init.nof_ports)) {
		fprintf(stderr, "Error initializing equalizer\n");
		return -1;
	}
	if (h->init.cell_id != -1) {
		if (chest_ref_LTEDL(&h->obj, h->init.cell_id)) {
			fprintf(stderr, "Error initializing reference signal\n");
			return -1;
		}
	}

	return 0;
}
Exemplo n.º 3
0
int main(int argc, char **argv) {
	chest_t eq;
	cf_t *input = NULL, *ce = NULL, *h = NULL;
	refsignal_t refs;
	int i, j, n_port, n_slot, cid, num_re;
	int ret = -1;
	int max_cid;
	FILE *fmatlab = NULL;
	float mse_mag, mse_phase;

	parse_args(argc,argv);

	if (output_matlab) {
		fmatlab=fopen(output_matlab, "w");
		if (!fmatlab) {
			perror("fopen");
			goto do_exit;
		}
	}

	num_re = nof_prb * RE_X_RB * CP_NSYMB(cp);

	input = malloc(num_re * sizeof(cf_t));
	if (!input) {
		perror("malloc");
		goto do_exit;
	}
	h = malloc(num_re * sizeof(cf_t));
	if (!h) {
		perror("malloc");
		goto do_exit;
	}
	ce = malloc(num_re * sizeof(cf_t));
	if (!ce) {
		perror("malloc");
		goto do_exit;
	}

	if (cell_id == -1) {
		cid = 0;
		max_cid = 504;
	} else {
		cid = cell_id;
		max_cid = cell_id;
	}
	while(cid <= max_cid) {
		if (chest_init(&eq, LINEAR, cp, nof_prb, MAX_PORTS)) {
			fprintf(stderr, "Error initializing equalizer\n");
			goto do_exit;
		}

		if (chest_ref_LTEDL(&eq, cid)) {
			fprintf(stderr, "Error initializing reference signal\n");
			goto do_exit;
		}

		for (n_slot=0;n_slot<NSLOTS_X_FRAME;n_slot++) {
			for (n_port=0;n_port<MAX_PORTS;n_port++) {

				if (refsignal_init_LTEDL(&refs, n_port, n_slot, cid, cp, nof_prb)) {
					fprintf(stderr, "Error initiating CRS slot=%d\n", i);
					return -1;
				}

				bzero(input, sizeof(cf_t) * num_re);
				for (i=0;i<num_re;i++) {
					input[i] = 0.5-rand()/RAND_MAX+I*(0.5-rand()/RAND_MAX);
				}

				bzero(ce, sizeof(cf_t) * num_re);
				bzero(h, sizeof(cf_t) * num_re);

				refsignal_put(&refs, input);

				refsignal_free(&refs);

				for (i=0;i<CP_NSYMB(cp);i++) {
					for (j=0;j<nof_prb * RE_X_RB;j++) {
						float x = -1+(float) i/CP_NSYMB(cp) + cosf(2 * M_PI * (float) j/nof_prb/RE_X_RB);
						h[i*nof_prb * RE_X_RB+j] = (3+x) * cexpf(I * x);
						input[i*nof_prb * RE_X_RB+j] *= h[i*nof_prb * RE_X_RB+j];
					}
				}

				chest_ce_slot_port(&eq, input, ce, n_slot, n_port);

				mse_mag = mse_phase = 0;
				for (i=0;i<num_re;i++) {
					mse_mag += (cabsf(h[i]) - cabsf(ce[i])) * (cabsf(h[i]) - cabsf(ce[i])) / num_re;
					mse_phase += (cargf(h[i]) - cargf(ce[i])) * (cargf(h[i]) - cargf(ce[i])) / num_re;
				}

				if (check_mse(mse_mag, mse_phase, n_port)) {
					goto do_exit;
				}

				if (fmatlab) {
					fprintf(fmatlab, "input=");
					vec_fprint_c(fmatlab, input, num_re);
					fprintf(fmatlab, ";\n");
					fprintf(fmatlab, "h=");
					vec_fprint_c(fmatlab, h, num_re);
					fprintf(fmatlab, ";\n");
					fprintf(fmatlab, "ce=");
					vec_fprint_c(fmatlab, ce, num_re);
					fprintf(fmatlab, ";\n");
					chest_fprint(&eq, fmatlab, n_slot, n_port);
				}
			}
		}
		chest_free(&eq);
		cid+=10;
		INFO("cid=%d\n", cid);
	}


	ret = 0;

do_exit:

	if (ce) {
		free(ce);
	}
	if (input) {
		free(input);
	}
	if (h) {
		free(h);
	}

	if (!ret) {
		printf("OK\n");
	} else {
		printf("Error at cid=%d, slot=%d, port=%d\n",cid, n_slot, n_port);
	}

	exit(ret);
}
Exemplo n.º 4
0
int base_init() {
	int i;

	if (filesource_init(&fsrc, input_file_name, COMPLEX_FLOAT_BIN)) {
		fprintf(stderr, "Error opening file %s\n", input_file_name);
		exit(-1);
	}

	if (matlab_file_name) {
		fmatlab = fopen(matlab_file_name, "w");
		if (!fmatlab) {
			perror("fopen");
			return -1;
		}
	} else {
		fmatlab = NULL;
	}

	flen = SLOT_LEN(lte_symbol_sz(nof_prb), cp);

	input_buffer = malloc(flen * sizeof(cf_t));
	if (!input_buffer) {
		perror("malloc");
		exit(-1);
	}

	fft_buffer = malloc(CP_NSYMB(cp) * nof_prb * RE_X_RB * sizeof(cf_t));
	if (!fft_buffer) {
		perror("malloc");
		return -1;
	}

	for (i=0;i<MAX_PORTS_CTRL;i++) {
		ce[i] = malloc(CP_NSYMB(cp) * nof_prb * RE_X_RB * sizeof(cf_t));
		if (!ce[i]) {
			perror("malloc");
			return -1;
		}
	}

	if (chest_init(&chest, LINEAR, cp, nof_prb, nof_ports)) {
		fprintf(stderr, "Error initializing equalizer\n");
		return -1;
	}

	if (chest_ref_LTEDL(&chest, cell_id)) {
		fprintf(stderr, "Error initializing reference signal\n");
		return -1;
	}

	if (lte_fft_init(&fft, cp, nof_prb)) {
		fprintf(stderr, "Error initializing FFT\n");
		return -1;
	}

	if (regs_init(&regs, cell_id, nof_prb, nof_ports, phich_res, phich_length, cp)) {
		fprintf(stderr, "Error initiating regs\n");
		return -1;
	}

	if (phich_init(&phich, &regs, cell_id, nof_prb, nof_ports, cp)) {
		fprintf(stderr, "Error creating PBCH object\n");
		return -1;
	}

	DEBUG("Memory init OK\n",0);
	return 0;
}