Exemple #1
0
void chest_free(chest_t *q) {
	int p, n;
	for (p=0;p<q->nof_ports;p++) {
		for (n=0;n<NSLOTS_X_FRAME;n++) {
			refsignal_free(&q->refsignal[p][n]);
		}
	}
	bzero(q, sizeof(chest_t));
}
Exemple #2
0
void chest_free(chest_t *q) {
  int p, n;
  for (p=0;p<q->nof_ports;p++) {
    for (n=0;n<NSLOTS_X_FRAME;n++) {
      refsignal_free(&q->refsignal[p][n]);
    }
  }
#ifdef VOLK_INTERP
  for (p=0;p<MAX_PORTS;p++) {
    interp_free(&q->interp_freq[p]);
    interp_free(&q->interp_time[p]);    
  }
#endif
  bzero(q, sizeof(chest_t));
}
Exemple #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);
}