void base_free() { int i; filesource_free(&fsrc); if (fmatlab) { fclose(fmatlab); } free(input_buffer); free(fft_buffer); filesource_free(&fsrc); for (i=0;i<cell.nof_ports;i++) { free(ce[i]); } chest_free(&chest); lte_fft_free(&fft); pbch_free(&pbch); }
void base_free() { int i; filesource_free(&fsrc); if (fmatlab) { fclose(fmatlab); } free(input_buffer); free(fft_buffer); filesource_free(&fsrc); for (i=0;i<MAX_PORTS_CTRL;i++) { free(ce[i]); } chest_free(&chest); lte_fft_free(&fft); phich_free(&phich); regs_free(®s); }
void base_free() { int i; filesource_free(&fsrc); if (fmatlab) { fclose(fmatlab); } free(input_buffer); free(fft_buffer); filesource_free(&fsrc); for (i=0;i<MAX_PORTS;i++) { free(ce[i]); } chest_free(&chest); lte_fft_free(&fft); pdcch_free(&pdcch); pdsch_free(&pdsch); pdsch_harq_free(&harq_process); regs_free(®s); }
int chest_stop(chest_hl* hl) { chest_free(&hl->obj); return 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); }