void base_init() { /* init memory */ slot_buffer = malloc(sizeof(cf_t) * slot_n_re); if (!slot_buffer) { perror("malloc"); exit(-1); } output_buffer = malloc(sizeof(cf_t) * slot_n_samples); if (!output_buffer) { perror("malloc"); exit(-1); } /* open file or USRP */ if (output_file_name) { if (filesink_init(&fsink, output_file_name, COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", output_file_name); exit(-1); } } else { #ifndef DISABLE_UHD printf("Opening UHD device...\n"); if (cuhd_open(uhd_args,&uhd)) { fprintf(stderr, "Error opening uhd\n"); exit(-1); } #else printf("Error UHD not available. Select an output file\n"); exit(-1); #endif } /* create ifft object */ if (lte_ifft_init(&ifft, CPNORM, nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } if (pbch_init(&pbch, 6, cell_id, CPNORM)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } }
void base_init() { /* init memory */ sf_buffer = malloc(sizeof(cf_t) * sf_n_re); if (!sf_buffer) { perror("malloc"); exit(-1); } output_buffer = malloc(sizeof(cf_t) * sf_n_samples); if (!output_buffer) { perror("malloc"); exit(-1); } /* open file or USRP */ if (output_file_name) { if (filesink_init(&fsink, output_file_name, COMPLEX_FLOAT_BIN)) { fprintf(stderr, "Error opening file %s\n", output_file_name); exit(-1); } } else { #ifndef DISABLE_UHD printf("Opening UHD device...\n"); if (cuhd_open(uhd_args, &uhd)) { fprintf(stderr, "Error opening uhd\n"); exit(-1); } #else printf("Error UHD not available. Select an output file\n"); exit(-1); #endif } /* create ifft object */ if (lte_ifft_init(&ifft, CPNORM, cell.nof_prb)) { fprintf(stderr, "Error creating iFFT object\n"); exit(-1); } if (pbch_init(&pbch, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } if (regs_init(®s, R_1, PHICH_NORM, cell)) { fprintf(stderr, "Error initiating regs\n"); exit(-1); } if (pcfich_init(&pcfich, ®s, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } if (regs_set_cfi(®s, cfi)) { fprintf(stderr, "Error setting CFI\n"); exit(-1); } if (pdcch_init(&pdcch, ®s, cell)) { fprintf(stderr, "Error creating PDCCH object\n"); exit(-1); } if (pdsch_init(&pdsch, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); exit(-1); } pdsch_set_rnti(&pdsch, 1234); if (pdsch_harq_init(&harq_process, &pdsch)) { fprintf(stderr, "Error initiating HARQ process\n"); exit(-1); } }
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; } input_buffer = malloc(FLEN * sizeof(cf_t)); if (!input_buffer) { perror("malloc"); exit(-1); } fft_buffer = malloc(2 * CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB * sizeof(cf_t)); if (!fft_buffer) { perror("malloc"); return -1; } for (i=0;i<cell.nof_ports;i++) { ce[i] = malloc(2 * CP_NSYMB(cell.cp) * cell.nof_prb * RE_X_RB * sizeof(cf_t)); if (!ce[i]) { perror("malloc"); return -1; } } if (!lte_cell_isvalid(&cell)) { fprintf(stderr, "Invalid cell properties\n"); return -1; } if (chest_init_LTEDL(&chest, cell)) { fprintf(stderr, "Error initializing equalizer\n"); return -1; } if (lte_fft_init(&fft, cell.cp, cell.nof_prb)) { fprintf(stderr, "Error initializing FFT\n"); return -1; } if (pbch_init(&pbch, cell)) { fprintf(stderr, "Error initiating PBCH\n"); return -1; } DEBUG("Memory init OK\n",0); return 0; }
int main(int argc, char **argv) { pbch_t pbch; pbch_mib_t mib_tx, mib_rx; int i, j; cf_t *ce[MAX_PORTS]; int nof_re; cf_t *sf_symbols[MAX_PORTS]; parse_args(argc,argv); nof_re = 2 * CPNORM_NSYMB * cell.nof_prb * RE_X_RB; /* init memory */ for (i=0;i<cell.nof_ports;i++) { ce[i] = malloc(sizeof(cf_t) * nof_re); if (!ce[i]) { perror("malloc"); exit(-1); } for (j=0;j<nof_re;j++) { ce[i][j] = 1; } sf_symbols[i] = malloc(sizeof(cf_t) * nof_re); if (!sf_symbols[i]) { perror("malloc"); exit(-1); } } if (pbch_init(&pbch, cell)) { fprintf(stderr, "Error creating PBCH object\n"); exit(-1); } mib_tx.nof_ports = cell.nof_ports; mib_tx.nof_prb = 50; mib_tx.phich_length = PHICH_EXT; mib_tx.phich_resources = R_1_6; mib_tx.sfn = 124; pbch_encode(&pbch, &mib_tx, sf_symbols); /* combine outputs */ for (i=1;i<cell.nof_ports;i++) { for (j=0;j<nof_re;j++) { sf_symbols[0][j] += sf_symbols[i][j]; } } pbch_decode_reset(&pbch); if (1 != pbch_decode(&pbch, sf_symbols[0], ce, &mib_rx)) { printf("Error decoding\n"); exit(-1); } pbch_free(&pbch); for (i=0;i<cell.nof_ports;i++) { free(ce[i]); free(sf_symbols[i]); } if (!memcmp(&mib_tx, &mib_rx, sizeof(pbch_mib_t))) { printf("OK\n"); exit(0); } else { pbch_mib_fprint(stdout, &mib_rx); exit(-1); } }